##// 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 34 connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char)));
35 35 connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString)));
36 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 42 APBUART_Plugin_ui::~APBUART_Plugin_ui()
@@ -62,3 +65,36 void APBUART_Plugin_ui::setUartConnected
62 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 23 #define APBUART_PLUGIN_UI_H
24 24
25 25 #include <QWidget>
26 #include <QCompleter>
27 #include <QStringListModel>
26 28
27 29 namespace Ui {
28 30 class APBUART_Plugin_ui;
@@ -39,6 +41,7 public:
39 41 public slots:
40 42 void setEnableForLoopBack(bool enable);
41 43 void setUartConnected(bool enable);
44 void updatePortList();
42 45 signals:
43 46 void loopbackChkBxStateChanged( int state );
44 47 void apbUartTextReceived(QString text);
@@ -48,6 +51,8 signals:
48 51 void PortNameChanged(QString text);
49 52 private:
50 53 Ui::APBUART_Plugin_ui *ui;
54 QCompleter *portListcompleter;
55 QStringListModel *portListcompleterModel;
51 56 };
52 57
53 58 #endif // APBUART_PLUGIN_UI_H
@@ -51,16 +51,23
51 51 </property>
52 52 </widget>
53 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 65 <widget class="QPushButton" name="ConnectQpb">
56 66 <property name="text">
57 67 <string>Open Port</string>
58 68 </property>
59 69 </widget>
60 70 </item>
61 <item row="3" column="1">
62 <widget class="QLineEdit" name="UartSpeedLineEdit"/>
63 </item>
64 71 </layout>
65 72 </widget>
66 73 <widget class="QWidget" name="Terminal">
@@ -42,6 +42,8 UARTPollingThread::~UARTPollingThread()
42 42 void UARTPollingThread::run()
43 43 {
44 44
45 char ch[4097];
46 int timeout =10;
45 47 SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3);
46 48 while (!this->isInterruptionRequested())
47 49 {
@@ -76,21 +78,35 void UARTPollingThread::run()
76 78 }
77 79 else
78 80 {
79 int read =0;
80 char ch[1];
81 int read =0,avail=0;
81 82 uartMutex->lock();
82 83 if(uartOpened)
83 84 {
84 read =rs232read(this->uart,ch,1);
85 SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3);
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 }
99 SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3);
100 ch[read]='\0';
101 }
86 102 }
87 103 uartMutex->unlock();
88 104 if(read>=1)
89 105 {
90 SocExplorerEngine::message(this->plugin,QString("Received one char from APBUART"),3);
91 emit this->apbUartTextReceived(QString(ch[0]));
106 SocExplorerEngine::message(this->plugin,QString("Received %1 char(s) from APBUART").arg(read),3);
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 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 33 unsigned int* dataLocal = (unsigned int*)malloc(size);
33 34 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
34 35 for(int i=0;(unsigned int)i<(size>>2);i++)
@@ -40,18 +41,18 bool memchecker::checkmemory(unsigned in
40 41 for(int i=0;(unsigned int)i<(size>>2);i++)
41 42 {
42 43 if(dataLocal[i]!=dataOnBoard[i])
43 success=false;
44 *success=false;
44 45 }
45
46 46 free(dataLocal);
47 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;
54 return success;
53 *success = true;
54 QString repport;
55 return repport;
55 56 }
56 57
57 58
@@ -28,8 +28,8 class memchecker
28 28 {
29 29 public:
30 30 memchecker(socexplorerplugin* plugin);
31 bool checkmemory(unsigned int address,unsigned int size);
32 bool checkdatabits(unsigned int address,unsigned int size);
31 QString checkmemory(unsigned int address,unsigned int size,bool* success);
32 QString checkdatabits(unsigned int address,unsigned int size,bool* success);
33 33
34 34 private:
35 35 socexplorerplugin* plugin;
@@ -26,14 +26,27 memcheckplugin::memcheckplugin(QWidget *
26 26 this->UI = new memcheckplugin_ui();
27 27 this->setWidget(this->UI);
28 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 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 58 explicit memcheckplugin(QWidget *parent = 0);
59 59 ~memcheckplugin();
60 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 63 signals:
63 64
64 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 37 ~memcheckplugin_ui();
38 38 public slots:
39 39 void startCheck();
40 void setResult(bool success,QString repport);
40 41 signals:
41 bool checkmemory(unsigned int address,unsigned int size);
42 bool checkdatabits(unsigned int address,unsigned int size);
42 void checkmemory(unsigned int address,unsigned int size);
43 void checkdatabits(unsigned int address,unsigned int size);
43 44 private:
44 45 Ui::memcheckplugin_ui *ui;
45 46 };
General Comments 0
You need to be logged in to leave comments. Login now