##// END OF EJS Templates
Removed lppserial from ahbuart now uses the one provided by socexplorercommon.
Jeandet Alexis -
r27:8bc9664f2835 default
parent child
Show More
@@ -0,0 +1,70
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 2 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@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #include "uartpollingthread.h"
23 #include <RS232.h>
24 #include <socexplorerengine.h>
25
26 UARTPollingThread::UARTPollingThread(socexplorerplugin *parent) :
27 QThread((QObject*)parent)
28 {
29 this->plugin = parent;
30 rs232open("/dev/ttyUS0");
31 }
32
33 void UARTPollingThread::run()
34 {
35 while (!this->isInterruptionRequested())
36 {
37 if(fifoDebugEnabled)
38 {
39 if(this->plugin->baseAddress()!=-1)
40 {
41 unsigned int status_reg,data;
42 char ch;
43 QString printdata="";
44 plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG);
45 while ((status_reg&4)==0) {
46 plugin->parent->Read(&data,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG);
47 ch = (char)(0xff & data);
48 printdata+=ch;
49 plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG);
50 }
51 if(printdata!="")
52 emit apbUartTextReceived(printdata);
53 }
54 else
55 {
56 this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0));
57 }
58 }
59 if(uartOpened)
60 {
61
62 }
63 msleep(100);
64 }
65 }
66
67 void UARTPollingThread::sendChar(char c)
68 {
69
70 }
@@ -0,0 +1,53
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 2 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@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #ifndef UARTPOLLINGTHREAD_H
23 #define UARTPOLLINGTHREAD_H
24
25 #include <QObject>
26 #include <QThread>
27 #include <socexplorerplugin.h>
28
29 #define APB_UART_DATA_REG 0x0
30 #define APB_UART_STATUS_REG 0x4
31 #define APB_UART_CONTROL_REG 0x8
32 #define APB_UART_SCALE_REG 0xC
33 #define APB_UART_FIFO_DEBUG_REG 0x10
34
35 class UARTPollingThread : public QThread
36 {
37 Q_OBJECT
38 public:
39 explicit UARTPollingThread(socexplorerplugin *parent = 0);
40 void run();
41 signals:
42 void apbUartTextReceived(QString text);
43 public slots:
44 void sendChar(char c);
45 private:
46 bool fifoDebugEnabled;
47 QString portName;
48 int uartSpeed;
49 bool uartOpened;
50 socexplorerplugin* plugin;
51 };
52
53 #endif // UARTPOLLINGTHREAD_H
@@ -1,70 +1,68
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
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
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
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
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef APBUARTPLUGIN_H
22 #ifndef APBUARTPLUGIN_H
23 #define APBUARTPLUGIN_H
23 #define APBUARTPLUGIN_H
24 #include <QMenuBar>
24 #include <QMenuBar>
25 #include <QMenu>
25 #include <QMenu>
26 #include <QAction>
26 #include <QAction>
27 #include <QLayout>
27 #include <QLayout>
28
28
29 #include <socexplorerplugin.h>
29 #include <socexplorerplugin.h>
30 #include <apbuartpluginui.h>
31 #include <QTimer>
30 #include <QTimer>
32 #include "apbuart_plugin_ui.h"
31 #include "apbuart_plugin_ui.h"
33
32 #include "uartpollingthread.h"
34 #define APB_UART_DATA_REG 0x0
33 #define APB_UART_DATA_REG 0x0
35 #define APB_UART_STATUS_REG 0x4
34 #define APB_UART_STATUS_REG 0x4
36 #define APB_UART_CONTROL_REG 0x8
35 #define APB_UART_CONTROL_REG 0x8
37 #define APB_UART_SCALE_REG 0xC
36 #define APB_UART_SCALE_REG 0xC
38 #define APB_UART_FIFO_DEBUG_REG 0x10
37 #define APB_UART_FIFO_DEBUG_REG 0x10
39
38
40
41 class ApbUartPlugin : public socexplorerplugin
39 class ApbUartPlugin : public socexplorerplugin
42 {
40 {
43 Q_OBJECT
41 Q_OBJECT
44 public:
42 public:
45 explicit ApbUartPlugin(QWidget *parent = 0);
43 explicit ApbUartPlugin(QWidget *parent = 0);
46 ~ApbUartPlugin();
44 ~ApbUartPlugin();
47 int VID(){return driver_VID;}
45 int VID(){return driver_VID;}
48 int PID(){return driver_PID;}
46 int PID(){return driver_PID;}
49
47
50 public slots:
48 public slots:
51 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
49 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
52 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
50 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
53 void closeMe();
51 void closeMe();
54 void postInstantiationTrigger();
52 void postInstantiationTrigger();
55 void loopbackChangeState( int state );
53 void loopbackChangeState( int state );
56 void uartReadout();
54 void uartReadout();
57 void activateScan(bool flag);
55 void activateScan(bool flag);
58 void activate(bool flag);
56 void activate(bool flag);
59 signals:
57 signals:
60 void apbUartTextReceived(QString text);
58 void apbUartTextReceived(QString text);
61 private:
59 private:
62 APBUART_Plugin_ui* UI;
60 APBUART_Plugin_ui* UI;
63 bool useLoopBack;
61 bool useLoopBack;
64 QTimer loopBackTimer;
62 QTimer loopBackTimer;
65 int enableLoopback();
63 int enableLoopback();
66 int disableLoopback();
64 int disableLoopback();
67 };
65 };
68
66
69 #endif // APBUARTPLUGIN_H
67 #endif // APBUARTPLUGIN_H
70
68
@@ -1,74 +1,72
1 #
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
3 #
4 #-------------------------------------------------
4 #-------------------------------------------------
5
5
6 CONFIG += socexplorerplugin
6 CONFIG += socexplorerplugin
7 win32:CONFIG += dll
7 win32:CONFIG += dll
8 win32:CONFIG -= static
8 win32:CONFIG -= static
9
9
10 CONFIG(debug, debug|release) {
10 CONFIG(debug, debug|release) {
11 DEBUG_EXT = _d
11 DEBUG_EXT = _d
12 } else {
12 } else {
13 DEBUG_EXT =
13 DEBUG_EXT =
14 }
14 }
15
15
16 TARGET = ApbUartPlugin$${DEBUG_EXT}
16 TARGET = ApbUartPlugin$${DEBUG_EXT}
17
17
18 DEFINES += PLUGIN=ApbUartPlugin
18 DEFINES += PLUGIN=ApbUartPlugin
19 DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\"
19 DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\"
20 DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\"
20 DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\"
21 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
21 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
22 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
22 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
23 DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\"
23 DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\"
24 DEFINES += driver_can_be_root=0
24 DEFINES += driver_can_be_root=0
25 DEFINES += driver_can_be_child=1
25 DEFINES += driver_can_be_child=1
26 DEFINES += driver_VID=1
26 DEFINES += driver_VID=1
27 DEFINES += driver_PID=0x0c
27 DEFINES += driver_PID=0x0c
28
28
29
29
30
30
31 INCLUDEPATH += \
31 INCLUDEPATH += \
32 $${PWD}
32 $${PWD}
33
33
34 HEADERS += \
34 HEADERS += \
35 APBUARTPLUGIN.h \
35 APBUARTPLUGIN.h \
36 apbuartpluginui.h \
37 apbuartcfg.h \
38 apbuartterminal.h \
36 apbuartterminal.h \
39 apbuart_plugin_ui.h
37 apbuart_plugin_ui.h \
38 uartpollingthread.h
40
39
41
40
42 SOURCES += \
41 SOURCES += \
43 APBUARTPLUGIN.cpp \
42 APBUARTPLUGIN.cpp \
44 apbuartpluginui.cpp \
45 apbuartcfg.cpp \
46 apbuartterminal.cpp \
43 apbuartterminal.cpp \
47 apbuart_plugin_ui.cpp
44 apbuart_plugin_ui.cpp \
45 uartpollingthread.cpp
48
46
49 FORMS += \
47 FORMS += \
50 apbuart_plugin_ui.ui
48 apbuart_plugin_ui.ui
51
49
52
50
53
51
54
52
55
53
56
54
57
55
58
56
59
57
60
58
61
59
62
60
63
61
64
62
65
63
66
64
67
65
68
66
69
67
70
68
71
69
72
70
73
71
74
72
@@ -1,133 +1,128
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
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
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
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
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef AHBUARTPLUGIN_H
22 #ifndef AHBUARTPLUGIN_H
23 #define AHBUARTPLUGIN_H
23 #define AHBUARTPLUGIN_H
24 #include <QMenuBar>
24 #include <QMenuBar>
25 #include <QMenu>
25 #include <QMenu>
26 #include <QAction>
26 #include <QAction>
27 #include <QLayout>
27 #include <QLayout>
28 #include <QMutex>
28 #include <QMutex>
29 #include <QProgressDialog>
29 #include <QProgressDialog>
30 #include <QStringListModel>
30 #include <QStringListModel>
31 #include <QTime>
31 #include <QTime>
32 #include <socexplorerplugin.h>
32 #include <socexplorerplugin.h>
33 #include "ahbuartpluginui.h"
33 #include "ahbuartpluginui.h"
34 #include <RS232.h>
34
35
35 #ifdef WinRs232
36 #include "librs232/RS232.h"
37 #else
38 #include <RS232.h>
39 #undef debug
40 #endif
41
36
42
37
43
38
44
39
45 #define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message)
40 #define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message)
46
41
47 #define APENDTABLETOLOG(table,size,Qstr,message) \
42 #define APENDTABLETOLOG(table,size,Qstr,message) \
48 Qstr.clear();\
43 Qstr.clear();\
49 Qstr+=message;\
44 Qstr+=message;\
50 for(int __i__tbllog__=0;(unsigned int)__i__tbllog__<size;__i__tbllog__++)\
45 for(int __i__tbllog__=0;(unsigned int)__i__tbllog__<size;__i__tbllog__++)\
51 {\
46 {\
52 if(__i__tbllog__%16==0) Qstr += "\n"; \
47 if(__i__tbllog__%16==0) Qstr += "\n"; \
53 Qstr += "0x" + QString::number((int)(0xff & table[__i__tbllog__]),16) +"\t";\
48 Qstr += "0x" + QString::number((int)(0xff & table[__i__tbllog__]),16) +"\t";\
54 }\
49 }\
55 APPENDTOLOG(Qstr);
50 APPENDTOLOG(Qstr);
56
51
57
52
58 #define SAFEWRITE(data,count,timer,timeout,error) \
53 #define SAFEWRITE(data,count,timer,timeout,error) \
59 while(1)\
54 while(1)\
60 {\
55 {\
61 unsigned int __writen__=0; \
56 unsigned int __writen__=0; \
62 (timer).restart(); \
57 (timer).restart(); \
63 while(__writen__!=(count)) \
58 while(__writen__!=(count)) \
64 {\
59 {\
65 __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
60 __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
66 if((timer).elapsed()>(timeout)) \
61 if((timer).elapsed()>(timeout)) \
67 {\
62 {\
68 APPENDTOLOG(QString("Timeout error while writing"));\
63 APPENDTOLOG(QString("Timeout error while writing"));\
69 this->port = (rs232port_t)NULL; \
64 this->port = (rs232port_t)NULL; \
70 this->Connected = false; \
65 this->Connected = false; \
71 emit this->activateSig(false); \
66 emit this->activateSig(false); \
72 error; \
67 error; \
73 } \
68 } \
74 } \
69 } \
75 break;\
70 break;\
76 }
71 }
77
72
78
73
79 #define SAFEREAD(data,count,timer,timeout,error) \
74 #define SAFEREAD(data,count,timer,timeout,error) \
80 unsigned int __read__=0; \
75 unsigned int __read__=0; \
81 (timer).restart(); \
76 (timer).restart(); \
82 while(__read__ != (count)) \
77 while(__read__ != (count)) \
83 { \
78 { \
84 __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \
79 __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \
85 if((timer).elapsed()>(timeout)) \
80 if((timer).elapsed()>(timeout)) \
86 { \
81 { \
87 APPENDTOLOG(QString("Timeout error while reading"));\
82 APPENDTOLOG(QString("Timeout error while reading"));\
88 this->Connected = false; \
83 this->Connected = false; \
89 emit this->activateSig(false); \
84 emit this->activateSig(false); \
90 this->portMutex->unlock(); \
85 this->portMutex->unlock(); \
91 error; \
86 error; \
92 } \
87 } \
93 } \
88 } \
94
89
95
90
96
91
97 class ahbuartplugin : public socexplorerplugin
92 class ahbuartplugin : public socexplorerplugin
98 {
93 {
99 Q_OBJECT
94 Q_OBJECT
100 public:
95 public:
101 ahbuartplugin(QWidget *parent = 0);
96 ahbuartplugin(QWidget *parent = 0);
102 ~ahbuartplugin();
97 ~ahbuartplugin();
103 int registermenu(QMainWindow *menuHolder);
98 int registermenu(QMainWindow *menuHolder);
104 int VID(){return driver_VID;}
99 int VID(){return driver_VID;}
105 int PID(){return driver_PID;}
100 int PID(){return driver_PID;}
106
101
107 public slots:
102 public slots:
108 void togglePort(QString PortName,int baudrate);
103 void togglePort(QString PortName,int baudrate);
109 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
104 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
110 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
105 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
111 void closeMe();
106 void closeMe();
112 void close();
107 void close();
113 bool open(QString PortName,int baudrate);
108 bool open(QString PortName,int baudrate);
114 void updatePortList();
109 void updatePortList();
115 QVariantList ReadBytes(unsigned int address,unsigned int count);
110 QVariantList ReadBytes(unsigned int address,unsigned int count);
116 void WriteBytes(unsigned int address,QList<QVariant> dataList);
111 void WriteBytes(unsigned int address,QList<QVariant> dataList);
117 signals:
112 signals:
118 void setProgressValue(int progress);
113 void setProgressValue(int progress);
119 private:
114 private:
120 bool scanDone;
115 bool scanDone;
121 QProgressDialog* progress;
116 QProgressDialog* progress;
122 QLayout * mainLayout;
117 QLayout * mainLayout;
123 ahbUartPluginUI* UI;
118 ahbUartPluginUI* UI;
124 QMutex* portMutex;
119 QMutex* portMutex;
125 rs232port_t port;
120 rs232port_t port;
126 QCompleter *portListcompleter;
121 QCompleter *portListcompleter;
127 QStringListModel *portListcompleterModel;
122 QStringListModel *portListcompleterModel;
128 void connectPort(QString PortName,int baudrate);
123 void connectPort(QString PortName,int baudrate);
129 bool checkConnection();
124 bool checkConnection();
130
125
131 };
126 };
132
127
133 #endif // AHBUARTPLUGIN_H
128 #endif // AHBUARTPLUGIN_H
@@ -1,80 +1,70
1 #
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
3 #
4 #-------------------------------------------------
4 #-------------------------------------------------
5
5
6 CONFIG += socexplorerplugin
6 CONFIG += socexplorerplugin
7 TEMPLATE = lib
7 TEMPLATE = lib
8 CONFIG += dll
8 CONFIG += dll
9 CONFIG -= static
9 CONFIG -= static
10 CONFIG(debug, debug|release) {
10 CONFIG(debug, debug|release) {
11 DEBUG_EXT = _d
11 DEBUG_EXT = _d
12 } else {
12 } else {
13 DEBUG_EXT =
13 DEBUG_EXT =
14 }
14 }
15 TARGET = ahbuartplugin$${DEBUG_EXT}
15 TARGET = ahbuartplugin$${DEBUG_EXT}
16 DEFINES += PLUGIN=ahbuartplugin
16 DEFINES += PLUGIN=ahbuartplugin
17 DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\"
17 DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\"
18 DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\"
18 DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\"
19 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
19 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
20 DEFINES += driver_Version="\"\\\"1.3.2"\\\"\"
20 DEFINES += driver_Version="\"\\\"1.3.2"\\\"\"
21 DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\"
21 DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\"
22 DEFINES += driver_can_be_root=1
22 DEFINES += driver_can_be_root=1
23 DEFINES += driver_can_be_child=0
23 DEFINES += driver_can_be_child=0
24 DEFINES += driver_VID=0
24 DEFINES += driver_VID=0
25 DEFINES += driver_PID=0
25 DEFINES += driver_PID=0
26
26
27
27
28
28
29 win32:LIBS += $${PWD}/librs232/bin/librs232-2.1.a
30 unix:LIBS += -lrs232-2.1
31
32
29
33 INCLUDEPATH += \
30 INCLUDEPATH += \
34 $${PWD}
31 $${PWD}
35
32
36
33
37 HEADERS += \
34 HEADERS += \
38 ahbuartplugin.h \
35 ahbuartplugin.h \
39 ahbuartpluginui.h \
36 ahbuartpluginui.h \
40 ahbuartpywrapper.h \
37 ahbuartpywrapper.h \
41 ahbuartpywrapper.h
38 ahbuartpywrapper.h
42
39
43
40
44
41
45 win32:HEADERS+=librs232/RS232.h
46 win32:INCLUDEPATH+=librs232
47
48 SOURCES += \
42 SOURCES += \
49 ahbuartplugin.cpp \
43 ahbuartplugin.cpp \
50 ahbuartpluginui.cpp \
44 ahbuartpluginui.cpp \
51 ahbuartpywrapper.cpp
45 ahbuartpywrapper.cpp
52
46
53
54 OTHER_FILES += \
55 librs232/bin/librs232-1.0-1.dll
56
57 FORMS += \
47 FORMS += \
58 ahbuartpluginui.ui
48 ahbuartpluginui.ui
59
49
60
50
61
51
62
52
63
53
64
54
65
55
66
56
67
57
68
58
69
59
70
60
71
61
72
62
73
63
74
64
75
65
76
66
77
67
78
68
79
69
80
70
@@ -1,202 +1,223
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@member.fsf.org
21 ----------------------------------------------------------------------------*/
1 #include "gr_esb_bridge.h"
22 #include "gr_esb_bridge.h"
2 #include "gr_esb_ui.h"
23 #include "gr_esb_ui.h"
3 #include <unistd.h>
24 #include <unistd.h>
4 #include "spw.h"
25 #include "spw.h"
5 #include <socexplorerengine.h>
26 #include <socexplorerengine.h>
6
27
7 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
28 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
8 abstractSpwBridge(parent)
29 abstractSpwBridge(parent)
9 {
30 {
10 this->p_GUI = new GR_ESB_ui();
31 this->p_GUI = new GR_ESB_ui();
11 this->manager = new GR_ESB_Manager(parent,this);
32 this->manager = new GR_ESB_Manager(parent,this);
12
33
13 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString)));
34 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString)));
14 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setVirtualLink(QString)));
35 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setVirtualLink(QString)));
15 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
36 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
16 this->manager->virtualLinkIndex = 0;
37 this->manager->virtualLinkIndex = 0;
17 this->manager->start();
38 this->manager->start();
18 }
39 }
19
40
20 GR_ESB_bridge::~GR_ESB_bridge()
41 GR_ESB_bridge::~GR_ESB_bridge()
21 {
42 {
22 }
43 }
23
44
24 void GR_ESB_bridge::toggleBridgeConnection()
45 void GR_ESB_bridge::toggleBridgeConnection()
25 {
46 {
26 if(this->plugin->isConnected())
47 if(this->plugin->isConnected())
27 {
48 {
28 this->disconnectBridge();
49 this->disconnectBridge();
29 }
50 }
30 else
51 else
31 {
52 {
32 this->connectBridge();
53 this->connectBridge();
33 }
54 }
34 }
55 }
35
56
36 bool GR_ESB_bridge::connectBridge()
57 bool GR_ESB_bridge::connectBridge()
37 {
58 {
38 if(this->manager->connectBridge())
59 if(this->manager->connectBridge())
39 {
60 {
40 ((GR_ESB_ui*)this->p_GUI)->lock(true);
61 ((GR_ESB_ui*)this->p_GUI)->lock(true);
41 emit setConnected(true);
62 emit setConnected(true);
42 return true;
63 return true;
43 }
64 }
44 return false;
65 return false;
45 }
66 }
46
67
47 bool GR_ESB_bridge::disconnectBridge()
68 bool GR_ESB_bridge::disconnectBridge()
48 {
69 {
49 if(this->manager->disconnectBridge())
70 if(this->manager->disconnectBridge())
50 {
71 {
51 ((GR_ESB_ui*)this->p_GUI)->lock(false);
72 ((GR_ESB_ui*)this->p_GUI)->lock(false);
52 emit setConnected(false);
73 emit setConnected(false);
53 return true;
74 return true;
54 }
75 }
55 return false;
76 return false;
56 }
77 }
57
78
58 void GR_ESB_bridge::setIP(QString ip)
79 void GR_ESB_bridge::setIP(QString ip)
59 {
80 {
60 this->manager->IP = ip;
81 this->manager->IP = ip;
61 }
82 }
62
83
63 void GR_ESB_bridge::setVirtualLink(QString vlink)
84 void GR_ESB_bridge::setVirtualLink(QString vlink)
64 {
85 {
65 vlink = vlink.section("Virtual link",0,0);
86 vlink = vlink.section("Virtual link",0,0);
66 bool success;
87 bool success;
67 int vlinkTmp = vlink.toInt(&success);
88 int vlinkTmp = vlink.toInt(&success);
68 if(success)
89 if(success)
69 {
90 {
70 setVirtualLink(vlinkTmp);
91 setVirtualLink(vlinkTmp);
71 }
92 }
72 }
93 }
73
94
74 void GR_ESB_bridge::setVirtualLink(qint32 vlink)
95 void GR_ESB_bridge::setVirtualLink(qint32 vlink)
75 {
96 {
76 if(vlink<6 && vlink>=0)
97 if(vlink<6 && vlink>=0)
77 {
98 {
78 this->manager->virtualLinkIndex = vlink;
99 this->manager->virtualLinkIndex = vlink;
79 }
100 }
80 }
101 }
81
102
82
103
83 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
104 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
84 {
105 {
85
106
86 }
107 }
87
108
88 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
109 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
89 {
110 {
90
111
91 }
112 }
92
113
93 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
114 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
94 {
115 {
95 return this->manager->sendPacket(packet,size);
116 return this->manager->sendPacket(packet,size);
96 }
117 }
97
118
98
119
99 GR_ESB_Manager::GR_ESB_Manager(socexplorerplugin *plugin, QObject *parent)
120 GR_ESB_Manager::GR_ESB_Manager(socexplorerplugin *plugin, QObject *parent)
100 :QThread((QObject*)parent)
121 :QThread((QObject*)parent)
101 {
122 {
102 this->Read_soc = new QTcpSocket(this);
123 this->Read_soc = new QTcpSocket(this);
103 this->Write_soc = new QTcpSocket(this);
124 this->Write_soc = new QTcpSocket(this);
104 this->RMAPtimeout = 2000;
125 this->RMAPtimeout = 2000;
105 this->handleMutex = new QMutex(QMutex::NonRecursive);
126 this->handleMutex = new QMutex(QMutex::NonRecursive);
106 this->RMAP_AnswersSem = new QSemaphore(0);
127 this->RMAP_AnswersSem = new QSemaphore(0);
107 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
128 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
108 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
129 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
109 this->plugin = plugin;
130 this->plugin = plugin;
110 connected = false;
131 connected = false;
111 this->moveToThread(this);
132 this->moveToThread(this);
112 }
133 }
113
134
114 GR_ESB_Manager::~GR_ESB_Manager()
135 GR_ESB_Manager::~GR_ESB_Manager()
115 {
136 {
116
137
117 }
138 }
118
139
119 void GR_ESB_Manager::run()
140 void GR_ESB_Manager::run()
120 {
141 {
121 SocExplorerEngine::message(this->plugin,"Starting GRESB pooling thread",1);
142 SocExplorerEngine::message(this->plugin,"Starting GRESB pooling thread",1);
122 while (!this->isInterruptionRequested())
143 while (!this->isInterruptionRequested())
123 {
144 {
124 if(this->connected)
145 if(this->connected)
125 {
146 {
126 handleMutex->lock();
147 handleMutex->lock();
127 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
148 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
128
149
129 }
150 }
130 else
151 else
131 {
152 {
132 //do some sanity checks!
153 //do some sanity checks!
133
154
134 usleep(RMAPtimeout/2);
155 usleep(RMAPtimeout/2);
135 }
156 }
136 usleep(1000);
157 usleep(1000);
137 }
158 }
138 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
159 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
139 }
160 }
140
161
141 bool GR_ESB_Manager::connectBridge()
162 bool GR_ESB_Manager::connectBridge()
142 {
163 {
143 int timeout=60;
164 int timeout=60;
144 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
165 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
145 {
166 {
146 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
167 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
147 this->Read_soc->waitForConnected(30000);
168 this->Read_soc->waitForConnected(30000);
148 }
169 }
149 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
170 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
150 {
171 {
151 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
172 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
152 this->Write_soc->waitForConnected(30000);
173 this->Write_soc->waitForConnected(30000);
153 }
174 }
154 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
175 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
155 {
176 {
156 usleep(100000);
177 usleep(100000);
157 if(timeout--==0)return false;
178 if(timeout--==0)return false;
158 }
179 }
159 return true;
180 return true;
160
181
161 }
182 }
162
183
163 bool GR_ESB_Manager::disconnectBridge()
184 bool GR_ESB_Manager::disconnectBridge()
164 {
185 {
165 int timeout=60;
186 int timeout=60;
166 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
187 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
167 {
188 {
168 this->Read_soc->disconnectFromHost();
189 this->Read_soc->disconnectFromHost();
169 this->Read_soc->waitForDisconnected(30000);
190 this->Read_soc->waitForDisconnected(30000);
170 }
191 }
171 if(this->Write_soc->state()!=QTcpSocket::UnconnectedState)
192 if(this->Write_soc->state()!=QTcpSocket::UnconnectedState)
172 {
193 {
173 this->Write_soc->disconnectFromHost();
194 this->Write_soc->disconnectFromHost();
174 this->Write_soc->waitForDisconnected(30000);
195 this->Write_soc->waitForDisconnected(30000);
175 }
196 }
176 while((this->Read_soc->state()!=QTcpSocket::UnconnectedState) && (this->Write_soc->state()!=QTcpSocket::UnconnectedState))
197 while((this->Read_soc->state()!=QTcpSocket::UnconnectedState) && (this->Write_soc->state()!=QTcpSocket::UnconnectedState))
177 {
198 {
178 usleep(100000);
199 usleep(100000);
179 if(timeout--==0)return false;
200 if(timeout--==0)return false;
180 }
201 }
181 return true;
202 return true;
182 }
203 }
183
204
184 int GR_ESB_Manager::getRMAPtransactionID()
205 int GR_ESB_Manager::getRMAPtransactionID()
185 {
206 {
186
207
187 }
208 }
188
209
189 int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer)
210 int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer)
190 {
211 {
191
212
192 }
213 }
193
214
194 bool GR_ESB_Manager::sendPacket(char *packet, int size)
215 bool GR_ESB_Manager::sendPacket(char *packet, int size)
195 {
216 {
196
217
197 }
218 }
198
219
199 void GR_ESB_Manager::pushRmapPacket(char *packet, int len)
220 void GR_ESB_Manager::pushRmapPacket(char *packet, int len)
200 {
221 {
201
222
202 }
223 }
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now