@@ -1,199 +1,102 | |||||
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 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 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 | #include "APBUARTPLUGIN.h" |
|
22 | #include "APBUARTPLUGIN.h" | |
23 | #include <socexplorerengine.h> |
|
23 | #include <socexplorerengine.h> | |
24 |
|
24 | |||
25 | ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent) |
|
25 | ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent) | |
26 | { |
|
26 | { | |
|
27 | this->setBaseAddress(-1); | |||
27 | this->UI = new APBUART_Plugin_ui(); |
|
28 | this->UI = new APBUART_Plugin_ui(); | |
28 | this->setWidget((QWidget*)this->UI); |
|
29 | this->setWidget((QWidget*)this->UI); | |
29 |
this->u |
|
30 | this->uartConnected = false; | |
|
31 | this->UartThread = new UARTPollingThread(this); | |||
30 | connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int))); |
|
32 | connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int))); | |
31 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); |
|
33 | connect(this->UartThread,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); | |
32 |
connect( |
|
34 | connect(this->UI,SIGNAL(connectPort()),this,SLOT(toggleUartState())); | |
|
35 | connect(this->UI,SIGNAL(sendChar(char)),this->UartThread,SLOT(sendChar(char))); | |||
|
36 | connect(this->UI,SIGNAL(PortNameChanged(QString)),this->UartThread,SLOT(setPortName(QString))); | |||
|
37 | connect(this->UI,SIGNAL(UartSpeedChanged(QString)),this->UartThread,SLOT(setPortSpeedStr(QString))); | |||
|
38 | this->UartThread->start(); | |||
33 | } |
|
39 | } | |
34 |
|
40 | |||
35 |
|
41 | |||
36 | ApbUartPlugin::~ApbUartPlugin() |
|
42 | ApbUartPlugin::~ApbUartPlugin() | |
37 | { |
|
43 | { | |
38 |
|
44 | |||
39 | } |
|
45 | } | |
40 |
|
46 | |||
41 | void ApbUartPlugin::closeMe() |
|
47 | void ApbUartPlugin::closeMe() | |
42 | { |
|
48 | { | |
43 | emit this->closePlugin(this); |
|
49 | emit this->closePlugin(this); | |
44 | } |
|
50 | } | |
45 |
|
51 | |||
46 |
void ApbUartPlugin:: |
|
52 | void ApbUartPlugin::toggleUartState() | |
47 | { |
|
53 | { | |
48 | if(this->isEnabled()) |
|
54 | if(!uartConnected) | |
49 | { |
|
55 | { | |
50 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); |
|
56 | uartConnected = this->UartThread->openUart(); | |
51 | loopbackChangeState(Qt::Checked); |
|
|||
52 | } |
|
57 | } | |
|
58 | else | |||
|
59 | { | |||
|
60 | this->UartThread->closeUart(); | |||
|
61 | this->uartConnected = false; | |||
|
62 | } | |||
|
63 | this->UI->setUartConnected(uartConnected); | |||
53 | } |
|
64 | } | |
54 |
|
65 | |||
55 | void ApbUartPlugin::loopbackChangeState(int state) |
|
66 | void ApbUartPlugin::loopbackChangeState(int state) | |
56 | { |
|
67 | { | |
57 | if(state==Qt::Checked) |
|
68 | if(state==Qt::Checked) | |
58 | { |
|
69 | { | |
59 |
|
|
70 | this->UI->setEnableForLoopBack(false); | |
|
71 | this->UartThread->setFifoDebugEable(true); | |||
60 | } |
|
72 | } | |
61 | else |
|
73 | else | |
62 | { |
|
74 | { | |
63 |
|
|
75 | this->UI->setEnableForLoopBack(true); | |
64 | } |
|
76 | this->UartThread->setFifoDebugEable(false); | |
65 | } |
|
|||
66 |
|
||||
67 | void ApbUartPlugin::uartReadout() |
|
|||
68 | { |
|
|||
69 | #ifdef WIN32 |
|
|||
70 | int readcnt=0; |
|
|||
71 | #endif |
|
|||
72 | if(this->isEnabled() && parent!=NULL) |
|
|||
73 | { |
|
|||
74 | if(this->useLoopBack) |
|
|||
75 | { |
|
|||
76 | if(this->baseAddress()!=-1) |
|
|||
77 | { |
|
|||
78 | this->loopBackTimer.stop(); |
|
|||
79 | unsigned int status_reg,data; |
|
|||
80 | char ch; |
|
|||
81 | QString printdata=""; |
|
|||
82 | parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); |
|
|||
83 | while ((status_reg&4)==0) { |
|
|||
84 | parent->Read(&data,1,this->baseAddress()+APB_UART_FIFO_DEBUG_REG); |
|
|||
85 | ch = (char)(0xff & data); |
|
|||
86 | printdata+=ch; |
|
|||
87 | #ifdef WIN32 |
|
|||
88 | readcnt++; |
|
|||
89 | if(readcnt>=32) |
|
|||
90 | { |
|
|||
91 | qApp->processEvents(); |
|
|||
92 | break; |
|
|||
93 | } |
|
|||
94 | #endif |
|
|||
95 | parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); |
|
|||
96 | } |
|
|||
97 | if(printdata!="") |
|
|||
98 | emit apbUartTextReceived(printdata); |
|
|||
99 | this->loopBackTimer.start(200); |
|
|||
100 | } |
|
|||
101 | else |
|
|||
102 | { |
|
|||
103 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); |
|
|||
104 | this->enableLoopback(); |
|
|||
105 | } |
|
|||
106 | } |
|
|||
107 | } |
|
|||
108 | } |
|
|||
109 |
|
||||
110 | void ApbUartPlugin::activate(bool flag) |
|
|||
111 | { |
|
|||
112 | this->setEnabled(flag); |
|
|||
113 | emit this->activateSig(flag); |
|
|||
114 | if(this->isEnabled()) |
|
|||
115 | {this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); |
|
|||
116 |
|
||||
117 | loopbackChangeState(Qt::Checked); |
|
|||
118 | } |
|
77 | } | |
119 | } |
|
78 | } | |
120 |
|
79 | |||
121 | void ApbUartPlugin::activateScan(bool flag) |
|
|||
122 | { |
|
|||
123 | if(flag) |
|
|||
124 | this->loopBackTimer.start(200); |
|
|||
125 | else |
|
|||
126 | this->loopBackTimer.stop(); |
|
|||
127 | } |
|
|||
128 |
|
||||
129 | int ApbUartPlugin::enableLoopback() |
|
|||
130 | { |
|
|||
131 |
|
||||
132 | this->useLoopBack = true; |
|
|||
133 | this->loopBackTimer.start(200); |
|
|||
134 | SocExplorerEngine::message(this,"Set FiFo debug mode mode"); |
|
|||
135 | if(parent==NULL) |
|
|||
136 | { |
|
|||
137 | SocExplorerEngine::message(this,"Can't set FiFo debug mode no parent driver accessible"); |
|
|||
138 | return -1; |
|
|||
139 | } |
|
|||
140 | if(this->baseAddress()==-1) |
|
|||
141 | { |
|
|||
142 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); |
|
|||
143 | if(this->baseAddress()==-1) |
|
|||
144 | return -1; |
|
|||
145 | } |
|
|||
146 | unsigned int ctrl_reg= 0x843; |
|
|||
147 | parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); |
|
|||
148 | this->UI->setEnableForLoopBack(false); |
|
|||
149 | return 0; |
|
|||
150 | } |
|
|||
151 |
|
||||
152 | int ApbUartPlugin::disableLoopback() |
|
|||
153 | { |
|
|||
154 | SocExplorerEngine::message(this,"Disable FiFo debug mode mode"); |
|
|||
155 | if(parent==NULL) |
|
|||
156 | { |
|
|||
157 | SocExplorerEngine::message(this,"Can't disable FiFo debug mode no parent driver accessible"); |
|
|||
158 | return -1; |
|
|||
159 | } |
|
|||
160 | if(this->baseAddress()==-1) |
|
|||
161 | { |
|
|||
162 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); |
|
|||
163 | if(this->baseAddress()==-1) |
|
|||
164 | return -1; |
|
|||
165 | } |
|
|||
166 | unsigned int ctrl_reg; |
|
|||
167 | this->loopBackTimer.stop(); |
|
|||
168 | /* Firts get Control reg value*/ |
|
|||
169 | parent->Read(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); |
|
|||
170 | ctrl_reg = ctrl_reg & (~(1<<11)); |
|
|||
171 | parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); |
|
|||
172 | this->useLoopBack = false; |
|
|||
173 | this->UI->setEnableForLoopBack(true); |
|
|||
174 | return 0; |
|
|||
175 | } |
|
|||
176 |
|
||||
177 |
|
80 | |||
178 | unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
81 | unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
179 | { |
|
82 | { | |
180 | if(parent!=NULL) |
|
83 | if(parent!=NULL) | |
181 | return parent->Read(Value,count,address); |
|
84 | return parent->Read(Value,count,address); | |
182 | return 0; |
|
85 | return 0; | |
183 | } |
|
86 | } | |
184 |
|
87 | |||
185 |
|
88 | |||
186 | unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
89 | unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
187 | { |
|
90 | { | |
188 | if(parent!=NULL) |
|
91 | if(parent!=NULL) | |
189 | return parent->Write(Value,count,address); |
|
92 | return parent->Write(Value,count,address); | |
190 | return 0; |
|
93 | return 0; | |
191 | } |
|
94 | } | |
192 |
|
95 | |||
193 |
|
96 | |||
194 |
|
97 | |||
195 |
|
98 | |||
196 |
|
99 | |||
197 |
|
100 | |||
198 |
|
101 | |||
199 |
|
102 |
@@ -1,68 +1,65 | |||||
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 <QTimer> |
|
30 | #include <QTimer> | |
31 | #include "apbuart_plugin_ui.h" |
|
31 | #include "apbuart_plugin_ui.h" | |
32 | #include "uartpollingthread.h" |
|
32 | #include "uartpollingthread.h" | |
33 | #define APB_UART_DATA_REG 0x0 |
|
33 | #define APB_UART_DATA_REG 0x0 | |
34 | #define APB_UART_STATUS_REG 0x4 |
|
34 | #define APB_UART_STATUS_REG 0x4 | |
35 | #define APB_UART_CONTROL_REG 0x8 |
|
35 | #define APB_UART_CONTROL_REG 0x8 | |
36 | #define APB_UART_SCALE_REG 0xC |
|
36 | #define APB_UART_SCALE_REG 0xC | |
37 | #define APB_UART_FIFO_DEBUG_REG 0x10 |
|
37 | #define APB_UART_FIFO_DEBUG_REG 0x10 | |
38 |
|
38 | |||
39 | class ApbUartPlugin : public socexplorerplugin |
|
39 | class ApbUartPlugin : public socexplorerplugin | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | explicit ApbUartPlugin(QWidget *parent = 0); |
|
43 | explicit ApbUartPlugin(QWidget *parent = 0); | |
44 | ~ApbUartPlugin(); |
|
44 | ~ApbUartPlugin(); | |
45 | int VID(){return driver_VID;} |
|
45 | int VID(){return driver_VID;} | |
46 | int PID(){return driver_PID;} |
|
46 | int PID(){return driver_PID;} | |
47 |
|
47 | |||
48 | public slots: |
|
48 | public slots: | |
49 | 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); | |
50 | 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); | |
|
51 | void loopbackChangeState(int state); | |||
51 | void closeMe(); |
|
52 | void closeMe(); | |
52 | void postInstantiationTrigger(); |
|
53 | void toggleUartState(); | |
53 | void loopbackChangeState( int state ); |
|
|||
54 | void uartReadout(); |
|
|||
55 | void activateScan(bool flag); |
|
|||
56 | void activate(bool flag); |
|
|||
57 | signals: |
|
54 | signals: | |
58 | void apbUartTextReceived(QString text); |
|
55 | ||
59 | private: |
|
56 | private: | |
60 | APBUART_Plugin_ui* UI; |
|
57 | APBUART_Plugin_ui* UI; | |
61 | bool useLoopBack; |
|
58 | bool uartConnected; | |
62 | QTimer loopBackTimer; |
|
59 | UARTPollingThread* UartThread; | |
63 | int enableLoopback(); |
|
60 | int enableLoopback(); | |
64 | int disableLoopback(); |
|
61 | int disableLoopback(); | |
65 | }; |
|
62 | }; | |
66 |
|
63 | |||
67 | #endif // APBUARTPLUGIN_H |
|
64 | #endif // APBUARTPLUGIN_H | |
68 |
|
65 |
@@ -1,44 +1,64 | |||||
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) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, 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 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 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 | #include "apbuart_plugin_ui.h" |
|
22 | #include "apbuart_plugin_ui.h" | |
23 | #include "ui_apbuart_plugin_ui.h" |
|
23 | #include "ui_apbuart_plugin_ui.h" | |
|
24 | #include "apbuartterminal.h" | |||
24 |
|
25 | |||
25 | APBUART_Plugin_ui::APBUART_Plugin_ui(QWidget *parent) : |
|
26 | APBUART_Plugin_ui::APBUART_Plugin_ui(QWidget *parent) : | |
26 | QWidget(parent), |
|
27 | QWidget(parent), | |
27 | ui(new Ui::APBUART_Plugin_ui) |
|
28 | ui(new Ui::APBUART_Plugin_ui) | |
28 | { |
|
29 | { | |
29 | ui->setupUi(this); |
|
30 | ui->setupUi(this); | |
30 | connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); |
|
31 | connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); | |
31 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(append(QString))); |
|
32 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(append(QString))); | |
|
33 | connect(this->ui->ConnectQpb,SIGNAL(clicked()),this,SIGNAL(connectPort())); | |||
|
34 | connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char))); | |||
|
35 | connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString))); | |||
|
36 | connect(this->ui->UartSpeedLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(UartSpeedChanged(QString))); | |||
32 | } |
|
37 | } | |
33 |
|
38 | |||
34 | APBUART_Plugin_ui::~APBUART_Plugin_ui() |
|
39 | APBUART_Plugin_ui::~APBUART_Plugin_ui() | |
35 | { |
|
40 | { | |
36 | delete ui; |
|
41 | delete ui; | |
37 | } |
|
42 | } | |
38 |
|
43 | |||
39 | void APBUART_Plugin_ui::setEnableForLoopBack(bool enable) |
|
44 | void APBUART_Plugin_ui::setEnableForLoopBack(bool enable) | |
40 | { |
|
45 | { | |
41 | this->ui->PortNameLineEdit->setEnabled(enable); |
|
46 | this->ui->PortNameLineEdit->setEnabled(enable); | |
42 | this->ui->ConnectQpb->setEnabled(enable); |
|
47 | this->ui->ConnectQpb->setEnabled(enable); | |
43 | this->ui->UartSpeedLineEdit->setEnabled(enable); |
|
48 | this->ui->UartSpeedLineEdit->setEnabled(enable); | |
44 | } |
|
49 | } | |
|
50 | ||||
|
51 | void APBUART_Plugin_ui::setUartConnected(bool enable) | |||
|
52 | { | |||
|
53 | this->ui->PortNameLineEdit->setDisabled(enable); | |||
|
54 | this->ui->UartSpeedLineEdit->setDisabled(enable); | |||
|
55 | this->ui->FIFODebugChkBx->setDisabled(enable); | |||
|
56 | if(enable) | |||
|
57 | { | |||
|
58 | this->ui->ConnectQpb->setText("Close Port"); | |||
|
59 | } | |||
|
60 | else | |||
|
61 | { | |||
|
62 | this->ui->ConnectQpb->setText("Open Port"); | |||
|
63 | } | |||
|
64 | } |
@@ -1,49 +1,53 | |||||
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) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, 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 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 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 APBUART_PLUGIN_UI_H |
|
22 | #ifndef APBUART_PLUGIN_UI_H | |
23 | #define APBUART_PLUGIN_UI_H |
|
23 | #define APBUART_PLUGIN_UI_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 |
|
26 | |||
27 | namespace Ui { |
|
27 | namespace Ui { | |
28 | class APBUART_Plugin_ui; |
|
28 | class APBUART_Plugin_ui; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | class APBUART_Plugin_ui : public QWidget |
|
31 | class APBUART_Plugin_ui : public QWidget | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public: |
|
35 | public: | |
36 | explicit APBUART_Plugin_ui(QWidget *parent = 0); |
|
36 | explicit APBUART_Plugin_ui(QWidget *parent = 0); | |
37 | ~APBUART_Plugin_ui(); |
|
37 | ~APBUART_Plugin_ui(); | |
38 |
|
38 | |||
39 | public slots: |
|
39 | public slots: | |
40 | void setEnableForLoopBack(bool enable); |
|
40 | void setEnableForLoopBack(bool enable); | |
|
41 | void setUartConnected(bool enable); | |||
41 | signals: |
|
42 | signals: | |
42 | void loopbackChkBxStateChanged( int state ); |
|
43 | void loopbackChkBxStateChanged( int state ); | |
43 | void apbUartTextReceived(QString text); |
|
44 | void apbUartTextReceived(QString text); | |
44 |
|
45 | void connectPort(); | ||
|
46 | void sendChar(char c); | |||
|
47 | void UartSpeedChanged(QString text); | |||
|
48 | void PortNameChanged(QString text); | |||
45 | private: |
|
49 | private: | |
46 | Ui::APBUART_Plugin_ui *ui; |
|
50 | Ui::APBUART_Plugin_ui *ui; | |
47 | }; |
|
51 | }; | |
48 |
|
52 | |||
49 | #endif // APBUART_PLUGIN_UI_H |
|
53 | #endif // APBUART_PLUGIN_UI_H |
@@ -1,82 +1,89 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>APBUART_Plugin_ui</class> |
|
3 | <class>APBUART_Plugin_ui</class> | |
4 | <widget class="QWidget" name="APBUART_Plugin_ui"> |
|
4 | <widget class="QWidget" name="APBUART_Plugin_ui"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>400</width> |
|
9 | <width>400</width> | |
10 | <height>300</height> |
|
10 | <height>300</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="QVBoxLayout" name="verticalLayout"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <item> |
|
17 | <item> | |
18 | <widget class="QTabWidget" name="TabWidget"> |
|
18 | <widget class="QTabWidget" name="TabWidget"> | |
19 | <property name="currentIndex"> |
|
19 | <property name="currentIndex"> | |
20 |
<number> |
|
20 | <number>1</number> | |
21 | </property> |
|
21 | </property> | |
22 | <widget class="QWidget" name="Config"> |
|
22 | <widget class="QWidget" name="Config"> | |
23 | <attribute name="title"> |
|
23 | <attribute name="title"> | |
24 | <string>Configuration</string> |
|
24 | <string>Configuration</string> | |
25 | </attribute> |
|
25 | </attribute> | |
26 | <layout class="QGridLayout" name="gridLayout"> |
|
26 | <layout class="QGridLayout" name="gridLayout"> | |
27 | <item row="1" column="1"> |
|
27 | <item row="1" column="1"> | |
28 | <widget class="QLineEdit" name="PortNameLineEdit"/> |
|
28 | <widget class="QLineEdit" name="PortNameLineEdit"/> | |
29 | </item> |
|
29 | </item> | |
30 | <item row="0" column="0" colspan="2"> |
|
30 | <item row="0" column="0" colspan="2"> | |
31 | <widget class="QCheckBox" name="FIFODebugChkBx"> |
|
31 | <widget class="QCheckBox" name="FIFODebugChkBx"> | |
32 | <property name="text"> |
|
32 | <property name="text"> | |
33 | <string>Enable FIFO debug mode</string> |
|
33 | <string>Enable FIFO debug mode</string> | |
34 | </property> |
|
34 | </property> | |
35 | <property name="checked"> |
|
35 | <property name="checked"> | |
36 | <bool>true</bool> |
|
36 | <bool>true</bool> | |
37 | </property> |
|
37 | </property> | |
38 | </widget> |
|
38 | </widget> | |
39 | </item> |
|
39 | </item> | |
40 | <item row="1" column="0"> |
|
40 | <item row="1" column="0"> | |
41 | <widget class="QLabel" name="PortNameLbl"> |
|
41 | <widget class="QLabel" name="PortNameLbl"> | |
42 | <property name="text"> |
|
42 | <property name="text"> | |
43 | <string>Port Name</string> |
|
43 | <string>Port Name</string> | |
44 | </property> |
|
44 | </property> | |
45 | </widget> |
|
45 | </widget> | |
46 | </item> |
|
46 | </item> | |
47 | <item row="3" column="0"> |
|
47 | <item row="3" column="0"> | |
48 | <widget class="QLabel" name="UartSpeedLbl"> |
|
48 | <widget class="QLabel" name="UartSpeedLbl"> | |
49 | <property name="text"> |
|
49 | <property name="text"> | |
50 | <string>Uart Speed</string> |
|
50 | <string>Uart Speed</string> | |
51 | </property> |
|
51 | </property> | |
52 | </widget> |
|
52 | </widget> | |
53 | </item> |
|
53 | </item> | |
54 | <item row="4" column="1"> |
|
54 | <item row="4" column="1"> | |
55 | <widget class="QPushButton" name="ConnectQpb"> |
|
55 | <widget class="QPushButton" name="ConnectQpb"> | |
56 | <property name="text"> |
|
56 | <property name="text"> | |
57 | <string>Open Port</string> |
|
57 | <string>Open Port</string> | |
58 | </property> |
|
58 | </property> | |
59 | </widget> |
|
59 | </widget> | |
60 | </item> |
|
60 | </item> | |
61 | <item row="3" column="1"> |
|
61 | <item row="3" column="1"> | |
62 | <widget class="QLineEdit" name="UartSpeedLineEdit"/> |
|
62 | <widget class="QLineEdit" name="UartSpeedLineEdit"/> | |
63 | </item> |
|
63 | </item> | |
64 | </layout> |
|
64 | </layout> | |
65 | </widget> |
|
65 | </widget> | |
66 | <widget class="QWidget" name="Terminal"> |
|
66 | <widget class="QWidget" name="Terminal"> | |
67 | <attribute name="title"> |
|
67 | <attribute name="title"> | |
68 | <string>Terminal</string> |
|
68 | <string>Terminal</string> | |
69 | </attribute> |
|
69 | </attribute> | |
70 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
70 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
71 | <item> |
|
71 | <item> | |
72 |
<widget class=" |
|
72 | <widget class="ApbUartTerminal" name="UART_TERM"/> | |
73 | </item> |
|
73 | </item> | |
74 | </layout> |
|
74 | </layout> | |
75 | </widget> |
|
75 | </widget> | |
76 | </widget> |
|
76 | </widget> | |
77 | </item> |
|
77 | </item> | |
78 | </layout> |
|
78 | </layout> | |
79 | </widget> |
|
79 | </widget> | |
|
80 | <customwidgets> | |||
|
81 | <customwidget> | |||
|
82 | <class>ApbUartTerminal</class> | |||
|
83 | <extends>QTextEdit</extends> | |||
|
84 | <header>apbuartterminal.h</header> | |||
|
85 | </customwidget> | |||
|
86 | </customwidgets> | |||
80 | <resources/> |
|
87 | <resources/> | |
81 | <connections/> |
|
88 | <connections/> | |
82 | </ui> |
|
89 | </ui> |
@@ -1,28 +1,35 | |||||
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 | #include "apbuartterminal.h" |
|
22 | #include "apbuartterminal.h" | |
23 |
|
23 | |||
24 | ApbUartTerminal::ApbUartTerminal(QWidget *parent) : |
|
24 | ApbUartTerminal::ApbUartTerminal(QWidget *parent) : | |
25 | QTextEdit(parent) |
|
25 | QTextEdit(parent) | |
26 | { |
|
26 | { | |
27 | connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString))); |
|
27 | connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString))); | |
|
28 | setReadOnly(true); | |||
28 | } |
|
29 | } | |
|
30 | ||||
|
31 | void ApbUartTerminal::keyPressEvent(QKeyEvent *e) | |||
|
32 | { | |||
|
33 | emit this->sendChar((char)e->key()); | |||
|
34 | e->accept(); | |||
|
35 | } |
@@ -1,41 +1,45 | |||||
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 APBUARTTERMINAL_H |
|
22 | #ifndef APBUARTTERMINAL_H | |
23 | #define APBUARTTERMINAL_H |
|
23 | #define APBUARTTERMINAL_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <QTextEdit> |
|
26 | #include <QTextEdit> | |
27 |
|
27 | #include <QKeyEvent> | ||
28 |
|
28 | |||
29 | class ApbUartTerminal : public QTextEdit |
|
29 | class ApbUartTerminal : public QTextEdit | |
30 | { |
|
30 | { | |
31 | Q_OBJECT |
|
31 | Q_OBJECT | |
32 | public: |
|
32 | public: | |
33 | explicit ApbUartTerminal(QWidget *parent = 0); |
|
33 | explicit ApbUartTerminal(QWidget *parent = 0); | |
34 |
|
34 | |||
|
35 | protected: | |||
|
36 | void keyPressEvent(QKeyEvent * e); | |||
|
37 | ||||
35 | signals: |
|
38 | signals: | |
36 | void apbUartTextReceived(QString text); |
|
39 | void apbUartTextReceived(QString text); | |
|
40 | void sendChar(char c); | |||
37 | public slots: |
|
41 | public slots: | |
38 |
|
42 | |||
39 | }; |
|
43 | }; | |
40 |
|
44 | |||
41 | #endif // APBUARTTERMINAL_H |
|
45 | #endif // APBUARTTERMINAL_H |
@@ -1,70 +1,185 | |||||
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) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, 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 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 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 | #include "uartpollingthread.h" |
|
22 | #include "uartpollingthread.h" | |
23 | #include <RS232.h> |
|
|||
24 | #include <socexplorerengine.h> |
|
23 | #include <socexplorerengine.h> | |
25 |
|
24 | |||
26 | UARTPollingThread::UARTPollingThread(socexplorerplugin *parent) : |
|
25 | UARTPollingThread::UARTPollingThread(socexplorerplugin *parent) : | |
27 | QThread((QObject*)parent) |
|
26 | QThread((QObject*)parent) | |
28 | { |
|
27 | { | |
29 | this->plugin = parent; |
|
28 | this->plugin = parent; | |
30 | rs232open("/dev/ttyUS0"); |
|
29 | uartMutex = new QMutex(); | |
|
30 | uartOpened = false; | |||
|
31 | fifoDebugConfigured = false; | |||
|
32 | this->moveToThread(this); | |||
31 | } |
|
33 | } | |
32 |
|
34 | |||
33 | void UARTPollingThread::run() |
|
35 | void UARTPollingThread::run() | |
34 | { |
|
36 | { | |
|
37 | ||||
|
38 | SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3); | |||
35 | while (!this->isInterruptionRequested()) |
|
39 | while (!this->isInterruptionRequested()) | |
36 | { |
|
40 | { | |
37 | if(fifoDebugEnabled) |
|
41 | if(fifoDebugEnabled) | |
38 | { |
|
42 | { | |
39 | if(this->plugin->baseAddress()!=-1) |
|
43 | if(fifoDebugConfigured) | |
40 | { |
|
44 | { | |
41 | unsigned int status_reg,data; |
|
45 | if(this->plugin->baseAddress()!=-1) | |
42 |
|
|
46 | { | |
43 |
|
|
47 | unsigned int status_reg,data; | |
44 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); |
|
48 | char ch; | |
45 | while ((status_reg&4)==0) { |
|
49 | QString printdata=""; | |
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 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); | |
|
51 | while ((status_reg&4)==0) { | |||
|
52 | plugin->parent->Read(&data,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); | |||
|
53 | ch = (char)(0xff & data); | |||
|
54 | printdata+=ch; | |||
|
55 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); | |||
|
56 | } | |||
|
57 | if(printdata!="") | |||
|
58 | emit apbUartTextReceived(printdata); | |||
50 | } |
|
59 | } | |
51 |
|
|
60 | else | |
52 | emit apbUartTextReceived(printdata); |
|
61 | { | |
|
62 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); | |||
|
63 | } | |||
53 | } |
|
64 | } | |
54 | else |
|
65 | else | |
55 | { |
|
66 | { | |
56 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); |
|
67 | configFifoDebug(true); | |
57 | } |
|
68 | } | |
58 | } |
|
69 | } | |
59 | if(uartOpened) |
|
70 | else | |
60 | { |
|
71 | { | |
61 |
|
72 | int read =0; | ||
|
73 | char ch; | |||
|
74 | uartMutex->lock(); | |||
|
75 | if(uartOpened) | |||
|
76 | { | |||
|
77 | read =rs232read(this->uart,&ch,1); | |||
|
78 | } | |||
|
79 | uartMutex->unlock(); | |||
|
80 | if(read==1) | |||
|
81 | { | |||
|
82 | emit this->sendChar(ch); | |||
|
83 | } | |||
62 | } |
|
84 | } | |
63 | msleep(100); |
|
85 | msleep(100); | |
64 | } |
|
86 | } | |
65 | } |
|
87 | } | |
66 |
|
88 | |||
67 | void UARTPollingThread::sendChar(char c) |
|
89 | void UARTPollingThread::sendChar(char c) | |
68 | { |
|
90 | { | |
|
91 | if(fifoDebugEnabled) | |||
|
92 | { | |||
|
93 | if(this->plugin->baseAddress()!=-1) | |||
|
94 | { | |||
|
95 | unsigned int i=0x0FF & c; | |||
|
96 | plugin->parent->Write(&i,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); | |||
|
97 | } | |||
|
98 | } | |||
|
99 | else | |||
|
100 | { | |||
|
101 | uartMutex->lock(); | |||
|
102 | rs232write(this->uart,&c,1); | |||
|
103 | uartMutex->unlock(); | |||
|
104 | } | |||
|
105 | } | |||
69 |
|
106 | |||
|
107 | bool UARTPollingThread::openUart() | |||
|
108 | { | |||
|
109 | if(uartOpened) | |||
|
110 | { | |||
|
111 | closeUart(); | |||
|
112 | } | |||
|
113 | this->uart = rs232open((char*)this->portName.toStdString().c_str()); | |||
|
114 | if(this->uart!=badPortValue) | |||
|
115 | { | |||
|
116 | rs232setup(this->uart,8,this->uartSpeed,rs232parityNo,rs232OneStop); | |||
|
117 | uartOpened = true; | |||
|
118 | } | |||
|
119 | return uartOpened; | |||
70 | } |
|
120 | } | |
|
121 | ||||
|
122 | void UARTPollingThread::closeUart() | |||
|
123 | { | |||
|
124 | uartMutex->lock(); | |||
|
125 | rs232close(this->uart); | |||
|
126 | uartOpened = false; | |||
|
127 | uartMutex->unlock(); | |||
|
128 | } | |||
|
129 | ||||
|
130 | void UARTPollingThread::setPortName(QString name) | |||
|
131 | { | |||
|
132 | this->portName = name; | |||
|
133 | } | |||
|
134 | ||||
|
135 | void UARTPollingThread::setPortSpeedStr(QString speed) | |||
|
136 | { | |||
|
137 | this->uartSpeed = speed.toInt(); | |||
|
138 | } | |||
|
139 | ||||
|
140 | void UARTPollingThread::setPortSpeed(int speed) | |||
|
141 | { | |||
|
142 | this->uartSpeed = speed; | |||
|
143 | } | |||
|
144 | ||||
|
145 | void UARTPollingThread::setFifoDebugEable(bool enable) | |||
|
146 | { | |||
|
147 | if(enable) | |||
|
148 | SocExplorerEngine::message(this->plugin,"Enabling APB UART FIFO debug mode",3); | |||
|
149 | else | |||
|
150 | SocExplorerEngine::message(this->plugin,"Disabling APB UART FIFO debug mode",3); | |||
|
151 | if(uartOpened && enable) | |||
|
152 | { | |||
|
153 | closeUart(); | |||
|
154 | } | |||
|
155 | this->fifoDebugConfigured = false; | |||
|
156 | configFifoDebug(enable); | |||
|
157 | this->fifoDebugEnabled = enable; | |||
|
158 | } | |||
|
159 | ||||
|
160 | void UARTPollingThread::configFifoDebug(bool enable) | |||
|
161 | { | |||
|
162 | SocExplorerEngine::message(this->plugin,"Configuring APB UART in FIFO debug mode",3); | |||
|
163 | if(this->plugin->baseAddress()==-1) | |||
|
164 | { | |||
|
165 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); | |||
|
166 | } | |||
|
167 | if(this->plugin->baseAddress()!=-1) | |||
|
168 | { | |||
|
169 | if(enable) | |||
|
170 | { | |||
|
171 | unsigned int ctrl_reg= 0x843; | |||
|
172 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |||
|
173 | this->fifoDebugConfigured = true; | |||
|
174 | } | |||
|
175 | else | |||
|
176 | { | |||
|
177 | unsigned int ctrl_reg; | |||
|
178 | /* Firts get Control reg value*/ | |||
|
179 | this->plugin->parent->Read(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |||
|
180 | ctrl_reg = ctrl_reg & (~(1<<11)); | |||
|
181 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |||
|
182 | this->fifoDebugConfigured = true; | |||
|
183 | } | |||
|
184 | } | |||
|
185 | } |
@@ -1,53 +1,65 | |||||
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) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, 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 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 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 UARTPOLLINGTHREAD_H |
|
22 | #ifndef UARTPOLLINGTHREAD_H | |
23 | #define UARTPOLLINGTHREAD_H |
|
23 | #define UARTPOLLINGTHREAD_H | |
24 |
|
24 | |||
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <QThread> |
|
26 | #include <QThread> | |
27 | #include <socexplorerplugin.h> |
|
27 | #include <socexplorerplugin.h> | |
|
28 | #include <RS232.h> | |||
|
29 | #include <QMutex> | |||
28 |
|
30 | |||
29 | #define APB_UART_DATA_REG 0x0 |
|
31 | #define APB_UART_DATA_REG 0x0 | |
30 | #define APB_UART_STATUS_REG 0x4 |
|
32 | #define APB_UART_STATUS_REG 0x4 | |
31 | #define APB_UART_CONTROL_REG 0x8 |
|
33 | #define APB_UART_CONTROL_REG 0x8 | |
32 | #define APB_UART_SCALE_REG 0xC |
|
34 | #define APB_UART_SCALE_REG 0xC | |
33 | #define APB_UART_FIFO_DEBUG_REG 0x10 |
|
35 | #define APB_UART_FIFO_DEBUG_REG 0x10 | |
34 |
|
36 | |||
35 | class UARTPollingThread : public QThread |
|
37 | class UARTPollingThread : public QThread | |
36 | { |
|
38 | { | |
37 | Q_OBJECT |
|
39 | Q_OBJECT | |
38 | public: |
|
40 | public: | |
39 | explicit UARTPollingThread(socexplorerplugin *parent = 0); |
|
41 | explicit UARTPollingThread(socexplorerplugin *parent = 0); | |
40 | void run(); |
|
42 | void run(); | |
41 | signals: |
|
43 | signals: | |
42 | void apbUartTextReceived(QString text); |
|
44 | void apbUartTextReceived(QString text); | |
43 | public slots: |
|
45 | public slots: | |
44 | void sendChar(char c); |
|
46 | void sendChar(char c); | |
|
47 | bool openUart(); | |||
|
48 | void closeUart(); | |||
|
49 | void setPortName(QString name); | |||
|
50 | void setPortSpeedStr(QString speed); | |||
|
51 | void setPortSpeed(int speed); | |||
|
52 | void setFifoDebugEable(bool enable); | |||
45 | private: |
|
53 | private: | |
|
54 | void configFifoDebug(bool enable); | |||
46 | bool fifoDebugEnabled; |
|
55 | bool fifoDebugEnabled; | |
|
56 | bool fifoDebugConfigured; | |||
47 | QString portName; |
|
57 | QString portName; | |
48 | int uartSpeed; |
|
58 | int uartSpeed; | |
49 | bool uartOpened; |
|
59 | bool uartOpened; | |
50 | socexplorerplugin* plugin; |
|
60 | socexplorerplugin* plugin; | |
|
61 | rs232port_t uart; | |||
|
62 | QMutex* uartMutex; | |||
51 | }; |
|
63 | }; | |
52 |
|
64 | |||
53 | #endif // UARTPOLLINGTHREAD_H |
|
65 | #endif // UARTPOLLINGTHREAD_H |
General Comments 0
You need to be logged in to leave comments.
Login now