##// END OF EJS Templates
Added new MemChecker plugin....
jeandet -
r31:52e9b3517eea default
parent child
Show More
@@ -0,0 +1,57
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #include "memchecker.h"
23
24 memchecker::memchecker(socexplorerplugin* plugin)
25 {
26 this->plugin = plugin;
27 }
28
29 bool memchecker::checkmemory(unsigned int address,unsigned int size)
30 {
31 bool success = true;
32 unsigned int* dataLocal = (unsigned int*)malloc(size);
33 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
34 for(int i=0;(unsigned int)i<(size>>2);i++)
35 {
36 dataLocal[i]= (0xFFFF&rand())+(rand()<<16);
37 }
38 plugin->Write(dataLocal,size>>2,address);
39 plugin->Read(dataOnBoard,size>>2,address);
40 for(int i=0;(unsigned int)i<(size>>2);i++)
41 {
42 if(dataLocal[i]!=dataOnBoard[i])
43 success=false;
44 }
45
46 free(dataLocal);
47 free(dataOnBoard);
48 return success;
49 }
50
51 bool memchecker::checkdatabits(unsigned int address,unsigned int size)
52 {
53 bool success = true;
54 return success;
55 }
56
57
@@ -0,0 +1,38
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #ifndef MEMCHECKER_H
23 #define MEMCHECKER_H
24
25 #include <socexplorerplugin.h>
26
27 class memchecker
28 {
29 public:
30 memchecker(socexplorerplugin* plugin);
31 bool checkmemory(unsigned int address,unsigned int size);
32 bool checkdatabits(unsigned int address,unsigned int size);
33
34 private:
35 socexplorerplugin* plugin;
36 };
37
38 #endif // MEMCHECKER_H
@@ -0,0 +1,39
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #include "memcheckplugin.h"
23
24 memcheckplugin::memcheckplugin(QWidget *parent):socexplorerplugin(parent,true)
25 {
26 this->UI = new memcheckplugin_ui();
27 this->setWidget(this->UI);
28 this->checker = new memchecker(this);
29 }
30
31 memcheckplugin::~memcheckplugin()
32 {}
33
34 void memcheckplugin::startCheck()
35 {
36
37 }
38
39
@@ -0,0 +1,69
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #ifndef MEMCTRLRPLUGIN_H
23 /*------------------------------------------------------------------------------
24 -- This file is a part of the SocExplorer Software
25 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
26 --
27 -- This program is free software; you can redistribute it and/or modify
28 -- it under the terms of the GNU General Public License as published by
29 -- the Free Software Foundation; either version 3 of the License, or
30 -- (at your option) any later version.
31 --
32 -- This program is distributed in the hope that it will be useful,
33 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
34 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 -- GNU General Public License for more details.
36 --
37 -- You should have received a copy of the GNU General Public License
38 -- along with this program; if not, write to the Free Software
39 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 -------------------------------------------------------------------------------*/
41 /*-- Author : Alexis Jeandet
42 -- Mail : alexis.jeandet@lpp.polytechnique.fr
43 ----------------------------------------------------------------------------*/
44 #define MEMCTRLRPLUGIN_H
45 #include "memcheckplugin_ui.h"
46 #include <QMenuBar>
47 #include <QMenu>
48 #include <QAction>
49 #include <QMainWindow>
50 #include <socexplorerplugin.h>
51 #include <memchecker.h>
52 #include <socexplorerplugin.h>
53
54 class memcheckplugin : public socexplorerplugin
55 {
56 Q_OBJECT
57 public:
58 explicit memcheckplugin(QWidget *parent = 0);
59 ~memcheckplugin();
60 public slots:
61 void startCheck();
62 signals:
63
64 private:
65 memcheckplugin_ui* UI;
66 memchecker* checker;
67 };
68
69 #endif // MEMCTRLRPLUGIN_H
@@ -0,0 +1,71
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
4 #-------------------------------------------------
5
6 CONFIG += socexplorerplugin
7 CONFIG += dll
8 CONFIG -= static
9
10 CONFIG(debug, debug|release) {
11 DEBUG_EXT = _d
12 } else {
13 DEBUG_EXT =
14 }
15
16 TARGET = memcheckplugin$${DEBUG_EXT}
17 DEFINES += PLUGIN=memcheckplugin
18 DEFINES += PLUGINHEADER="\"\\\"memcheckplugin.h"\\\"\"
19 DEFINES += driver_Name="\"\\\"MemChecker"\\\"\"
20 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
21 DEFINES += driver_Version="\"\\\"1.0.1"\\\"\"
22 DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\"
23 DEFINES += driver_can_be_root=0
24 DEFINES += driver_can_be_child=1
25 DEFINES += driver_VID=0x04
26 DEFINES += driver_PID=0x0f
27
28 #LIBS +=-llppmoncommon
29
30 INCLUDEPATH += \
31 $${PWD}
32
33 HEADERS += \
34 memcheckplugin.h \
35 memcheckplugin_ui.h \
36 memchecker.h
37
38 SOURCES += \
39 memcheckplugin.cpp \
40 memcheckplugin_ui.cpp \
41 memchecker.cpp
42
43 FORMS += \
44 memcheckplugin_ui.ui
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@@ -0,0 +1,54
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #include "memcheckplugin_ui.h"
23 #include "ui_memcheckplugin_ui.h"
24 #include <memsizewdgt.h>
25 #include <qhexspinbox.h>
26
27 memcheckplugin_ui::memcheckplugin_ui(QWidget *parent) :
28 QWidget(parent),
29 ui(new Ui::memcheckplugin_ui)
30 {
31 ui->setupUi(this);
32 connect(this->ui->StartTestQpb,SIGNAL(clicked()),this,SLOT(startCheck()));
33 }
34
35 memcheckplugin_ui::~memcheckplugin_ui()
36 {
37 delete ui;
38 }
39
40 void memcheckplugin_ui::startCheck()
41 {
42 if(this->ui->testTypeQchkBx->currentText()=="Check data bits")
43 {
44 emit checkdatabits(this->ui->StartAddress->value(),this->ui->MemSize->getsize());
45 }
46 if(this->ui->testTypeQchkBx->currentText()=="Check memory size")
47 {
48 emit checkmemory(this->ui->StartAddress->value(),this->ui->MemSize->getsize());
49 }
50 if(this->ui->testTypeQchkBx->currentText()=="Full test")
51 {
52
53 }
54 }
@@ -0,0 +1,47
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
22 #ifndef MEMCHECKPLUGIN_UI_H
23 #define MEMCHECKPLUGIN_UI_H
24
25 #include <QWidget>
26
27 namespace Ui {
28 class memcheckplugin_ui;
29 }
30
31 class memcheckplugin_ui : public QWidget
32 {
33 Q_OBJECT
34
35 public:
36 explicit memcheckplugin_ui(QWidget *parent = 0);
37 ~memcheckplugin_ui();
38 public slots:
39 void startCheck();
40 signals:
41 bool checkmemory(unsigned int address,unsigned int size);
42 bool checkdatabits(unsigned int address,unsigned int size);
43 private:
44 Ui::memcheckplugin_ui *ui;
45 };
46
47 #endif // MEMCHECKPLUGIN_UI_H
@@ -0,0 +1,102
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>memcheckplugin_ui</class>
4 <widget class="QWidget" name="memcheckplugin_ui">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>664</width>
10 <height>288</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="3" column="0" colspan="2">
18 <widget class="QComboBox" name="testTypeQchkBx">
19 <item>
20 <property name="text">
21 <string>Check data bits</string>
22 </property>
23 </item>
24 <item>
25 <property name="text">
26 <string>Check memory size</string>
27 </property>
28 </item>
29 <item>
30 <property name="text">
31 <string>Full test</string>
32 </property>
33 </item>
34 </widget>
35 </item>
36 <item row="6" column="0" colspan="2">
37 <widget class="QTextEdit" name="testDetails">
38 <property name="readOnly">
39 <bool>true</bool>
40 </property>
41 </widget>
42 </item>
43 <item row="5" column="0">
44 <widget class="QLabel" name="TestResultLbl">
45 <property name="text">
46 <string>Test result</string>
47 </property>
48 </widget>
49 </item>
50 <item row="5" column="1">
51 <widget class="QLabel" name="TestResult">
52 <property name="text">
53 <string/>
54 </property>
55 </widget>
56 </item>
57 <item row="1" column="0">
58 <widget class="QLabel" name="MemSizeLbl">
59 <property name="text">
60 <string>Memory Size</string>
61 </property>
62 </widget>
63 </item>
64 <item row="0" column="0">
65 <widget class="QLabel" name="StartAddressLbl">
66 <property name="text">
67 <string>Start address</string>
68 </property>
69 </widget>
70 </item>
71 <item row="4" column="0" colspan="2">
72 <widget class="QPushButton" name="StartTestQpb">
73 <property name="text">
74 <string>Start Test</string>
75 </property>
76 </widget>
77 </item>
78 <item row="0" column="1">
79 <widget class="QHexSpinBox" name="StartAddress" native="true"/>
80 </item>
81 <item row="1" column="1">
82 <widget class="MemSizeWdgt" name="MemSize" native="true"/>
83 </item>
84 </layout>
85 </widget>
86 <customwidgets>
87 <customwidget>
88 <class>QHexSpinBox</class>
89 <extends>QWidget</extends>
90 <header location="global">qhexspinbox.h</header>
91 <container>1</container>
92 </customwidget>
93 <customwidget>
94 <class>MemSizeWdgt</class>
95 <extends>QWidget</extends>
96 <header location="global">memsizewdgt.h</header>
97 <container>1</container>
98 </customwidget>
99 </customwidgets>
100 <resources/>
101 <connections/>
102 </ui>
@@ -8,6 +8,7 SUBDIRS = \
8 APBUARTPLUGIN \
8 APBUARTPLUGIN \
9 dsu3plugin \
9 dsu3plugin \
10 genericrwplugin \
10 genericrwplugin \
11 memctrlrplugin
11 memctrlrplugin \
12 memcheckplugin
12
13
13 unix:SUBDIRS += spwplugin
14 unix:SUBDIRS += spwplugin
@@ -47,6 +47,8 ahbuartplugin::ahbuartplugin(QWidget *pa
47 QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint)));
47 QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint)));
48 QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>)));
48 QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>)));
49 QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList()));
49 QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList()));
50 QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int)));
51 QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int)));
50 this->portListcompleter = NULL;
52 this->portListcompleter = NULL;
51 this->scanDone = false;
53 this->scanDone = false;
52 updatePortList();
54 updatePortList();
@@ -147,7 +149,6 void ahbuartplugin::connectPort(QString
147 char test2[1024];
149 char test2[1024];
148 SAFEWRITE(test,1,timeout,2000,return);
150 SAFEWRITE(test,1,timeout,2000,return);
149 SAFEWRITE((test+1),1,timeout,2000,return);
151 SAFEWRITE((test+1),1,timeout,2000,return);
150 APPENDTOLOG(QString("Flush port "));
151 rs232read(this->port,test2,512);
152 rs232read(this->port,test2,512);
152 int read = 0;
153 int read = 0;
153 for(int i=0;i<10;i++)
154 for(int i=0;i<10;i++)
@@ -235,8 +236,6 unsigned int ahbuartplugin::Read(unsigne
235 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
236 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
236 {
237 {
237 QMutexLocker lock(portMutex);
238 QMutexLocker lock(portMutex);
238 // if(!this->portMutex->tryLock())
239 // return 0;
240 if(!this->checkConnection())
239 if(!this->checkConnection())
241 {
240 {
242 this->Connected = false;
241 this->Connected = false;
@@ -256,13 +255,11 unsigned int ahbuartplugin::Read(unsigne
256 CMD[2] = (char)((address>>16)&0xFF);
255 CMD[2] = (char)((address>>16)&0xFF);
257 CMD[3] = (char)((address>>8)&0xFF);
256 CMD[3] = (char)((address>>8)&0xFF);
258 CMD[4] = (char)((address)&0xFF);
257 CMD[4] = (char)((address)&0xFF);
259 // APENDTABLETOLOG(CMD,5,logmessage,"Write CMD : ");
260 SAFEWRITE(CMD,5,timeout,1000,return 0);
258 SAFEWRITE(CMD,5,timeout,1000,return 0);
261 #ifdef WIN32
259 #ifdef WIN32
262 usleep(1000);
260 usleep(1000);
263 #endif
261 #endif
264 SAFEREAD(result+((cnt-count)*4),32*4,timeout,1000,return 0);
262 SAFEREAD(result+((cnt-count)*4),32*4,timeout,1000,return 0);
265 // APENDTABLETOLOG((result+((cnt-count)*4)),32*4,logmessage, QString("Get ") + QString::number(32*4) + " Bytes : ");
266 count-=32;
263 count-=32;
267 address+=32*4;
264 address+=32*4;
268 if(cnt>128)
265 if(cnt>128)
@@ -288,7 +285,6 unsigned int ahbuartplugin::Read(unsigne
288 usleep(1000);
285 usleep(1000);
289 #endif
286 #endif
290 SAFEREAD(result+((cnt-count)*4),(count*4),timeout,1000,return 0);
287 SAFEREAD(result+((cnt-count)*4),(count*4),timeout,1000,return 0);
291 // APENDTABLETOLOG((result+((cnt-count)*4)),(count*4),logmessage, QString("Get ") + QString::number(32*4) + " Bytes : ");
292 }
288 }
293 if(cnt>128)
289 if(cnt>128)
294 {
290 {
@@ -307,8 +303,8 unsigned int ahbuartplugin::Read(unsigne
307 if(cnt>128)
303 if(cnt>128)
308 SocExplorerEngine::deleteProgressBar(progress);
304 SocExplorerEngine::deleteProgressBar(progress);
309 free(result);
305 free(result);
310 // this->portMutex->unlock();
311 }
306 }
307 emit this->addReadBytes(read);
312 return read/4;
308 return read/4;
313 }
309 }
314
310
@@ -322,8 +318,6 unsigned int ahbuartplugin::Write(unsign
322 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
318 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
323 {
319 {
324 QMutexLocker lock(portMutex);
320 QMutexLocker lock(portMutex);
325 // if(!this->portMutex->tryLock())
326 // return 0;
327 if(!this->checkConnection())
321 if(!this->checkConnection())
328 {
322 {
329 emit this->activateSig(false);
323 emit this->activateSig(false);
@@ -388,7 +382,7 unsigned int ahbuartplugin::Write(unsign
388 SocExplorerEngine::deleteProgressBar(progress);
382 SocExplorerEngine::deleteProgressBar(progress);
389 }
383 }
390 free(CMD);
384 free(CMD);
391 // this->portMutex->unlock();
385 emit this->addWritenBytes(writen);
392 return writen;
386 return writen;
393 }
387 }
394 return 0;
388 return 0;
@@ -34,22 +34,6
34 #include <RS232.h>
34 #include <RS232.h>
35
35
36
36
37
38
39
40 #define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message)
41
42 #define APENDTABLETOLOG(table,size,Qstr,message) \
43 Qstr.clear();\
44 Qstr+=message;\
45 for(int __i__tbllog__=0;(unsigned int)__i__tbllog__<size;__i__tbllog__++)\
46 {\
47 if(__i__tbllog__%16==0) Qstr += "\n"; \
48 Qstr += "0x" + QString::number((int)(0xff & table[__i__tbllog__]),16) +"\t";\
49 }\
50 APPENDTOLOG(Qstr);
51
52
53 #define SAFEWRITE(data,count,timer,timeout,error) \
37 #define SAFEWRITE(data,count,timer,timeout,error) \
54 while(1)\
38 while(1)\
55 {\
39 {\
@@ -60,7 +44,6 while(1)\
60 __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
44 __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
61 if((timer).elapsed()>(timeout)) \
45 if((timer).elapsed()>(timeout)) \
62 {\
46 {\
63 APPENDTOLOG(QString("Timeout error while writing"));\
64 this->port = (rs232port_t)NULL; \
47 this->port = (rs232port_t)NULL; \
65 this->Connected = false; \
48 this->Connected = false; \
66 emit this->activateSig(false); \
49 emit this->activateSig(false); \
@@ -79,7 +62,6 unsigned int __read__=0; \
79 __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \
62 __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \
80 if((timer).elapsed()>(timeout)) \
63 if((timer).elapsed()>(timeout)) \
81 { \
64 { \
82 APPENDTOLOG(QString("Timeout error while reading"));\
83 this->Connected = false; \
65 this->Connected = false; \
84 emit this->activateSig(false); \
66 emit this->activateSig(false); \
85 this->portMutex->unlock(); \
67 this->portMutex->unlock(); \
@@ -111,6 +93,8 public slots:
111 void WriteBytes(unsigned int address,QList<QVariant> dataList);
93 void WriteBytes(unsigned int address,QList<QVariant> dataList);
112 signals:
94 signals:
113 void setProgressValue(int progress);
95 void setProgressValue(int progress);
96 void addWritenBytes(int count);
97 void addReadBytes(int count);
114 private:
98 private:
115 bool scanDone;
99 bool scanDone;
116 QProgressDialog* progress;
100 QProgressDialog* progress;
@@ -29,10 +29,9 ahbUartPluginUI::ahbUartPluginUI(QWidget
29 ui->setupUi(this);
29 ui->setupUi(this);
30 connect(ui->OpenPort,SIGNAL(clicked()),this,SLOT(connectPort()));
30 connect(ui->OpenPort,SIGNAL(clicked()),this,SLOT(connectPort()));
31 connect(ui->PortspeedSlider,SIGNAL(valueChanged(int)),ui->baurateLCD,SLOT(display(int)));
31 connect(ui->PortspeedSlider,SIGNAL(valueChanged(int)),ui->baurateLCD,SLOT(display(int)));
32 connect(ui->logFileChooseBp,SIGNAL(clicked()),this,SLOT(chooseLogFile()));
33 connect(this,SIGNAL(setLogFileName(QString)),this->ui->logFileName,SLOT(setText(QString)));
34 connect(ui->rescanPorts,SIGNAL(clicked()),this,SIGNAL(rescanPorts()));
32 connect(ui->rescanPorts,SIGNAL(clicked()),this,SIGNAL(rescanPorts()));
35 this->logFile = new QFile();
33 this->writtenBytes = 0;
34 this->readBytes = 0;
36 }
35 }
37
36
38 void ahbUartPluginUI::connectPort()
37 void ahbUartPluginUI::connectPort()
@@ -57,49 +56,24 ahbUartPluginUI::~ahbUartPluginUI()
57 }
56 }
58
57
59
58
60 void ahbUartPluginUI::chooseLogFile()
61 {
62 if(this->logFile->isOpen())
63 this->logFile->close();
64 this->logFile->setFileName(QFileDialog::getSaveFileName(this,tr("Open Log file"),QDir::homePath(), tr("Log Files (*.txt *.log)")));
65 if(this->logFile->open(QIODevice::WriteOnly))
66 {
67 this->logFileStrm = new QTextStream(this->logFile);
68 emit this->setLogFileName(this->logFile->fileName());
69 }
70 }
71
72 void ahbUartPluginUI::setconfig(QString PortName, int baudrate)
59 void ahbUartPluginUI::setconfig(QString PortName, int baudrate)
73 {
60 {
74 this->ui->PortName->setText(PortName);
61 this->ui->PortName->setText(PortName);
75 this->ui->PortspeedSlider->setValue(baudrate);
62 this->ui->PortspeedSlider->setValue(baudrate);
76 }
63 }
77
64
78
65 void ahbUartPluginUI::addWritenBytes(int count)
79 void ahbUartPluginUI::logFileEnDisable(int state)
80 {
66 {
81 if(state==Qt::Checked)
67 this->writtenBytes+=count;
82 {
68 this->ui->WrBytesLCD->display(this->writtenBytes);
83 this->logFileEn = true;
84 }
85 else if(state==Qt::Unchecked)
86 {
87 this->logFileEn = false;
88 }
89 }
69 }
90
70
91 bool ahbUartPluginUI::islogfileenable()
71 void ahbUartPluginUI::addReadBytes(int count)
92 {
72 {
93 return this->logFileEn;
73 this->readBytes+=count;
74 this->ui->RdBytesLCD->display(this->readBytes);
94 }
75 }
95
76
96 void ahbUartPluginUI::appendToLogFile(const QString & text)
97 {
98 if(this->logFileEn && this->logFile->isOpen())
99 {
100 *(this->logFileStrm) << text << endl;
101 }
102 }
103
77
104 void ahbUartPluginUI::setCompleter(QCompleter *completer)
78 void ahbUartPluginUI::setCompleter(QCompleter *completer)
105 {
79 {
@@ -108,12 +82,6 void ahbUartPluginUI::setCompleter(QComp
108
82
109 void ahbUartPluginUI::closeEvent(QCloseEvent *event)
83 void ahbUartPluginUI::closeEvent(QCloseEvent *event)
110 {
84 {
111 if(this->logFile->isOpen())
112 {
113 this->logFileStrm->flush();
114 this->logFile->waitForBytesWritten(3000);
115 this->logFile->close();
116 }
117 event->accept();
85 event->accept();
118 }
86 }
119
87
@@ -41,26 +41,23 class ahbUartPluginUI : public QWidget
41 public:
41 public:
42 explicit ahbUartPluginUI(QWidget *parent = 0);
42 explicit ahbUartPluginUI(QWidget *parent = 0);
43 ~ahbUartPluginUI();
43 ~ahbUartPluginUI();
44 bool islogfileenable();
45 void appendToLogFile(const QString & text);
46 void closeEvent(QCloseEvent *event);
44 void closeEvent(QCloseEvent *event);
47 void setCompleter(QCompleter* completer);
45 void setCompleter(QCompleter* completer);
48 public slots:
46 public slots:
49 void setConnected(bool connected);
47 void setConnected(bool connected);
50 void connectPort();
48 void connectPort();
51 void chooseLogFile();
52 void logFileEnDisable(int state);
53 void setconfig(QString PortName,int baudrate);
49 void setconfig(QString PortName,int baudrate);
50 void addWritenBytes(int count);
51 void addReadBytes(int count);
54
52
55 signals:
53 signals:
56 void connectPortsig(QString PortName,int baudrate);
54 void connectPortsig(QString PortName,int baudrate);
57 void setLogFileName(QString FileName);
55 void setLogFileName(QString FileName);
58 void rescanPorts();
56 void rescanPorts();
59 private:
57 private:
58 int writtenBytes;
59 int readBytes;
60 Ui::ahbUartPluginUI *ui;
60 Ui::ahbUartPluginUI *ui;
61 QFile* logFile;
62 QTextStream* logFileStrm;
63 bool logFileEn;
64 };
61 };
65
62
66 #endif // AHBUARTPLUGINUI_H
63 #endif // AHBUARTPLUGINUI_H
@@ -6,14 +6,57
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>947</width>
9 <width>768</width>
10 <height>279</height>
10 <height>196</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <layout class="QGridLayout" name="gridLayout_2">
16 <layout class="QGridLayout" name="gridLayout_2">
17 <item row="4" column="0" colspan="3">
18 <widget class="QGroupBox" name="Statistiques">
19 <property name="title">
20 <string>Statistics</string>
21 </property>
22 <layout class="QGridLayout" name="gridLayout">
23 <item row="0" column="2">
24 <widget class="QLCDNumber" name="WrBytesLCD">
25 <property name="digitCount">
26 <number>8</number>
27 </property>
28 <property name="segmentStyle">
29 <enum>QLCDNumber::Flat</enum>
30 </property>
31 </widget>
32 </item>
33 <item row="1" column="2">
34 <widget class="QLCDNumber" name="RdBytesLCD">
35 <property name="digitCount">
36 <number>8</number>
37 </property>
38 <property name="segmentStyle">
39 <enum>QLCDNumber::Flat</enum>
40 </property>
41 </widget>
42 </item>
43 <item row="1" column="0">
44 <widget class="QLabel" name="RdBytesLbl">
45 <property name="text">
46 <string>Read Bytes</string>
47 </property>
48 </widget>
49 </item>
50 <item row="0" column="0">
51 <widget class="QLabel" name="WrBytesLbl">
52 <property name="text">
53 <string>Writen Bytes</string>
54 </property>
55 </widget>
56 </item>
57 </layout>
58 </widget>
59 </item>
17 <item row="1" column="1">
60 <item row="1" column="1">
18 <widget class="QSlider" name="PortspeedSlider">
61 <widget class="QSlider" name="PortspeedSlider">
19 <property name="maximum">
62 <property name="maximum">
@@ -33,34 +76,10
33 </property>
76 </property>
34 </widget>
77 </widget>
35 </item>
78 </item>
36 <item row="0" column="1">
79 <item row="1" column="0">
37 <widget class="QLineEdit" name="PortName"/>
80 <widget class="QLabel" name="label_2">
38 </item>
39 <item row="3" column="2">
40 <widget class="QPushButton" name="OpenPort">
41 <property name="text">
42 <string>Open Port</string>
43 </property>
44 </widget>
45 </item>
46 <item row="2" column="0">
47 <widget class="QCheckBox" name="logEnableChkBx">
48 <property name="text">
81 <property name="text">
49 <string>Enable Logs</string>
82 <string>Port Speed</string>
50 </property>
51 </widget>
52 </item>
53 <item row="2" column="1">
54 <widget class="QPushButton" name="logFileChooseBp">
55 <property name="text">
56 <string>Choose file</string>
57 </property>
58 </widget>
59 </item>
60 <item row="0" column="2">
61 <widget class="QPushButton" name="rescanPorts">
62 <property name="text">
63 <string>SCAN</string>
64 </property>
83 </property>
65 </widget>
84 </widget>
66 </item>
85 </item>
@@ -71,19 +90,15
71 </property>
90 </property>
72 </widget>
91 </widget>
73 </item>
92 </item>
74 <item row="1" column="0">
93 <item row="0" column="2">
75 <widget class="QLabel" name="label_2">
94 <widget class="QPushButton" name="rescanPorts">
76 <property name="text">
95 <property name="text">
77 <string>Port Speed</string>
96 <string>SCAN</string>
78 </property>
97 </property>
79 </widget>
98 </widget>
80 </item>
99 </item>
81 <item row="3" column="0" colspan="2">
100 <item row="0" column="1">
82 <widget class="QLabel" name="logFileName">
101 <widget class="QLineEdit" name="PortName"/>
83 <property name="text">
84 <string/>
85 </property>
86 </widget>
87 </item>
102 </item>
88 <item row="1" column="2">
103 <item row="1" column="2">
89 <widget class="QLCDNumber" name="baurateLCD">
104 <widget class="QLCDNumber" name="baurateLCD">
@@ -93,9 +108,6
93 <bold>true</bold>
108 <bold>true</bold>
94 </font>
109 </font>
95 </property>
110 </property>
96 <property name="numDigits">
97 <number>7</number>
98 </property>
99 <property name="digitCount">
111 <property name="digitCount">
100 <number>7</number>
112 <number>7</number>
101 </property>
113 </property>
@@ -104,6 +116,26
104 </property>
116 </property>
105 </widget>
117 </widget>
106 </item>
118 </item>
119 <item row="3" column="0">
120 <spacer name="verticalSpacer">
121 <property name="orientation">
122 <enum>Qt::Vertical</enum>
123 </property>
124 <property name="sizeHint" stdset="0">
125 <size>
126 <width>20</width>
127 <height>40</height>
128 </size>
129 </property>
130 </spacer>
131 </item>
132 <item row="3" column="1" colspan="2">
133 <widget class="QPushButton" name="OpenPort">
134 <property name="text">
135 <string>Open Port</string>
136 </property>
137 </widget>
138 </item>
107 </layout>
139 </layout>
108 </widget>
140 </widget>
109 <resources/>
141 <resources/>
General Comments 0
You need to be logged in to leave comments. Login now