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