##// END OF EJS Templates
Improved APB UART Plugin, now check how many bytes are available on uart...
jeandet -
r32:4c8d1b562d91 default
parent child
Show More
@@ -34,6 +34,9 APBUART_Plugin_ui::APBUART_Plugin_ui(QWi
34 connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char)));
34 connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char)));
35 connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString)));
35 connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString)));
36 connect(this->ui->UartSpeedLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(UartSpeedChanged(QString)));
36 connect(this->ui->UartSpeedLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(UartSpeedChanged(QString)));
37 connect(this->ui->rescanQpb,SIGNAL(clicked()),this,SLOT(updatePortList()));
38 this->portListcompleter = NULL;
39 this->updatePortList();
37 }
40 }
38
41
39 APBUART_Plugin_ui::~APBUART_Plugin_ui()
42 APBUART_Plugin_ui::~APBUART_Plugin_ui()
@@ -62,3 +65,36 void APBUART_Plugin_ui::setUartConnected
62 this->ui->ConnectQpb->setText("Open Port");
65 this->ui->ConnectQpb->setText("Open Port");
63 }
66 }
64 }
67 }
68
69 #include <RS232.h>
70
71 void APBUART_Plugin_ui::updatePortList()
72 {
73 if(this->portListcompleter==(QCompleter*)NULL)
74 {
75 this->portListcompleter=new QCompleter(this);
76 this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive);
77 this->portListcompleterModel = new QStringListModel(this);
78 this->portListcompleter->setModel(this->portListcompleterModel);
79 this->ui->PortNameLineEdit->setCompleter(this->portListcompleter);
80 }
81 rs232portslist_t* portlist = rs232getportlist();
82 rs232portslist_t* portlistenum = portlist;
83 QStringList wordList;
84 while(portlistenum!=NULL)
85 {
86 wordList << portlistenum->name;
87 portlistenum = portlistenum->next;
88 }
89 rs232deleteportlist(portlist);
90 this->portListcompleterModel->setStringList(wordList);
91 }
92
93
94
95
96
97
98
99
100
@@ -23,6 +23,8
23 #define APBUART_PLUGIN_UI_H
23 #define APBUART_PLUGIN_UI_H
24
24
25 #include <QWidget>
25 #include <QWidget>
26 #include <QCompleter>
27 #include <QStringListModel>
26
28
27 namespace Ui {
29 namespace Ui {
28 class APBUART_Plugin_ui;
30 class APBUART_Plugin_ui;
@@ -39,6 +41,7 public:
39 public slots:
41 public slots:
40 void setEnableForLoopBack(bool enable);
42 void setEnableForLoopBack(bool enable);
41 void setUartConnected(bool enable);
43 void setUartConnected(bool enable);
44 void updatePortList();
42 signals:
45 signals:
43 void loopbackChkBxStateChanged( int state );
46 void loopbackChkBxStateChanged( int state );
44 void apbUartTextReceived(QString text);
47 void apbUartTextReceived(QString text);
@@ -48,6 +51,8 signals:
48 void PortNameChanged(QString text);
51 void PortNameChanged(QString text);
49 private:
52 private:
50 Ui::APBUART_Plugin_ui *ui;
53 Ui::APBUART_Plugin_ui *ui;
54 QCompleter *portListcompleter;
55 QStringListModel *portListcompleterModel;
51 };
56 };
52
57
53 #endif // APBUART_PLUGIN_UI_H
58 #endif // APBUART_PLUGIN_UI_H
@@ -51,16 +51,23
51 </property>
51 </property>
52 </widget>
52 </widget>
53 </item>
53 </item>
54 <item row="4" column="1">
54 <item row="1" column="2">
55 <widget class="QPushButton" name="rescanQpb">
56 <property name="text">
57 <string>Rescan ports</string>
58 </property>
59 </widget>
60 </item>
61 <item row="3" column="1" colspan="2">
62 <widget class="QLineEdit" name="UartSpeedLineEdit"/>
63 </item>
64 <item row="4" column="1" colspan="2">
55 <widget class="QPushButton" name="ConnectQpb">
65 <widget class="QPushButton" name="ConnectQpb">
56 <property name="text">
66 <property name="text">
57 <string>Open Port</string>
67 <string>Open Port</string>
58 </property>
68 </property>
59 </widget>
69 </widget>
60 </item>
70 </item>
61 <item row="3" column="1">
62 <widget class="QLineEdit" name="UartSpeedLineEdit"/>
63 </item>
64 </layout>
71 </layout>
65 </widget>
72 </widget>
66 <widget class="QWidget" name="Terminal">
73 <widget class="QWidget" name="Terminal">
@@ -42,6 +42,8 UARTPollingThread::~UARTPollingThread()
42 void UARTPollingThread::run()
42 void UARTPollingThread::run()
43 {
43 {
44
44
45 char ch[4097];
46 int timeout =10;
45 SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3);
47 SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3);
46 while (!this->isInterruptionRequested())
48 while (!this->isInterruptionRequested())
47 {
49 {
@@ -76,21 +78,35 void UARTPollingThread::run()
76 }
78 }
77 else
79 else
78 {
80 {
79 int read =0;
81 int read =0,avail=0;
80 char ch[1];
81 uartMutex->lock();
82 uartMutex->lock();
82 if(uartOpened)
83 if(uartOpened)
83 {
84 {
84 read =rs232read(this->uart,ch,1);
85 avail = rs232availablebytes(this->uart);
86 SocExplorerEngine::message(this->plugin,QString("%1 available bytes on uart").arg(read),3);
87 if(avail)
88 {
89 if(avail>=4096)
90 {
91 read = rs232read(this->uart,ch,4096);
92 timeout = 0;
93 }
94 else
95 {
96 read = rs232read(this->uart,ch,avail);
97 timeout = 10;
98 }
85 SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3);
99 SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3);
100 ch[read]='\0';
101 }
86 }
102 }
87 uartMutex->unlock();
103 uartMutex->unlock();
88 if(read>=1)
104 if(read>=1)
89 {
105 {
90 SocExplorerEngine::message(this->plugin,QString("Received one char from APBUART"),3);
106 SocExplorerEngine::message(this->plugin,QString("Received %1 char(s) from APBUART").arg(read),3);
91 emit this->apbUartTextReceived(QString(ch[0]));
107 emit this->apbUartTextReceived(QString(ch));
92 }
108 }
93 msleep(10);
109 msleep(timeout);
94 }
110 }
95 }
111 }
96 }
112 }
@@ -26,9 +26,10 memchecker::memchecker(socexplorerplugin
26 this->plugin = plugin;
26 this->plugin = plugin;
27 }
27 }
28
28
29 bool memchecker::checkmemory(unsigned int address,unsigned int size)
29 QString memchecker::checkmemory(unsigned int address, unsigned int size, bool *success)
30 {
30 {
31 bool success = true;
31 *success = true;
32 QString repport;
32 unsigned int* dataLocal = (unsigned int*)malloc(size);
33 unsigned int* dataLocal = (unsigned int*)malloc(size);
33 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
34 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
34 for(int i=0;(unsigned int)i<(size>>2);i++)
35 for(int i=0;(unsigned int)i<(size>>2);i++)
@@ -40,18 +41,18 bool memchecker::checkmemory(unsigned in
40 for(int i=0;(unsigned int)i<(size>>2);i++)
41 for(int i=0;(unsigned int)i<(size>>2);i++)
41 {
42 {
42 if(dataLocal[i]!=dataOnBoard[i])
43 if(dataLocal[i]!=dataOnBoard[i])
43 success=false;
44 *success=false;
44 }
45 }
45
46 free(dataLocal);
46 free(dataLocal);
47 free(dataOnBoard);
47 free(dataOnBoard);
48 return success;
48 return repport;
49 }
49 }
50
50
51 bool memchecker::checkdatabits(unsigned int address,unsigned int size)
51 QString memchecker::checkdatabits(unsigned int address,unsigned int size,bool* success)
52 {
52 {
53 bool success = true;
53 *success = true;
54 return success;
54 QString repport;
55 return repport;
55 }
56 }
56
57
57
58
@@ -28,8 +28,8 class memchecker
28 {
28 {
29 public:
29 public:
30 memchecker(socexplorerplugin* plugin);
30 memchecker(socexplorerplugin* plugin);
31 bool checkmemory(unsigned int address,unsigned int size);
31 QString checkmemory(unsigned int address,unsigned int size,bool* success);
32 bool checkdatabits(unsigned int address,unsigned int size);
32 QString checkdatabits(unsigned int address,unsigned int size,bool* success);
33
33
34 private:
34 private:
35 socexplorerplugin* plugin;
35 socexplorerplugin* plugin;
@@ -26,14 +26,27 memcheckplugin::memcheckplugin(QWidget *
26 this->UI = new memcheckplugin_ui();
26 this->UI = new memcheckplugin_ui();
27 this->setWidget(this->UI);
27 this->setWidget(this->UI);
28 this->checker = new memchecker(this);
28 this->checker = new memchecker(this);
29 QObject::connect(this->UI,SIGNAL(checkdatabits(uint,uint)),this,SLOT(checkdatabits(uint,uint)));
30 QObject::connect(this->UI,SIGNAL(checkmemory(uint,uint)),this,SLOT(checkmemory(uint,uint)));
29 }
31 }
30
32
31 memcheckplugin::~memcheckplugin()
33 memcheckplugin::~memcheckplugin()
32 {}
34 {}
33
35
34 void memcheckplugin::startCheck()
36
37 void memcheckplugin::checkmemory(unsigned int address, unsigned int size)
35 {
38 {
39 bool success;
40 QString repport=this->checker->checkmemory(address,size,&success);
41 this->UI->setResult(success,repport);
36
42
37 }
43 }
38
44
45 void memcheckplugin::checkdatabits(unsigned int address, unsigned int size)
46 {
47 bool success;
48 QString repport=this->checker->checkdatabits(address,size,&success);
49 this->UI->setResult(success,repport);
50 }
39
51
52
@@ -58,7 +58,8 public:
58 explicit memcheckplugin(QWidget *parent = 0);
58 explicit memcheckplugin(QWidget *parent = 0);
59 ~memcheckplugin();
59 ~memcheckplugin();
60 public slots:
60 public slots:
61 void startCheck();
61 void checkmemory(unsigned int address,unsigned int size);
62 void checkdatabits(unsigned int address,unsigned int size);
62 signals:
63 signals:
63
64
64 private:
65 private:
@@ -52,3 +52,16 void memcheckplugin_ui::startCheck()
52
52
53 }
53 }
54 }
54 }
55
56 void memcheckplugin_ui::setResult(bool success, QString repport)
57 {
58 this->ui->testDetails->setText(repport);
59 if(success)
60 {
61 this->ui->TestResult->setText("Success");
62 }
63 else
64 {
65 this->ui->TestResult->setText("Failed");
66 }
67 }
@@ -37,9 +37,10 public:
37 ~memcheckplugin_ui();
37 ~memcheckplugin_ui();
38 public slots:
38 public slots:
39 void startCheck();
39 void startCheck();
40 void setResult(bool success,QString repport);
40 signals:
41 signals:
41 bool checkmemory(unsigned int address,unsigned int size);
42 void checkmemory(unsigned int address,unsigned int size);
42 bool checkdatabits(unsigned int address,unsigned int size);
43 void checkdatabits(unsigned int address,unsigned int size);
43 private:
44 private:
44 Ui::memcheckplugin_ui *ui;
45 Ui::memcheckplugin_ui *ui;
45 };
46 };
General Comments 0
You need to be logged in to leave comments. Login now