@@ -0,0 +1,27 | |||||
|
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 "apbuartpywrapper.h" | |||
|
23 | ||||
|
24 | APBUartPyWrapper::APBUartPyWrapper(socexplorerplugin *parent) : | |||
|
25 | genericPySysdriver(parent) | |||
|
26 | { | |||
|
27 | } |
@@ -0,0 +1,46 | |||||
|
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 APBUARTPYWRAPPER_H | |||
|
23 | #define APBUARTPYWRAPPER_H | |||
|
24 | #include <QString> | |||
|
25 | #include <socexplorerplugin.h> | |||
|
26 | #include <genericPySysdriver.h> | |||
|
27 | ||||
|
28 | class APBUartPyWrapper : public genericPySysdriver | |||
|
29 | { | |||
|
30 | Q_OBJECT | |||
|
31 | public: | |||
|
32 | explicit APBUartPyWrapper(socexplorerplugin *parent = 0); | |||
|
33 | ||||
|
34 | signals: | |||
|
35 | void setFifoDebugEnabled(bool enable); | |||
|
36 | void setAPBUartIndex(int index); | |||
|
37 | void setUARTPortNane(QString name); | |||
|
38 | void setUARTPortSpeed(int speed); | |||
|
39 | void updateAPBUartsList(); | |||
|
40 | void openUart(); | |||
|
41 | void closeUart(); | |||
|
42 | public slots: | |||
|
43 | ||||
|
44 | }; | |||
|
45 | ||||
|
46 | #endif // APBUARTPYWRAPPER_H |
@@ -1,102 +1,177 | |||||
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 | #include <apbuartpywrapper.h> | |||
24 |
|
25 | |||
25 | ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent) |
|
26 | ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent,false) | |
26 | { |
|
27 | { | |
27 | this->setBaseAddress(-1); |
|
28 | this->setBaseAddress(-1); | |
|
29 | this->p_curentAPBUart = 0; | |||
28 | this->UI = new APBUART_Plugin_ui(); |
|
30 | this->UI = new APBUART_Plugin_ui(); | |
29 | this->setWidget((QWidget*)this->UI); |
|
31 | this->setWidget((QWidget*)this->UI); | |
30 | this->uartConnected = false; |
|
32 | this->uartConnected = false; | |
31 | this->UartThread = new UARTPollingThread(this); |
|
33 | this->UartThread = new UARTPollingThread(this); | |
32 | connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int))); |
|
34 | this->pyObject = new APBUartPyWrapper(this); | |
|
35 | connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(fifoDebugChangeState(int))); | |||
33 | connect(this->UartThread,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); |
|
36 | connect(this->UartThread,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); | |
34 | connect(this->UI,SIGNAL(connectPort()),this,SLOT(toggleUartState())); |
|
37 | connect(this->UI,SIGNAL(connectPort()),this,SLOT(toggleUartState())); | |
35 | connect(this->UI,SIGNAL(sendChar(char)),this->UartThread,SLOT(sendChar(char))); |
|
38 | connect(this->UI,SIGNAL(sendChar(char)),this->UartThread,SLOT(sendChar(char))); | |
36 | connect(this->UI,SIGNAL(PortNameChanged(QString)),this->UartThread,SLOT(setPortName(QString))); |
|
39 | connect(this->UI,SIGNAL(PortNameChanged(QString)),this->UartThread,SLOT(setPortName(QString))); | |
37 | connect(this->UI,SIGNAL(UartSpeedChanged(QString)),this->UartThread,SLOT(setPortSpeedStr(QString))); |
|
40 | connect(this->UI,SIGNAL(UartSpeedChanged(QString)),this->UartThread,SLOT(setPortSpeedStr(QString))); | |
|
41 | connect(this->UI,SIGNAL(updateAPBUartsList()),this,SLOT(updateAPBUartsList())); | |||
|
42 | connect(this->UI,SIGNAL(curentAPBUartChanged(int)),this,SLOT(setCurentAPBUart(int))); | |||
|
43 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(openUart()),this,SLOT(openUart())); | |||
|
44 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(closeUart()),this,SLOT(closeUart())); | |||
|
45 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setFifoDebugEnabled(bool)),this,SLOT(setFifoDebugEnabled(bool))); | |||
|
46 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setUARTPortNane(QString)),this,SLOT(setUARTPortNane(QString))); | |||
|
47 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setUARTPortSpeed(int)),this,SLOT(setUARTPortSpeed(int))); | |||
|
48 | connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(updateAPBUartsList()),this,SLOT(updateAPBUartsList())); | |||
38 | this->UartThread->start(); |
|
49 | this->UartThread->start(); | |
39 | } |
|
50 | } | |
40 |
|
51 | |||
41 |
|
52 | |||
42 | ApbUartPlugin::~ApbUartPlugin() |
|
53 | ApbUartPlugin::~ApbUartPlugin() | |
43 | { |
|
54 | { | |
44 |
|
55 | |||
45 | } |
|
56 | } | |
46 |
|
57 | |||
|
58 | int ApbUartPlugin::curentAPBUart() | |||
|
59 | { | |||
|
60 | return p_curentAPBUart; | |||
|
61 | } | |||
|
62 | ||||
47 | void ApbUartPlugin::closeMe() |
|
63 | void ApbUartPlugin::closeMe() | |
48 | { |
|
64 | { | |
49 | emit this->closePlugin(this); |
|
65 | emit this->closePlugin(this); | |
50 | } |
|
66 | } | |
51 |
|
67 | |||
52 | void ApbUartPlugin::toggleUartState() |
|
68 | void ApbUartPlugin::toggleUartState() | |
53 | { |
|
69 | { | |
54 | if(!uartConnected) |
|
70 | if(!uartConnected) | |
55 | { |
|
71 | { | |
56 |
|
|
72 | this->openUart(); | |
57 | } |
|
73 | } | |
58 | else |
|
74 | else | |
59 | { |
|
75 | { | |
60 |
this |
|
76 | this->closeUart(); | |
61 | this->uartConnected = false; |
|
|||
62 | } |
|
77 | } | |
|
78 | } | |||
|
79 | ||||
|
80 | void ApbUartPlugin::activate(bool flag) | |||
|
81 | { | |||
|
82 | socexplorerplugin::activate(flag); | |||
|
83 | this->updateAPBUartsList(); | |||
|
84 | } | |||
|
85 | ||||
|
86 | void ApbUartPlugin::updateAPBUartsList() | |||
|
87 | { | |||
|
88 | QList<unsigned int> addresses; | |||
|
89 | int count = SocExplorerEngine::self()->getEnumDeviceCount(this,this->VID(),this->PID()); | |||
|
90 | for(int i=0;i<count;i++) | |||
|
91 | { | |||
|
92 | addresses.append(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),i)); | |||
|
93 | } | |||
|
94 | this->UI->updateAPBUartList(addresses); | |||
|
95 | } | |||
|
96 | ||||
|
97 | void ApbUartPlugin::setCurentAPBUart(int index) | |||
|
98 | { | |||
|
99 | this->p_curentAPBUart = index; | |||
|
100 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),index)); | |||
|
101 | } | |||
|
102 | ||||
|
103 | void ApbUartPlugin::openUart() | |||
|
104 | { | |||
|
105 | if(this->UartThread->fifoDebugEnabled()) | |||
|
106 | setFifoDebugEnabled(false); | |||
|
107 | if(!uartConnected) | |||
|
108 | uartConnected = this->UartThread->openUart(); | |||
63 | this->UI->setUartConnected(uartConnected); |
|
109 | this->UI->setUartConnected(uartConnected); | |
64 | } |
|
110 | } | |
65 |
|
111 | |||
66 |
void ApbUartPlugin:: |
|
112 | void ApbUartPlugin::closeUart() | |
|
113 | { | |||
|
114 | if(uartConnected) | |||
|
115 | this->UartThread->closeUart(); | |||
|
116 | this->uartConnected = false; | |||
|
117 | this->UI->setUartConnected(uartConnected); | |||
|
118 | } | |||
|
119 | ||||
|
120 | void ApbUartPlugin::setFifoDebugEnabled(bool enable) | |||
|
121 | { | |||
|
122 | if(uartConnected) | |||
|
123 | closeUart(); | |||
|
124 | this->UI->setEnableForLoopBack(!enable); | |||
|
125 | this->UartThread->setFifoDebugEable(enable); | |||
|
126 | } | |||
|
127 | ||||
|
128 | void ApbUartPlugin::setAPBUartIndex(int index) | |||
|
129 | { | |||
|
130 | this->UI->setAPBUartIndex(index); | |||
|
131 | } | |||
|
132 | ||||
|
133 | void ApbUartPlugin::setUARTPortNane(QString name) | |||
|
134 | { | |||
|
135 | this->UI->setUartPortName(name); | |||
|
136 | } | |||
|
137 | ||||
|
138 | void ApbUartPlugin::setUARTPortSpeed(int speed) | |||
|
139 | { | |||
|
140 | this->UI->setUartSpeed(speed); | |||
|
141 | } | |||
|
142 | ||||
|
143 | void ApbUartPlugin::fifoDebugChangeState(int state) | |||
67 | { |
|
144 | { | |
68 | if(state==Qt::Checked) |
|
145 | if(state==Qt::Checked) | |
69 | { |
|
146 | { | |
70 |
this-> |
|
147 | this->setFifoDebugEnabled(true); | |
71 | this->UartThread->setFifoDebugEable(true); |
|
|||
72 | } |
|
148 | } | |
73 | else |
|
149 | else | |
74 | { |
|
150 | { | |
75 |
this-> |
|
151 | this->setFifoDebugEnabled(false); | |
76 | this->UartThread->setFifoDebugEable(false); |
|
|||
77 | } |
|
152 | } | |
78 | } |
|
153 | } | |
79 |
|
154 | |||
80 |
|
155 | |||
81 | unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
156 | unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
82 | { |
|
157 | { | |
83 | if(parent!=NULL) |
|
158 | if(parent!=NULL) | |
84 | return parent->Read(Value,count,address); |
|
159 | return parent->Read(Value,count,address); | |
85 | return 0; |
|
160 | return 0; | |
86 | } |
|
161 | } | |
87 |
|
162 | |||
88 |
|
163 | |||
89 | unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
164 | unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
90 | { |
|
165 | { | |
91 | if(parent!=NULL) |
|
166 | if(parent!=NULL) | |
92 | return parent->Write(Value,count,address); |
|
167 | return parent->Write(Value,count,address); | |
93 | return 0; |
|
168 | return 0; | |
94 | } |
|
169 | } | |
95 |
|
170 | |||
96 |
|
171 | |||
97 |
|
172 | |||
98 |
|
173 | |||
99 |
|
174 | |||
100 |
|
175 | |||
101 |
|
176 | |||
102 |
|
177 |
@@ -1,65 +1,76 | |||||
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 | int curentAPBUart(); | ||
|
48 | ||||
48 | public slots: |
|
49 | public slots: | |
49 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
50 | 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); |
|
51 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
51 |
void |
|
52 | void fifoDebugChangeState(int state); | |
52 | void closeMe(); |
|
53 | void closeMe(); | |
53 | void toggleUartState(); |
|
54 | void toggleUartState(); | |
|
55 | void activate(bool flag); | |||
|
56 | void updateAPBUartsList(); | |||
|
57 | void setCurentAPBUart(int index); | |||
|
58 | void openUart(); | |||
|
59 | void closeUart(); | |||
|
60 | void setFifoDebugEnabled(bool enable); | |||
|
61 | void setAPBUartIndex(int index); | |||
|
62 | void setUARTPortNane(QString name); | |||
|
63 | void setUARTPortSpeed(int speed); | |||
54 | signals: |
|
64 | signals: | |
55 |
|
65 | |||
56 | private: |
|
66 | private: | |
57 | APBUART_Plugin_ui* UI; |
|
67 | APBUART_Plugin_ui* UI; | |
58 | bool uartConnected; |
|
68 | bool uartConnected; | |
|
69 | int p_curentAPBUart; | |||
59 | UARTPollingThread* UartThread; |
|
70 | UARTPollingThread* UartThread; | |
60 | int enableLoopback(); |
|
71 | int enableLoopback(); | |
61 | int disableLoopback(); |
|
72 | int disableLoopback(); | |
62 | }; |
|
73 | }; | |
63 |
|
74 | |||
64 | #endif // APBUARTPLUGIN_H |
|
75 | #endif // APBUARTPLUGIN_H | |
65 |
|
76 |
@@ -1,72 +1,75 | |||||
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 | ||||
7 | win32:CONFIG += dll |
|
8 | win32:CONFIG += dll | |
8 | win32:CONFIG -= static |
|
9 | win32:CONFIG -= static | |
9 |
|
10 | |||
10 | CONFIG(debug, debug|release) { |
|
11 | CONFIG(debug, debug|release) { | |
11 | DEBUG_EXT = _d |
|
12 | DEBUG_EXT = _d | |
12 | } else { |
|
13 | } else { | |
13 | DEBUG_EXT = |
|
14 | DEBUG_EXT = | |
14 | } |
|
15 | } | |
15 |
|
16 | |||
16 | TARGET = ApbUartPlugin$${DEBUG_EXT} |
|
17 | TARGET = ApbUartPlugin$${DEBUG_EXT} | |
17 |
|
18 | |||
18 | DEFINES += PLUGIN=ApbUartPlugin |
|
19 | DEFINES += PLUGIN=ApbUartPlugin | |
19 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" |
|
20 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" | |
20 | DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\" |
|
21 | DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\" | |
21 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" |
|
22 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
22 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
23 | 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."\\\"\" |
|
24 | 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 |
|
25 | DEFINES += driver_can_be_root=0 | |
25 | DEFINES += driver_can_be_child=1 |
|
26 | DEFINES += driver_can_be_child=1 | |
26 | DEFINES += driver_VID=1 |
|
27 | DEFINES += driver_VID=1 | |
27 | DEFINES += driver_PID=0x0c |
|
28 | DEFINES += driver_PID=0x0c | |
28 |
|
29 | |||
29 |
|
30 | |||
30 |
|
31 | |||
31 | INCLUDEPATH += \ |
|
32 | INCLUDEPATH += \ | |
32 | $${PWD} |
|
33 | $${PWD} | |
33 |
|
34 | |||
34 | HEADERS += \ |
|
35 | HEADERS += \ | |
35 | APBUARTPLUGIN.h \ |
|
36 | APBUARTPLUGIN.h \ | |
36 | apbuartterminal.h \ |
|
37 | apbuartterminal.h \ | |
37 | apbuart_plugin_ui.h \ |
|
38 | apbuart_plugin_ui.h \ | |
38 | uartpollingthread.h |
|
39 | uartpollingthread.h \ | |
|
40 | apbuartpywrapper.h | |||
39 |
|
41 | |||
40 |
|
42 | |||
41 | SOURCES += \ |
|
43 | SOURCES += \ | |
42 | APBUARTPLUGIN.cpp \ |
|
44 | APBUARTPLUGIN.cpp \ | |
43 | apbuartterminal.cpp \ |
|
45 | apbuartterminal.cpp \ | |
44 | apbuart_plugin_ui.cpp \ |
|
46 | apbuart_plugin_ui.cpp \ | |
45 | uartpollingthread.cpp |
|
47 | uartpollingthread.cpp \ | |
|
48 | apbuartpywrapper.cpp | |||
46 |
|
49 | |||
47 | FORMS += \ |
|
50 | FORMS += \ | |
48 | apbuart_plugin_ui.ui |
|
51 | apbuart_plugin_ui.ui | |
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 |
|
75 |
@@ -1,100 +1,145 | |||||
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 | #include "apbuartterminal.h" | |
|
25 | #include <QComboBox> | |||
25 |
|
26 | |||
26 | APBUART_Plugin_ui::APBUART_Plugin_ui(QWidget *parent) : |
|
27 | APBUART_Plugin_ui::APBUART_Plugin_ui(QWidget *parent) : | |
27 | QWidget(parent), |
|
28 | QWidget(parent), | |
28 | ui(new Ui::APBUART_Plugin_ui) |
|
29 | ui(new Ui::APBUART_Plugin_ui) | |
29 | { |
|
30 | { | |
30 | ui->setupUi(this); |
|
31 | ui->setupUi(this); | |
31 | connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); |
|
32 | connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); | |
32 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(apbUartTextReceived(QString))); |
|
33 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(apbUartTextReceived(QString))); | |
33 | connect(this->ui->ConnectQpb,SIGNAL(clicked()),this,SIGNAL(connectPort())); |
|
34 | 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->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->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString))); | |
36 | connect(this->ui->UartSpeedLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(UartSpeedChanged(QString))); |
|
37 | connect(this->ui->UartSpeedLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(UartSpeedChanged(QString))); | |
37 | connect(this->ui->rescanQpb,SIGNAL(clicked()),this,SLOT(updatePortList())); |
|
38 | connect(this->ui->rescanQpb,SIGNAL(clicked()),this,SLOT(updatePortList())); | |
|
39 | connect(this->ui->APBUartsUpdateQpb,SIGNAL(clicked()),this,SIGNAL(updateAPBUartsList())); | |||
|
40 | connect(this->ui->UARTSelector,SIGNAL(currentIndexChanged(int)),this,SIGNAL(curentAPBUartChanged(int))); | |||
38 | this->portListcompleter = NULL; |
|
41 | this->portListcompleter = NULL; | |
39 | this->updatePortList(); |
|
42 | this->updatePortList(); | |
40 | } |
|
43 | } | |
41 |
|
44 | |||
42 | APBUART_Plugin_ui::~APBUART_Plugin_ui() |
|
45 | APBUART_Plugin_ui::~APBUART_Plugin_ui() | |
43 | { |
|
46 | { | |
44 | delete ui; |
|
47 | delete ui; | |
45 | } |
|
48 | } | |
46 |
|
49 | |||
|
50 | int APBUART_Plugin_ui::curentAPBUart() | |||
|
51 | { | |||
|
52 | return this->ui->UARTSelector->currentIndex(); | |||
|
53 | } | |||
|
54 | ||||
47 | void APBUART_Plugin_ui::setEnableForLoopBack(bool enable) |
|
55 | void APBUART_Plugin_ui::setEnableForLoopBack(bool enable) | |
48 | { |
|
56 | { | |
49 | this->ui->PortNameLineEdit->setEnabled(enable); |
|
57 | this->ui->PortNameLineEdit->setEnabled(enable); | |
50 | this->ui->ConnectQpb->setEnabled(enable); |
|
58 | this->ui->ConnectQpb->setEnabled(enable); | |
51 | this->ui->UartSpeedLineEdit->setEnabled(enable); |
|
59 | this->ui->UartSpeedLineEdit->setEnabled(enable); | |
|
60 | this->ui->APBUartsUpdateQpb->setEnabled(enable); | |||
|
61 | this->ui->rescanQpb->setEnabled(enable); | |||
|
62 | this->ui->UARTSelector->setEnabled(enable); | |||
|
63 | if(this->ui->FIFODebugChkBx->isChecked()==enable) | |||
|
64 | this->ui->FIFODebugChkBx->toggle(); | |||
|
65 | ||||
52 | } |
|
66 | } | |
53 |
|
67 | |||
54 | void APBUART_Plugin_ui::setUartConnected(bool enable) |
|
68 | void APBUART_Plugin_ui::setUartConnected(bool enable) | |
55 | { |
|
69 | { | |
56 | this->ui->PortNameLineEdit->setDisabled(enable); |
|
70 | this->ui->PortNameLineEdit->setDisabled(enable); | |
57 | this->ui->UartSpeedLineEdit->setDisabled(enable); |
|
71 | this->ui->UartSpeedLineEdit->setDisabled(enable); | |
58 | this->ui->FIFODebugChkBx->setDisabled(enable); |
|
72 | this->ui->FIFODebugChkBx->setDisabled(enable); | |
|
73 | this->ui->APBUartsUpdateQpb->setDisabled(enable); | |||
|
74 | this->ui->rescanQpb->setDisabled(enable); | |||
|
75 | this->ui->UARTSelector->setDisabled(enable); | |||
59 | if(enable) |
|
76 | if(enable) | |
60 | { |
|
77 | { | |
61 | this->ui->ConnectQpb->setText("Close Port"); |
|
78 | this->ui->ConnectQpb->setText("Close Port"); | |
62 | } |
|
79 | } | |
63 | else |
|
80 | else | |
64 | { |
|
81 | { | |
65 | this->ui->ConnectQpb->setText("Open Port"); |
|
82 | this->ui->ConnectQpb->setText("Open Port"); | |
66 | } |
|
83 | } | |
67 | } |
|
84 | } | |
68 |
|
85 | |||
69 | #include <RS232.h> |
|
86 | #include <RS232.h> | |
70 |
|
87 | |||
71 | void APBUART_Plugin_ui::updatePortList() |
|
88 | void APBUART_Plugin_ui::updatePortList() | |
72 | { |
|
89 | { | |
73 | if(this->portListcompleter==(QCompleter*)NULL) |
|
90 | if(this->portListcompleter==(QCompleter*)NULL) | |
74 | { |
|
91 | { | |
75 | this->portListcompleter=new QCompleter(this); |
|
92 | this->portListcompleter=new QCompleter(this); | |
76 | this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
93 | this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); | |
77 | this->portListcompleterModel = new QStringListModel(this); |
|
94 | this->portListcompleterModel = new QStringListModel(this); | |
78 | this->portListcompleter->setModel(this->portListcompleterModel); |
|
95 | this->portListcompleter->setModel(this->portListcompleterModel); | |
79 | this->ui->PortNameLineEdit->setCompleter(this->portListcompleter); |
|
96 | this->ui->PortNameLineEdit->setCompleter(this->portListcompleter); | |
80 | } |
|
97 | } | |
81 | rs232portslist_t* portlist = rs232getportlist(); |
|
98 | rs232portslist_t* portlist = rs232getportlist(); | |
82 | rs232portslist_t* portlistenum = portlist; |
|
99 | rs232portslist_t* portlistenum = portlist; | |
83 | QStringList wordList; |
|
100 | QStringList wordList; | |
84 | while(portlistenum!=NULL) |
|
101 | while(portlistenum!=NULL) | |
85 | { |
|
102 | { | |
86 | wordList << portlistenum->name; |
|
103 | wordList << portlistenum->name; | |
87 | portlistenum = portlistenum->next; |
|
104 | portlistenum = portlistenum->next; | |
88 | } |
|
105 | } | |
89 | rs232deleteportlist(portlist); |
|
106 | rs232deleteportlist(portlist); | |
90 | this->portListcompleterModel->setStringList(wordList); |
|
107 | this->portListcompleterModel->setStringList(wordList); | |
91 | } |
|
108 | } | |
92 |
|
109 | |||
|
110 | void APBUART_Plugin_ui::updateAPBUartList(QList<unsigned int> addresses) | |||
|
111 | { | |||
|
112 | this->ui->UARTSelector->clear(); | |||
|
113 | for(int i=0;i<addresses.count();i++) | |||
|
114 | { | |||
|
115 | this->ui->UARTSelector->addItem(QString("APBUart %1 @0x%2").arg(i).arg(addresses.at(i),8,16)); | |||
|
116 | } | |||
|
117 | if(addresses.count()==0) | |||
|
118 | this->ui->UARTSelector->addItem("None"); | |||
|
119 | } | |||
|
120 | ||||
|
121 | void APBUART_Plugin_ui::setUartSpeed(int speed) | |||
|
122 | { | |||
|
123 | this->ui->UartSpeedLineEdit->setText(QString::number(speed)); | |||
|
124 | } | |||
|
125 | ||||
|
126 | void APBUART_Plugin_ui::setUartPortName(QString name) | |||
|
127 | { | |||
|
128 | this->ui->PortNameLineEdit->setText(name); | |||
|
129 | } | |||
|
130 | ||||
|
131 | void APBUART_Plugin_ui::setAPBUartIndex(int index) | |||
|
132 | { | |||
|
133 | if((index<this->ui->UARTSelector->count()) && (index>0) ) | |||
|
134 | this->ui->UARTSelector->setCurrentIndex(index); | |||
|
135 | } | |||
93 |
|
136 | |||
94 |
|
137 | |||
95 |
|
138 | |||
96 |
|
139 | |||
97 |
|
140 | |||
98 |
|
141 | |||
99 |
|
142 | |||
100 |
|
143 | |||
|
144 | ||||
|
145 |
@@ -1,58 +1,66 | |||||
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 | #include <QCompleter> |
|
26 | #include <QCompleter> | |
27 | #include <QStringListModel> |
|
27 | #include <QStringListModel> | |
28 |
|
28 | |||
29 | namespace Ui { |
|
29 | namespace Ui { | |
30 | class APBUART_Plugin_ui; |
|
30 | class APBUART_Plugin_ui; | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | class APBUART_Plugin_ui : public QWidget |
|
33 | class APBUART_Plugin_ui : public QWidget | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 |
|
36 | |||
37 | public: |
|
37 | public: | |
38 | explicit APBUART_Plugin_ui(QWidget *parent = 0); |
|
38 | explicit APBUART_Plugin_ui(QWidget *parent = 0); | |
39 | ~APBUART_Plugin_ui(); |
|
39 | ~APBUART_Plugin_ui(); | |
40 |
|
40 | int curentAPBUart(); | ||
41 | public slots: |
|
41 | public slots: | |
42 | void setEnableForLoopBack(bool enable); |
|
42 | void setEnableForLoopBack(bool enable); | |
43 | void setUartConnected(bool enable); |
|
43 | void setUartConnected(bool enable); | |
44 | void updatePortList(); |
|
44 | void updatePortList(); | |
|
45 | void updateAPBUartList(QList<unsigned int> addresses); | |||
|
46 | void setUartSpeed(int speed); | |||
|
47 | void setUartPortName(QString name); | |||
|
48 | void setAPBUartIndex(int index); | |||
|
49 | private slots: | |||
|
50 | ||||
45 | signals: |
|
51 | signals: | |
|
52 | void curentAPBUartChanged(int index); | |||
46 | void loopbackChkBxStateChanged( int state ); |
|
53 | void loopbackChkBxStateChanged( int state ); | |
47 | void apbUartTextReceived(QString text); |
|
54 | void apbUartTextReceived(QString text); | |
48 | void connectPort(); |
|
55 | void connectPort(); | |
49 | void sendChar(char c); |
|
56 | void sendChar(char c); | |
50 | void UartSpeedChanged(QString text); |
|
57 | void UartSpeedChanged(QString text); | |
51 | void PortNameChanged(QString text); |
|
58 | void PortNameChanged(QString text); | |
|
59 | void updateAPBUartsList(); | |||
52 | private: |
|
60 | private: | |
53 | Ui::APBUART_Plugin_ui *ui; |
|
61 | Ui::APBUART_Plugin_ui *ui; | |
54 | QCompleter *portListcompleter; |
|
62 | QCompleter *portListcompleter; | |
55 | QStringListModel *portListcompleterModel; |
|
63 | QStringListModel *portListcompleterModel; | |
56 | }; |
|
64 | }; | |
57 |
|
65 | |||
58 | #endif // APBUART_PLUGIN_UI_H |
|
66 | #endif // APBUART_PLUGIN_UI_H |
@@ -1,96 +1,128 | |||||
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> |
|
9 | <width>608</width> | |
10 |
<height>3 |
|
10 | <height>319</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>0</number> |
|
20 | <number>0</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=" |
|
27 | <item row="2" column="0" colspan="3"> | |
28 |
<widget class="Q |
|
28 | <widget class="QGroupBox" name="Uartconfig"> | |
29 | </item> |
|
29 | <property name="title"> | |
30 | <item row="0" column="0" colspan="2"> |
|
30 | <string>APB UART Config</string> | |
31 | <widget class="QCheckBox" name="FIFODebugChkBx"> |
|
|||
32 | <property name="text"> |
|
|||
33 | <string>Enable FIFO debug mode</string> |
|
|||
34 | </property> |
|
|||
35 | <property name="checked"> |
|
|||
36 | <bool>false</bool> |
|
|||
37 | </property> |
|
|||
38 | </widget> |
|
|||
39 | </item> |
|
|||
40 | <item row="1" column="0"> |
|
|||
41 | <widget class="QLabel" name="PortNameLbl"> |
|
|||
42 | <property name="text"> |
|
|||
43 | <string>Port Name</string> |
|
|||
44 | </property> |
|
31 | </property> | |
45 | </widget> |
|
32 | <layout class="QGridLayout" name="gridLayout_2"> | |
46 | </item> |
|
33 | <item row="2" column="0"> | |
47 | <item row="3" column="0"> |
|
34 | <widget class="QLabel" name="PortNameLbl"> | |
48 | <widget class="QLabel" name="UartSpeedLbl"> |
|
35 | <property name="text"> | |
49 | <property name="text"> |
|
36 | <string>Port Name</string> | |
50 | <string>Uart Speed</string> |
|
37 | </property> | |
51 |
|
|
38 | </widget> | |
52 |
</ |
|
39 | </item> | |
53 | </item> |
|
40 | <item row="3" column="0"> | |
54 | <item row="1" column="2"> |
|
41 | <widget class="QLabel" name="UartSpeedLbl"> | |
55 | <widget class="QPushButton" name="rescanQpb"> |
|
42 | <property name="text"> | |
56 | <property name="text"> |
|
43 | <string>Uart Speed</string> | |
57 | <string>Rescan ports</string> |
|
44 | </property> | |
58 |
|
|
45 | </widget> | |
59 |
</ |
|
46 | </item> | |
60 | </item> |
|
47 | <item row="0" column="0"> | |
61 | <item row="3" column="1" colspan="2"> |
|
48 | <widget class="QCheckBox" name="FIFODebugChkBx"> | |
62 | <widget class="QLineEdit" name="UartSpeedLineEdit"/> |
|
49 | <property name="text"> | |
63 | </item> |
|
50 | <string>Enable FIFO debug mode</string> | |
64 | <item row="4" column="1" colspan="2"> |
|
51 | </property> | |
65 | <widget class="QPushButton" name="ConnectQpb"> |
|
52 | <property name="checked"> | |
66 | <property name="text"> |
|
53 | <bool>false</bool> | |
67 | <string>Open Port</string> |
|
54 | </property> | |
68 |
|
|
55 | </widget> | |
|
56 | </item> | |||
|
57 | <item row="0" column="3"> | |||
|
58 | <widget class="QPushButton" name="APBUartsUpdateQpb"> | |||
|
59 | <property name="text"> | |||
|
60 | <string>Update</string> | |||
|
61 | </property> | |||
|
62 | </widget> | |||
|
63 | </item> | |||
|
64 | <item row="3" column="1" colspan="3"> | |||
|
65 | <widget class="QLineEdit" name="UartSpeedLineEdit"/> | |||
|
66 | </item> | |||
|
67 | <item row="2" column="3"> | |||
|
68 | <widget class="QPushButton" name="rescanQpb"> | |||
|
69 | <property name="text"> | |||
|
70 | <string>Rescan ports</string> | |||
|
71 | </property> | |||
|
72 | </widget> | |||
|
73 | </item> | |||
|
74 | <item row="2" column="1" colspan="2"> | |||
|
75 | <widget class="QLineEdit" name="PortNameLineEdit"/> | |||
|
76 | </item> | |||
|
77 | <item row="0" column="2"> | |||
|
78 | <widget class="QComboBox" name="UARTSelector"> | |||
|
79 | <item> | |||
|
80 | <property name="text"> | |||
|
81 | <string>None</string> | |||
|
82 | </property> | |||
|
83 | </item> | |||
|
84 | </widget> | |||
|
85 | </item> | |||
|
86 | <item row="0" column="1"> | |||
|
87 | <widget class="QLabel" name="label"> | |||
|
88 | <property name="text"> | |||
|
89 | <string>Chose UART</string> | |||
|
90 | </property> | |||
|
91 | </widget> | |||
|
92 | </item> | |||
|
93 | <item row="4" column="2" colspan="2"> | |||
|
94 | <widget class="QPushButton" name="ConnectQpb"> | |||
|
95 | <property name="text"> | |||
|
96 | <string>Open Port</string> | |||
|
97 | </property> | |||
|
98 | </widget> | |||
|
99 | </item> | |||
|
100 | </layout> | |||
69 | </widget> |
|
101 | </widget> | |
70 | </item> |
|
102 | </item> | |
71 | </layout> |
|
103 | </layout> | |
72 | </widget> |
|
104 | </widget> | |
73 | <widget class="QWidget" name="Terminal"> |
|
105 | <widget class="QWidget" name="Terminal"> | |
74 | <attribute name="title"> |
|
106 | <attribute name="title"> | |
75 | <string>Terminal</string> |
|
107 | <string>Terminal</string> | |
76 | </attribute> |
|
108 | </attribute> | |
77 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
109 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
78 | <item> |
|
110 | <item> | |
79 | <widget class="ApbUartTerminal" name="UART_TERM"/> |
|
111 | <widget class="ApbUartTerminal" name="UART_TERM"/> | |
80 | </item> |
|
112 | </item> | |
81 | </layout> |
|
113 | </layout> | |
82 | </widget> |
|
114 | </widget> | |
83 | </widget> |
|
115 | </widget> | |
84 | </item> |
|
116 | </item> | |
85 | </layout> |
|
117 | </layout> | |
86 | </widget> |
|
118 | </widget> | |
87 | <customwidgets> |
|
119 | <customwidgets> | |
88 | <customwidget> |
|
120 | <customwidget> | |
89 | <class>ApbUartTerminal</class> |
|
121 | <class>ApbUartTerminal</class> | |
90 | <extends>QTextEdit</extends> |
|
122 | <extends>QTextEdit</extends> | |
91 | <header>apbuartterminal.h</header> |
|
123 | <header>apbuartterminal.h</header> | |
92 | </customwidget> |
|
124 | </customwidget> | |
93 | </customwidgets> |
|
125 | </customwidgets> | |
94 | <resources/> |
|
126 | <resources/> | |
95 | <connections/> |
|
127 | <connections/> | |
96 | </ui> |
|
128 | </ui> |
@@ -1,217 +1,222 | |||||
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 <socexplorerengine.h> |
|
23 | #include <socexplorerengine.h> | |
24 |
|
24 | |||
25 | UARTPollingThread::UARTPollingThread(socexplorerplugin *parent) : |
|
25 | UARTPollingThread::UARTPollingThread(socexplorerplugin *parent) : | |
26 | QThread((QObject*)parent) |
|
26 | QThread((QObject*)parent) | |
27 | { |
|
27 | { | |
28 | this->plugin = parent; |
|
28 | this->plugin = parent; | |
29 | uartMutex = new QMutex(); |
|
29 | uartMutex = new QMutex(); | |
30 | uartOpened = false; |
|
30 | uartOpened = false; | |
31 | fifoDebugConfigured = false; |
|
31 | fifoDebugConfigured = false; | |
32 | fifoDebugEnabled = false; |
|
32 | p_fifoDebugEnabled = false; | |
33 | this->moveToThread(this); |
|
33 | this->moveToThread(this); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | UARTPollingThread::~UARTPollingThread() |
|
36 | UARTPollingThread::~UARTPollingThread() | |
37 | { |
|
37 | { | |
38 | this->requestInterruption(); |
|
38 | this->requestInterruption(); | |
39 | while(isRunning()); |
|
39 | while(isRunning()); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void UARTPollingThread::run() |
|
42 | void UARTPollingThread::run() | |
43 | { |
|
43 | { | |
44 |
|
44 | |||
45 | char ch[4097]; |
|
45 | char ch[4097]; | |
46 | int timeout =10; |
|
46 | int timeout =10; | |
47 | SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3); |
|
47 | SocExplorerEngine::message(this->plugin,"Entering APB UART polling thread",3); | |
48 | while (!this->isInterruptionRequested()) |
|
48 | while (!this->isInterruptionRequested()) | |
49 | { |
|
49 | { | |
50 | if(fifoDebugEnabled) |
|
50 | if(p_fifoDebugEnabled) | |
51 | { |
|
51 | { | |
52 | if(fifoDebugConfigured) |
|
52 | if(fifoDebugConfigured) | |
53 | { |
|
53 | { | |
54 | if(this->plugin->baseAddress()!=-1) |
|
54 | if(this->plugin->baseAddress()!=-1) | |
55 | { |
|
55 | { | |
56 | unsigned int status_reg,data; |
|
56 | unsigned int status_reg,data; | |
57 | char ch; |
|
57 | char ch; | |
58 | QString printdata=""; |
|
58 | QString printdata=""; | |
59 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); |
|
59 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); | |
60 | while ((status_reg&4)==0) { |
|
60 | while ((status_reg & 4)==0) { | |
61 | plugin->parent->Read(&data,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); |
|
61 | plugin->parent->Read(&data,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); | |
62 | ch = (char)(0xff & data); |
|
62 | ch = (char)(0xff & data); | |
63 | printdata+=ch; |
|
63 | printdata+=ch; | |
64 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); |
|
64 | plugin->parent->Read(&status_reg,1,this->plugin->baseAddress()+APB_UART_STATUS_REG); | |
65 | } |
|
65 | } | |
66 | if(printdata!="") |
|
66 | if(printdata!="") | |
67 | emit apbUartTextReceived(printdata); |
|
67 | emit apbUartTextReceived(printdata); | |
68 | } |
|
68 | } | |
69 | else |
|
69 | else | |
70 | { |
|
70 | { | |
71 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); |
|
71 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | else |
|
74 | else | |
75 | { |
|
75 | { | |
76 | configFifoDebug(true); |
|
76 | configFifoDebug(true); | |
77 | } |
|
77 | } | |
78 | } |
|
78 | } | |
79 | else |
|
79 | else | |
80 | { |
|
80 | { | |
81 | int read =0,avail=0; |
|
81 | int read =0,avail=0; | |
82 | uartMutex->lock(); |
|
82 | uartMutex->lock(); | |
83 | if(uartOpened) |
|
83 | if(uartOpened) | |
84 | { |
|
84 | { | |
85 | avail = rs232availablebytes(this->uart); |
|
85 | avail = rs232availablebytes(this->uart); | |
86 | SocExplorerEngine::message(this->plugin,QString("%1 available bytes on uart").arg(read),3); |
|
86 | SocExplorerEngine::message(this->plugin,QString("%1 available bytes on uart").arg(read),3); | |
87 | if(avail) |
|
87 | if(avail) | |
88 | { |
|
88 | { | |
89 | if(avail>=4096) |
|
89 | if(avail>=4096) | |
90 | { |
|
90 | { | |
91 | read = rs232read(this->uart,ch,4096); |
|
91 | read = rs232read(this->uart,ch,4096); | |
92 | timeout = 0; |
|
92 | timeout = 0; | |
93 | } |
|
93 | } | |
94 | else |
|
94 | else | |
95 | { |
|
95 | { | |
96 | read = rs232read(this->uart,ch,avail); |
|
96 | read = rs232read(this->uart,ch,avail); | |
97 | timeout = 10; |
|
97 | timeout = 10; | |
98 | } |
|
98 | } | |
99 | SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3); |
|
99 | SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3); | |
100 | ch[read]='\0'; |
|
100 | ch[read]='\0'; | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 | uartMutex->unlock(); |
|
103 | uartMutex->unlock(); | |
104 | if(read>=1) |
|
104 | if(read>=1) | |
105 | { |
|
105 | { | |
106 | SocExplorerEngine::message(this->plugin,QString("Received %1 char(s) from APBUART").arg(read),3); |
|
106 | SocExplorerEngine::message(this->plugin,QString("Received %1 char(s) from APBUART").arg(read),3); | |
107 | emit this->apbUartTextReceived(QString(ch)); |
|
107 | emit this->apbUartTextReceived(QString(ch)); | |
108 | } |
|
108 | } | |
109 | msleep(timeout); |
|
109 | msleep(timeout); | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | void UARTPollingThread::sendChar(char c) |
|
114 | void UARTPollingThread::sendChar(char c) | |
115 | { |
|
115 | { | |
116 | if(fifoDebugEnabled) |
|
116 | if(p_fifoDebugEnabled) | |
117 | { |
|
117 | { | |
118 | if(this->plugin->baseAddress()!=-1) |
|
118 | if(this->plugin->baseAddress()!=-1) | |
119 | { |
|
119 | { | |
120 | unsigned int i=0x0FF & c; |
|
120 | unsigned int i=0x0FF & c; | |
121 | plugin->parent->Write(&i,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); |
|
121 | plugin->parent->Write(&i,1,this->plugin->baseAddress()+APB_UART_FIFO_DEBUG_REG); | |
122 | } |
|
122 | } | |
123 | } |
|
123 | } | |
124 | else |
|
124 | else | |
125 | { |
|
125 | { | |
126 | uartMutex->lock(); |
|
126 | uartMutex->lock(); | |
127 | rs232write(this->uart,&c,1); |
|
127 | rs232write(this->uart,&c,1); | |
128 | uartMutex->unlock(); |
|
128 | uartMutex->unlock(); | |
129 | } |
|
129 | } | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | bool UARTPollingThread::openUart() |
|
132 | bool UARTPollingThread::openUart() | |
133 | { |
|
133 | { | |
134 | uartMutex->lock(); |
|
134 | uartMutex->lock(); | |
135 | if(uartOpened) |
|
135 | if(uartOpened) | |
136 | { |
|
136 | { | |
137 | closeUart(); |
|
137 | closeUart(); | |
138 | } |
|
138 | } | |
139 | SocExplorerEngine::message(this->plugin,"Opening UART "+this->portName,3); |
|
139 | SocExplorerEngine::message(this->plugin,"Opening UART "+this->portName,3); | |
140 | this->uart = rs232open((char*)this->portName.toStdString().c_str()); |
|
140 | this->uart = rs232open((char*)this->portName.toStdString().c_str()); | |
141 | if(this->uart!=badPortValue) |
|
141 | if(this->uart!=badPortValue) | |
142 | { |
|
142 | { | |
143 | SocExplorerEngine::message(this->plugin,QString("Configuring UART, speed =%1").arg(this->uartSpeed),3); |
|
143 | SocExplorerEngine::message(this->plugin,QString("Configuring UART, speed =%1").arg(this->uartSpeed),3); | |
144 | rs232setup(this->uart,8,this->uartSpeed,rs232parityNo,rs232OneStop); |
|
144 | rs232setup(this->uart,8,this->uartSpeed,rs232parityNo,rs232OneStop); | |
145 | uartOpened = true; |
|
145 | uartOpened = true; | |
146 | } |
|
146 | } | |
147 | uartMutex->unlock(); |
|
147 | uartMutex->unlock(); | |
148 | return uartOpened; |
|
148 | return uartOpened; | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | void UARTPollingThread::closeUart() |
|
151 | void UARTPollingThread::closeUart() | |
152 | { |
|
152 | { | |
153 | uartMutex->lock(); |
|
153 | uartMutex->lock(); | |
154 | rs232close(this->uart); |
|
154 | rs232close(this->uart); | |
155 | uartOpened = false; |
|
155 | uartOpened = false; | |
156 | uartMutex->unlock(); |
|
156 | uartMutex->unlock(); | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void UARTPollingThread::setPortName(QString name) |
|
159 | void UARTPollingThread::setPortName(QString name) | |
160 | { |
|
160 | { | |
161 | SocExplorerEngine::message(this->plugin,"Changing UART port Name: "+name,3); |
|
161 | SocExplorerEngine::message(this->plugin,"Changing UART port Name: "+name,3); | |
162 | this->portName = name; |
|
162 | this->portName = name; | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | void UARTPollingThread::setPortSpeedStr(QString speed) |
|
165 | void UARTPollingThread::setPortSpeedStr(QString speed) | |
166 | { |
|
166 | { | |
167 | SocExplorerEngine::message(this->plugin,"Changing UART speed: "+speed,3); |
|
167 | SocExplorerEngine::message(this->plugin,"Changing UART speed: "+speed,3); | |
168 | this->uartSpeed = speed.toInt(); |
|
168 | this->uartSpeed = speed.toInt(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | void UARTPollingThread::setPortSpeed(int speed) |
|
171 | void UARTPollingThread::setPortSpeed(int speed) | |
172 | { |
|
172 | { | |
173 | SocExplorerEngine::message(this->plugin,QString("Changing UART speed: %1").arg(speed),3); |
|
173 | SocExplorerEngine::message(this->plugin,QString("Changing UART speed: %1").arg(speed),3); | |
174 | this->uartSpeed = speed; |
|
174 | this->uartSpeed = speed; | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | void UARTPollingThread::setFifoDebugEable(bool enable) |
|
177 | void UARTPollingThread::setFifoDebugEable(bool enable) | |
178 | { |
|
178 | { | |
179 | if(enable) |
|
179 | if(enable) | |
180 | SocExplorerEngine::message(this->plugin,"Enabling APB UART FIFO debug mode",3); |
|
180 | SocExplorerEngine::message(this->plugin,"Enabling APB UART FIFO debug mode",3); | |
181 | else |
|
181 | else | |
182 | SocExplorerEngine::message(this->plugin,"Disabling APB UART FIFO debug mode",3); |
|
182 | SocExplorerEngine::message(this->plugin,"Disabling APB UART FIFO debug mode",3); | |
183 | if(uartOpened && enable) |
|
183 | if(uartOpened && enable) | |
184 | { |
|
184 | { | |
185 | closeUart(); |
|
185 | closeUart(); | |
186 | } |
|
186 | } | |
187 | this->fifoDebugConfigured = false; |
|
187 | this->fifoDebugConfigured = false; | |
188 | configFifoDebug(enable); |
|
188 | configFifoDebug(enable); | |
189 | this->fifoDebugEnabled = enable; |
|
189 | this->p_fifoDebugEnabled = enable; | |
|
190 | } | |||
|
191 | ||||
|
192 | bool UARTPollingThread::fifoDebugEnabled() | |||
|
193 | { | |||
|
194 | return p_fifoDebugEnabled; | |||
190 | } |
|
195 | } | |
191 |
|
196 | |||
192 | void UARTPollingThread::configFifoDebug(bool enable) |
|
197 | void UARTPollingThread::configFifoDebug(bool enable) | |
193 | { |
|
198 | { | |
194 | SocExplorerEngine::message(this->plugin,"Configuring APB UART in FIFO debug mode",3); |
|
199 | SocExplorerEngine::message(this->plugin,"Configuring APB UART in FIFO debug mode",3); | |
195 | if(this->plugin->baseAddress()==-1) |
|
200 | if(this->plugin->baseAddress()==-1) | |
196 | { |
|
201 | { | |
197 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); |
|
202 | this->plugin->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this->plugin,this->plugin->VID(),this->plugin->PID(),0)); | |
198 | } |
|
203 | } | |
199 | if(this->plugin->baseAddress()!=-1) |
|
204 | if(this->plugin->baseAddress()!=-1) | |
200 | { |
|
205 | { | |
201 | if(enable) |
|
206 | if(enable) | |
202 | { |
|
207 | { | |
203 | unsigned int ctrl_reg= 0x843; |
|
208 | unsigned int ctrl_reg= 0x843; | |
204 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); |
|
209 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |
205 | this->fifoDebugConfigured = true; |
|
210 | this->fifoDebugConfigured = true; | |
206 | } |
|
211 | } | |
207 | else |
|
212 | else | |
208 | { |
|
213 | { | |
209 | unsigned int ctrl_reg; |
|
214 | unsigned int ctrl_reg; | |
210 | /* Firts get Control reg value*/ |
|
215 | /* Firts get Control reg value*/ | |
211 | this->plugin->parent->Read(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); |
|
216 | this->plugin->parent->Read(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |
212 | ctrl_reg = ctrl_reg & (~(1<<11)); |
|
217 | ctrl_reg = ctrl_reg & (~(1<<11)); | |
213 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); |
|
218 | this->plugin->parent->Write(&ctrl_reg,1,this->plugin->baseAddress()+APB_UART_CONTROL_REG); | |
214 | this->fifoDebugConfigured = true; |
|
219 | this->fifoDebugConfigured = true; | |
215 | } |
|
220 | } | |
216 | } |
|
221 | } | |
217 | } |
|
222 | } |
@@ -1,66 +1,67 | |||||
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> |
|
28 | #include <RS232.h> | |
29 | #include <QMutex> |
|
29 | #include <QMutex> | |
30 |
|
30 | |||
31 | #define APB_UART_DATA_REG 0x0 |
|
31 | #define APB_UART_DATA_REG 0x0 | |
32 | #define APB_UART_STATUS_REG 0x4 |
|
32 | #define APB_UART_STATUS_REG 0x4 | |
33 | #define APB_UART_CONTROL_REG 0x8 |
|
33 | #define APB_UART_CONTROL_REG 0x8 | |
34 | #define APB_UART_SCALE_REG 0xC |
|
34 | #define APB_UART_SCALE_REG 0xC | |
35 | #define APB_UART_FIFO_DEBUG_REG 0x10 |
|
35 | #define APB_UART_FIFO_DEBUG_REG 0x10 | |
36 |
|
36 | |||
37 | class UARTPollingThread : public QThread |
|
37 | class UARTPollingThread : public QThread | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | public: |
|
40 | public: | |
41 | explicit UARTPollingThread(socexplorerplugin *parent = 0); |
|
41 | explicit UARTPollingThread(socexplorerplugin *parent = 0); | |
42 | ~UARTPollingThread(); |
|
42 | ~UARTPollingThread(); | |
43 | void run(); |
|
43 | void run(); | |
44 | signals: |
|
44 | signals: | |
45 | void apbUartTextReceived(QString text); |
|
45 | void apbUartTextReceived(QString text); | |
46 | public slots: |
|
46 | public slots: | |
47 | void sendChar(char c); |
|
47 | void sendChar(char c); | |
48 | bool openUart(); |
|
48 | bool openUart(); | |
49 | void closeUart(); |
|
49 | void closeUart(); | |
50 | void setPortName(QString name); |
|
50 | void setPortName(QString name); | |
51 | void setPortSpeedStr(QString speed); |
|
51 | void setPortSpeedStr(QString speed); | |
52 | void setPortSpeed(int speed); |
|
52 | void setPortSpeed(int speed); | |
53 | void setFifoDebugEable(bool enable); |
|
53 | void setFifoDebugEable(bool enable); | |
|
54 | bool fifoDebugEnabled(); | |||
54 | private: |
|
55 | private: | |
55 | void configFifoDebug(bool enable); |
|
56 | void configFifoDebug(bool enable); | |
56 | bool fifoDebugEnabled; |
|
57 | bool p_fifoDebugEnabled; | |
57 | bool fifoDebugConfigured; |
|
58 | bool fifoDebugConfigured; | |
58 | QString portName; |
|
59 | QString portName; | |
59 | int uartSpeed; |
|
60 | int uartSpeed; | |
60 | bool uartOpened; |
|
61 | bool uartOpened; | |
61 | socexplorerplugin* plugin; |
|
62 | socexplorerplugin* plugin; | |
62 | rs232port_t uart; |
|
63 | rs232port_t uart; | |
63 | QMutex* uartMutex; |
|
64 | QMutex* uartMutex; | |
64 | }; |
|
65 | }; | |
65 |
|
66 | |||
66 | #endif // UARTPOLLINGTHREAD_H |
|
67 | #endif // UARTPOLLINGTHREAD_H |
@@ -1,492 +1,490 | |||||
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 | #include <socexplorerengine.h> |
|
22 | #include <socexplorerengine.h> | |
23 | #include "ahbuartplugin.h" |
|
23 | #include "ahbuartplugin.h" | |
24 | #include <unistd.h> |
|
24 | #include <unistd.h> | |
25 | #include <errno.h> |
|
25 | #include <errno.h> | |
26 | #include <QApplication> |
|
26 | #include <QApplication> | |
27 | #include <QProgressBar> |
|
27 | #include <QProgressBar> | |
28 | #include <stdio.h> |
|
28 | #include <stdio.h> | |
29 | #include <QThread> |
|
29 | #include <QThread> | |
30 | #include "ahbuartpywrapper.h" |
|
30 | #include "ahbuartpywrapper.h" | |
31 | #include <QCompleter> |
|
31 | #include <QCompleter> | |
32 | #include <QStringList> |
|
32 | #include <QStringList> | |
33 | #include <QLineEdit> |
|
33 | #include <QLineEdit> | |
34 | #include <socexplorerproxy.h> |
|
34 | #include <socexplorerproxy.h> | |
35 |
|
35 | |||
36 | ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
36 | ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false) | |
37 | { |
|
37 | { | |
38 | this->port =(rs232port_t)NULL; |
|
38 | this->port =(rs232port_t)NULL; | |
39 | this->portMutex = new QMutex(QMutex::Recursive); |
|
39 | this->portMutex = new QMutex(QMutex::Recursive); | |
40 | this->UI = new ahbUartPluginUI(); |
|
40 | this->UI = new ahbUartPluginUI(); | |
41 | this->setWidget((QWidget*)this->UI); |
|
41 | this->setWidget((QWidget*)this->UI); | |
42 | QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool))); |
|
42 | QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool))); | |
43 | QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int))); |
|
43 | QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int))); | |
44 | this->pyObject = new ahbuartPywrapper(this); |
|
44 | this->pyObject = new ahbuartPywrapper(this); | |
45 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int))); |
|
45 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int))); | |
46 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close())); |
|
46 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close())); | |
47 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint))); |
|
47 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint))); | |
48 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>))); |
|
48 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>))); | |
49 | QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList())); |
|
49 | QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList())); | |
50 | QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int))); |
|
50 | QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int))); | |
51 | QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int))); |
|
51 | QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int))); | |
52 | this->portListcompleter = NULL; |
|
52 | this->portListcompleter = NULL; | |
53 | this->scanDone = false; |
|
53 | this->scanDone = false; | |
54 | updatePortList(); |
|
54 | updatePortList(); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | ahbuartplugin::~ahbuartplugin() |
|
58 | ahbuartplugin::~ahbuartplugin() | |
59 | { |
|
59 | { | |
60 | if(this->port!=(rs232port_t)NULL) |
|
60 | if(this->port!=(rs232port_t)NULL) | |
61 | { |
|
61 | { | |
62 | rs232close(this->port); |
|
62 | rs232close(this->port); | |
63 | this->port = (rs232port_t)NULL; |
|
63 | this->port = (rs232port_t)NULL; | |
64 | } |
|
64 | } | |
65 | this->UI->close(); |
|
65 | this->UI->close(); | |
66 | this->UI->~ahbUartPluginUI(); |
|
66 | this->UI->~ahbUartPluginUI(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 |
|
69 | |||
70 | void ahbuartplugin::closeMe() |
|
70 | void ahbuartplugin::closeMe() | |
71 | { |
|
71 | { | |
72 | if(this->port!=(rs232port_t)NULL) |
|
72 | if(this->port!=(rs232port_t)NULL) | |
73 | { |
|
73 | { | |
74 | rs232close(this->port); |
|
74 | rs232close(this->port); | |
75 | this->port = (rs232port_t)NULL; |
|
75 | this->port = (rs232port_t)NULL; | |
76 | } |
|
76 | } | |
77 | emit this->closePlugin(this); |
|
77 | emit this->closePlugin(this); | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | int ahbuartplugin::registermenu(QMainWindow *menuHolder) |
|
80 | int ahbuartplugin::registermenu(QMainWindow *menuHolder) | |
81 | { |
|
81 | { | |
82 | this->menu = menuHolder->menuBar()->addMenu(tr("&AHB UART")); |
|
82 | this->menu = menuHolder->menuBar()->addMenu(tr("&AHB UART")); | |
83 | this->closeAction = this->menu->addAction(tr("Close plugin")); |
|
83 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
84 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); |
|
84 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
85 | return 1; |
|
85 | return 1; | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 |
|
88 | |||
89 |
|
||||
90 |
|
||||
91 | bool ahbuartplugin::checkConnection() |
|
89 | bool ahbuartplugin::checkConnection() | |
92 | { |
|
90 | { | |
93 | QTime timeout; |
|
91 | QTime timeout; | |
94 | char test[5] ={(char)0x80,(char)0x80,(char)0,(char)0,(char)0}; |
|
92 | char test[5] ={(char)0x80,(char)0x80,(char)0,(char)0,(char)0}; | |
95 | char test2[1024]; |
|
93 | char test2[1024]; | |
96 | int writen =0; |
|
94 | int writen =0; | |
97 | int read = 0; |
|
95 | int read = 0; | |
98 | timeout.start(); |
|
96 | timeout.start(); | |
99 | SocExplorerEngine::message(this,"Check connection",2); |
|
97 | SocExplorerEngine::message(this,"Check connection",2); | |
100 | QMutexLocker lock(portMutex); |
|
98 | QMutexLocker lock(portMutex); | |
101 | while(writen!=5) |
|
99 | while(writen!=5) | |
102 | { |
|
100 | { | |
103 | writen+=rs232write(this->port,test+writen,5-writen); |
|
101 | writen+=rs232write(this->port,test+writen,5-writen); | |
104 | if(timeout.elapsed()>1000) |
|
102 | if(timeout.elapsed()>1000) | |
105 | { |
|
103 | { | |
106 | SocExplorerEngine::message(this,"Can't write any data on serial port",2); |
|
104 | SocExplorerEngine::message(this,"Can't write any data on serial port",2); | |
107 | return false; |
|
105 | return false; | |
108 | } |
|
106 | } | |
109 | } |
|
107 | } | |
110 | #ifdef WIN32 |
|
108 | #ifdef WIN32 | |
111 | usleep(1000); |
|
109 | usleep(1000); | |
112 | #endif |
|
110 | #endif | |
113 | timeout.restart(); |
|
111 | timeout.restart(); | |
114 | int avail = 0; |
|
112 | int avail = 0; | |
115 | do |
|
113 | do | |
116 | { |
|
114 | { | |
117 | avail = rs232availablebytes(this->port); |
|
115 | avail = rs232availablebytes(this->port); | |
118 | if(timeout.elapsed()>1000) |
|
116 | if(timeout.elapsed()>1000) | |
119 | { |
|
117 | { | |
120 | if(avail) |
|
118 | if(avail) | |
121 | rs232read(this->port,test2,avail); |
|
119 | rs232read(this->port,test2,avail); | |
122 | SocExplorerEngine::message(this,"Connection Error",2); |
|
120 | SocExplorerEngine::message(this,"Connection Error",2); | |
123 | return false; |
|
121 | return false; | |
124 | } |
|
122 | } | |
125 | }while(avail<4); |
|
123 | }while(avail<4); | |
126 | read = rs232read(this->port,test2,avail); |
|
124 | read = rs232read(this->port,test2,avail); | |
127 | if(read>0) |
|
125 | if(read>0) | |
128 | { |
|
126 | { | |
129 | SocExplorerEngine::message(this,"Connection Ok",2); |
|
127 | SocExplorerEngine::message(this,"Connection Ok",2); | |
130 | return true; |
|
128 | return true; | |
131 | } |
|
129 | } | |
132 | else |
|
130 | else | |
133 | { |
|
131 | { | |
134 | SocExplorerEngine::message(this,"Connection Error",2); |
|
132 | SocExplorerEngine::message(this,"Connection Error",2); | |
135 | return false; |
|
133 | return false; | |
136 | } |
|
134 | } | |
137 | } |
|
135 | } | |
138 |
|
136 | |||
139 | void ahbuartplugin::connectPort(QString PortName, int baudrate) |
|
137 | void ahbuartplugin::connectPort(QString PortName, int baudrate) | |
140 | { |
|
138 | { | |
141 | QTime timeout; |
|
139 | QTime timeout; | |
142 | SocExplorerEngine::message(this,"Try to connect to port "+PortName,2); |
|
140 | SocExplorerEngine::message(this,"Try to connect to port "+PortName,2); | |
143 | timeout.start(); |
|
141 | timeout.start(); | |
144 | QMutexLocker lock(portMutex); |
|
142 | QMutexLocker lock(portMutex); | |
145 | if(this->port==(rs232port_t)NULL) |
|
143 | if(this->port==(rs232port_t)NULL) | |
146 | { |
|
144 | { | |
147 | SocExplorerEngine::message(this,"Open port "+PortName,2); |
|
145 | SocExplorerEngine::message(this,"Open port "+PortName,2); | |
148 | this->port=rs232open((char*)PortName.toStdString().c_str()); |
|
146 | this->port=rs232open((char*)PortName.toStdString().c_str()); | |
149 | } |
|
147 | } | |
150 | if(this->port!=badPortValue) |
|
148 | if(this->port!=badPortValue) | |
151 | { |
|
149 | { | |
152 | SocExplorerEngine::message(this,"Port opened "+PortName,2); |
|
150 | SocExplorerEngine::message(this,"Port opened "+PortName,2); | |
153 | SocExplorerEngine::message(this,"Configure port "+PortName,2); |
|
151 | SocExplorerEngine::message(this,"Configure port "+PortName,2); | |
154 | rs232setup(this->port,8,baudrate,rs232parityNo,rs232OneStop); |
|
152 | rs232setup(this->port,8,baudrate,rs232parityNo,rs232OneStop); | |
155 | char test[7] ={(char)0x55,(char)0x51,(char)0x80,(char)0x80,(char)0x0,(char)0x0,(char)0x14}; |
|
153 | char test[7] ={(char)0x55,(char)0x51,(char)0x80,(char)0x80,(char)0x0,(char)0x0,(char)0x14}; | |
156 | char test2[1024]; |
|
154 | char test2[1024]; | |
157 | SAFEWRITE(test,1,timeout,2000,return); |
|
155 | SAFEWRITE(test,1,timeout,2000,return); | |
158 | SAFEWRITE((test+1),1,timeout,2000,return); |
|
156 | SAFEWRITE((test+1),1,timeout,2000,return); | |
159 | rs232read(this->port,test2,512); |
|
157 | rs232read(this->port,test2,512); | |
160 | int read = 0; |
|
158 | int read = 0; | |
161 | for(int i=0;i<10;i++) |
|
159 | for(int i=0;i<10;i++) | |
162 | { |
|
160 | { | |
163 | SocExplorerEngine::message(this,"Send test patern :0x55,0x55,0x80,0x80,0x0,0x0,0x14",2); |
|
161 | SocExplorerEngine::message(this,"Send test patern :0x55,0x55,0x80,0x80,0x0,0x0,0x14",2); | |
164 | SAFEWRITE(test+2,5,timeout,2000,return); |
|
162 | SAFEWRITE(test+2,5,timeout,2000,return); | |
165 | SocExplorerEngine::message(this,"Read Result",2); |
|
163 | SocExplorerEngine::message(this,"Read Result",2); | |
166 | read=rs232read(this->port,test2+read,16); |
|
164 | read=rs232read(this->port,test2+read,16); | |
167 | SocExplorerEngine::message(this,QString("Get ") + QString::number(read) + " bytes",2); |
|
165 | SocExplorerEngine::message(this,QString("Get ") + QString::number(read) + " bytes",2); | |
168 | if(read>0) |
|
166 | if(read>0) | |
169 | { |
|
167 | { | |
170 | SocExplorerEngine::message(this,"Flush port ",2); |
|
168 | SocExplorerEngine::message(this,"Flush port ",2); | |
171 | while(rs232read(this->port,test2,1)>0); |
|
169 | while(rs232read(this->port,test2,1)>0); | |
172 | this->Connected = true; |
|
170 | this->Connected = true; | |
173 | SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2); |
|
171 | SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2); | |
174 | emit this->activate(true); |
|
172 | emit this->activate(true); | |
175 | if(this->scanDone==false) |
|
173 | if(this->scanDone==false) | |
176 | { |
|
174 | { | |
177 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
175 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
178 | this->scanDone=true; |
|
176 | this->scanDone=true; | |
179 | } |
|
177 | } | |
180 | break; |
|
178 | break; | |
181 | } |
|
179 | } | |
182 | } |
|
180 | } | |
183 | } |
|
181 | } | |
184 | else |
|
182 | else | |
185 | { |
|
183 | { | |
186 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); |
|
184 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); | |
187 | this->port = (rs232port_t)NULL; |
|
185 | this->port = (rs232port_t)NULL; | |
188 | this->Connected = false; |
|
186 | this->Connected = false; | |
189 | emit this->activateSig(false); |
|
187 | emit this->activateSig(false); | |
190 | return; |
|
188 | return; | |
191 | } |
|
189 | } | |
192 | if(this->Connected == false) |
|
190 | if(this->Connected == false) | |
193 | { |
|
191 | { | |
194 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); |
|
192 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); | |
195 | rs232close(this->port); |
|
193 | rs232close(this->port); | |
196 | this->port = (rs232port_t)NULL; |
|
194 | this->port = (rs232port_t)NULL; | |
197 | emit this->activateSig(false); |
|
195 | emit this->activateSig(false); | |
198 | } |
|
196 | } | |
199 |
|
197 | |||
200 | } |
|
198 | } | |
201 |
|
199 | |||
202 | bool ahbuartplugin::open(QString PortName,int baudrate) |
|
200 | bool ahbuartplugin::open(QString PortName,int baudrate) | |
203 | { |
|
201 | { | |
204 | if(this->port!=(rs232port_t)NULL) |
|
202 | if(this->port!=(rs232port_t)NULL) | |
205 | this->close(); |
|
203 | this->close(); | |
206 | this->UI->setconfig(PortName,baudrate); |
|
204 | this->UI->setconfig(PortName,baudrate); | |
207 | this->connectPort(PortName,baudrate); |
|
205 | this->connectPort(PortName,baudrate); | |
208 | return (this->port!=(rs232port_t)NULL); |
|
206 | return (this->port!=(rs232port_t)NULL); | |
209 | } |
|
207 | } | |
210 |
|
208 | |||
211 | void ahbuartplugin::close() |
|
209 | void ahbuartplugin::close() | |
212 | { |
|
210 | { | |
213 | if(this->port!=(rs232port_t)NULL) |
|
211 | if(this->port!=(rs232port_t)NULL) | |
214 | { |
|
212 | { | |
215 | rs232close(this->port); |
|
213 | rs232close(this->port); | |
216 | this->port = (rs232port_t)NULL; |
|
214 | this->port = (rs232port_t)NULL; | |
217 | this->Connected = false; |
|
215 | this->Connected = false; | |
218 | emit this->activateSig(false); |
|
216 | emit this->activateSig(false); | |
219 | } |
|
217 | } | |
220 | } |
|
218 | } | |
221 |
|
219 | |||
222 | void ahbuartplugin::togglePort(QString PortName,int baudrate) |
|
220 | void ahbuartplugin::togglePort(QString PortName,int baudrate) | |
223 | { |
|
221 | { | |
224 | if(this->port!=(rs232port_t)NULL) |
|
222 | if(this->port!=(rs232port_t)NULL) | |
225 | { |
|
223 | { | |
226 | this->close(); |
|
224 | this->close(); | |
227 | } |
|
225 | } | |
228 | else |
|
226 | else | |
229 | { |
|
227 | { | |
230 | this->connectPort(PortName,baudrate); |
|
228 | this->connectPort(PortName,baudrate); | |
231 | } |
|
229 | } | |
232 | } |
|
230 | } | |
233 |
|
231 | |||
234 |
|
232 | |||
235 | unsigned int ahbuartplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
233 | unsigned int ahbuartplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
236 | { |
|
234 | { | |
237 | QTime timeout; |
|
235 | QTime timeout; | |
238 | timeout.start(); |
|
236 | timeout.start(); | |
239 | unsigned int read=0; |
|
237 | unsigned int read=0; | |
240 | unsigned int cnt=count; |
|
238 | unsigned int cnt=count; | |
241 | unsigned int nextUpdateTrig=0,updateStep=512; |
|
239 | unsigned int nextUpdateTrig=0,updateStep=512; | |
242 | SocExplorerEngine::message(this,QString("Read ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); |
|
240 | SocExplorerEngine::message(this,QString("Read ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); | |
243 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) |
|
241 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) | |
244 | { |
|
242 | { | |
245 | QMutexLocker lock(portMutex); |
|
243 | QMutexLocker lock(portMutex); | |
246 | if(!this->checkConnection()) |
|
244 | if(!this->checkConnection()) | |
247 | { |
|
245 | { | |
248 | this->Connected = false; |
|
246 | this->Connected = false; | |
249 | emit this->activateSig(false); |
|
247 | emit this->activateSig(false); | |
250 | this->portMutex->unlock(); |
|
248 | this->portMutex->unlock(); | |
251 | return 0; |
|
249 | return 0; | |
252 | } |
|
250 | } | |
253 | QProgressBar* progress=NULL; |
|
251 | QProgressBar* progress=NULL; | |
254 | if(cnt>128) |
|
252 | if(cnt>128) | |
255 | progress= SocExplorerEngine::getProgressBar("Reading on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
253 | progress= SocExplorerEngine::getProgressBar("Reading on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
256 | char CMD[5]; |
|
254 | char CMD[5]; | |
257 | char* result = (char*)malloc(count*4); |
|
255 | char* result = (char*)malloc(count*4); | |
258 | while(count>32) |
|
256 | while(count>32) | |
259 | { |
|
257 | { | |
260 | CMD[0] = 0x80 | (32-1); |
|
258 | CMD[0] = 0x80 | (32-1); | |
261 | CMD[1] = (char)((address>>24)&0xFF); |
|
259 | CMD[1] = (char)((address>>24)&0xFF); | |
262 | CMD[2] = (char)((address>>16)&0xFF); |
|
260 | CMD[2] = (char)((address>>16)&0xFF); | |
263 | CMD[3] = (char)((address>>8)&0xFF); |
|
261 | CMD[3] = (char)((address>>8)&0xFF); | |
264 | CMD[4] = (char)((address)&0xFF); |
|
262 | CMD[4] = (char)((address)&0xFF); | |
265 | SAFEWRITE(CMD,5,timeout,1000,return 0); |
|
263 | SAFEWRITE(CMD,5,timeout,1000,return 0); | |
266 | timeout.restart(); |
|
264 | timeout.restart(); | |
267 | int avail=0; |
|
265 | int avail=0; | |
268 | do{ |
|
266 | do{ | |
269 | avail=rs232availablebytes(this->port); |
|
267 | avail=rs232availablebytes(this->port); | |
270 | if(timeout.elapsed()>1000) |
|
268 | if(timeout.elapsed()>1000) | |
271 | { |
|
269 | { | |
272 | rs232close(this->port); |
|
270 | rs232close(this->port); | |
273 | this->port = (rs232port_t)NULL; |
|
271 | this->port = (rs232port_t)NULL; | |
274 | this->Connected = false; |
|
272 | this->Connected = false; | |
275 | emit this->activateSig(false); |
|
273 | emit this->activateSig(false); | |
276 | return 0; |
|
274 | return 0; | |
277 | } |
|
275 | } | |
278 | }while(avail<(32*4)); |
|
276 | }while(avail<(32*4)); | |
279 | rs232read(this->port,result+((cnt-count)*4),32*4); |
|
277 | rs232read(this->port,result+((cnt-count)*4),32*4); | |
280 | count-=32; |
|
278 | count-=32; | |
281 | address+=32*4; |
|
279 | address+=32*4; | |
282 | if(cnt>128) |
|
280 | if(cnt>128) | |
283 | { |
|
281 | { | |
284 |
|
282 | |||
285 | if((cnt-count)>=nextUpdateTrig) |
|
283 | if((cnt-count)>=nextUpdateTrig) | |
286 | { |
|
284 | { | |
287 | progress->setValue(cnt-count); |
|
285 | progress->setValue(cnt-count); | |
288 | qApp->processEvents(); |
|
286 | qApp->processEvents(); | |
289 | nextUpdateTrig+=updateStep; |
|
287 | nextUpdateTrig+=updateStep; | |
290 | } |
|
288 | } | |
291 | } |
|
289 | } | |
292 | } |
|
290 | } | |
293 | if(count>0) |
|
291 | if(count>0) | |
294 | { |
|
292 | { | |
295 | CMD[0] = 0x80 | (count-1); |
|
293 | CMD[0] = 0x80 | (count-1); | |
296 | CMD[1] = (char)((address>>24)&0xFF); |
|
294 | CMD[1] = (char)((address>>24)&0xFF); | |
297 | CMD[2] = (char)((address>>16)&0xFF); |
|
295 | CMD[2] = (char)((address>>16)&0xFF); | |
298 | CMD[3] = (char)((address>>8)&0xFF); |
|
296 | CMD[3] = (char)((address>>8)&0xFF); | |
299 | CMD[4] = (char)((address)&0xFF); |
|
297 | CMD[4] = (char)((address)&0xFF); | |
300 | SAFEWRITE(CMD,5,timeout,1000,return 0); |
|
298 | SAFEWRITE(CMD,5,timeout,1000,return 0); | |
301 | timeout.restart(); |
|
299 | timeout.restart(); | |
302 | int avail=0; |
|
300 | int avail=0; | |
303 | do{ |
|
301 | do{ | |
304 | avail=rs232availablebytes(this->port); |
|
302 | avail=rs232availablebytes(this->port); | |
305 | if(timeout.elapsed()>1000) |
|
303 | if(timeout.elapsed()>1000) | |
306 | { |
|
304 | { | |
307 | rs232close(this->port); |
|
305 | rs232close(this->port); | |
308 | this->port = (rs232port_t)NULL; |
|
306 | this->port = (rs232port_t)NULL; | |
309 | this->Connected = false; |
|
307 | this->Connected = false; | |
310 | emit this->activateSig(false); |
|
308 | emit this->activateSig(false); | |
311 | return 0; |
|
309 | return 0; | |
312 | } |
|
310 | } | |
313 | }while(avail<(count*4)); |
|
311 | }while(avail<(count*4)); | |
314 | rs232read(this->port,result+((cnt-count)*4),count*4); |
|
312 | rs232read(this->port,result+((cnt-count)*4),count*4); | |
315 | } |
|
313 | } | |
316 | if(cnt>128) |
|
314 | if(cnt>128) | |
317 | { |
|
315 | { | |
318 | progress->setValue(cnt-count); |
|
316 | progress->setValue(cnt-count); | |
319 | qApp->processEvents(); |
|
317 | qApp->processEvents(); | |
320 | } |
|
318 | } | |
321 | for(int i=0;(unsigned int)i<cnt;i++) |
|
319 | for(int i=0;(unsigned int)i<cnt;i++) | |
322 | { |
|
320 | { | |
323 | for(int j =0;j<4;j++) |
|
321 | for(int j =0;j<4;j++) | |
324 | { |
|
322 | { | |
325 | Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256; |
|
323 | Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256; | |
326 | } |
|
324 | } | |
327 | read = cnt*4; |
|
325 | read = cnt*4; | |
328 |
|
326 | |||
329 | } |
|
327 | } | |
330 | if(cnt>128) |
|
328 | if(cnt>128) | |
331 | SocExplorerEngine::deleteProgressBar(progress); |
|
329 | SocExplorerEngine::deleteProgressBar(progress); | |
332 | free(result); |
|
330 | free(result); | |
333 | } |
|
331 | } | |
334 | emit this->addReadBytes(read); |
|
332 | emit this->addReadBytes(read); | |
335 | return read/4; |
|
333 | return read/4; | |
336 | } |
|
334 | } | |
337 |
|
335 | |||
338 | unsigned int ahbuartplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
336 | unsigned int ahbuartplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
339 | { |
|
337 | { | |
340 | QTime timeout; |
|
338 | QTime timeout; | |
341 | timeout.start(); |
|
339 | timeout.start(); | |
342 | unsigned int writen=0; |
|
340 | unsigned int writen=0; | |
343 | unsigned int nextUpdateTrig=0,updateStep=512; |
|
341 | unsigned int nextUpdateTrig=0,updateStep=512; | |
344 | SocExplorerEngine::message(this,QString("Write ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); |
|
342 | SocExplorerEngine::message(this,QString("Write ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); | |
345 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) |
|
343 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) | |
346 | { |
|
344 | { | |
347 | QMutexLocker lock(portMutex); |
|
345 | QMutexLocker lock(portMutex); | |
348 | if(!this->checkConnection()) |
|
346 | if(!this->checkConnection()) | |
349 | { |
|
347 | { | |
350 | emit this->activateSig(false); |
|
348 | emit this->activateSig(false); | |
351 | this->Connected = false; |
|
349 | this->Connected = false; | |
352 | this->portMutex->unlock(); |
|
350 | this->portMutex->unlock(); | |
353 | return 0; |
|
351 | return 0; | |
354 | } |
|
352 | } | |
355 | QProgressBar* progress = NULL; |
|
353 | QProgressBar* progress = NULL; | |
356 | if(count>128) |
|
354 | if(count>128) | |
357 | progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
355 | progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
358 | int offset = 0; |
|
356 | int offset = 0; | |
359 | char* CMD= (char*)malloc((32*4)+5); |
|
357 | char* CMD= (char*)malloc((32*4)+5); | |
|
358 | writen=0; | |||
360 | while(count>32) |
|
359 | while(count>32) | |
361 | { |
|
360 | { | |
362 | writen=0; |
|
|||
363 | CMD[0] = 0xC0 | (32-1); |
|
361 | CMD[0] = 0xC0 | (32-1); | |
364 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); |
|
362 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); | |
365 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); |
|
363 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); | |
366 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); |
|
364 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); | |
367 | CMD[4] = (char)(((unsigned int)address)&0xFF); |
|
365 | CMD[4] = (char)(((unsigned int)address)&0xFF); | |
368 | for(int i=0;i<32;i++) |
|
366 | for(int i=0;i<32;i++) | |
369 | { |
|
367 | { | |
370 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); |
|
368 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); | |
371 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); |
|
369 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); | |
372 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); |
|
370 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); | |
373 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); |
|
371 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); | |
374 | } |
|
372 | } | |
375 | SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0); |
|
373 | SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0); | |
376 | writen+=32; |
|
374 | writen+=32; | |
377 | count-=32; |
|
375 | count-=32; | |
378 | offset+=32; |
|
376 | offset+=32; | |
379 | address+=32*4; |
|
377 | address+=32*4; | |
380 | if(offset>=nextUpdateTrig && progress!=NULL) |
|
378 | if(offset>=nextUpdateTrig && progress!=NULL) | |
381 | { |
|
379 | { | |
382 | progress->setValue(offset); |
|
380 | progress->setValue(offset); | |
383 | qApp->processEvents(); |
|
381 | qApp->processEvents(); | |
384 | nextUpdateTrig +=updateStep; |
|
382 | nextUpdateTrig +=updateStep; | |
385 | } |
|
383 | } | |
386 |
|
384 | |||
387 | } |
|
385 | } | |
388 | if(count>0) |
|
386 | if(count>0) | |
389 | { |
|
387 | { | |
390 | CMD[0] = 0xC0 | (count-1); |
|
388 | CMD[0] = 0xC0 | (count-1); | |
391 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); |
|
389 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); | |
392 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); |
|
390 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); | |
393 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); |
|
391 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); | |
394 | CMD[4] = (char)(((unsigned int)address)&0xFF); |
|
392 | CMD[4] = (char)(((unsigned int)address)&0xFF); | |
395 | for(int i=0;(unsigned int) i<(count);i++) |
|
393 | for(int i=0;(unsigned int) i<(count);i++) | |
396 | { |
|
394 | { | |
397 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); |
|
395 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); | |
398 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); |
|
396 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); | |
399 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); |
|
397 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); | |
400 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); |
|
398 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); | |
401 | } |
|
399 | } | |
402 | SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0); |
|
400 | SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0); | |
403 | writen+=count; |
|
401 | writen+=count; | |
404 | } |
|
402 | } | |
405 | if(progress!=NULL) |
|
403 | if(progress!=NULL) | |
406 | { |
|
404 | { | |
407 | progress->setValue(writen); |
|
405 | progress->setValue(writen); | |
408 | qApp->processEvents(); |
|
406 | qApp->processEvents(); | |
409 | SocExplorerEngine::deleteProgressBar(progress); |
|
407 | SocExplorerEngine::deleteProgressBar(progress); | |
410 | } |
|
408 | } | |
411 | free(CMD); |
|
409 | free(CMD); | |
412 | emit this->addWritenBytes(writen); |
|
410 | emit this->addWritenBytes(writen*4); | |
413 | return writen; |
|
411 | return writen; | |
414 | } |
|
412 | } | |
415 | return 0; |
|
413 | return 0; | |
416 | } |
|
414 | } | |
417 |
|
415 | |||
418 |
|
416 | |||
419 |
|
417 | |||
420 |
|
418 | |||
421 | void ahbuartplugin::updatePortList() |
|
419 | void ahbuartplugin::updatePortList() | |
422 | { |
|
420 | { | |
423 | if(this->portListcompleter==(QCompleter*)NULL) |
|
421 | if(this->portListcompleter==(QCompleter*)NULL) | |
424 | { |
|
422 | { | |
425 | this->portListcompleter=new QCompleter(this); |
|
423 | this->portListcompleter=new QCompleter(this); | |
426 | this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); |
|
424 | this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); | |
427 | this->portListcompleterModel = new QStringListModel(this); |
|
425 | this->portListcompleterModel = new QStringListModel(this); | |
428 | this->portListcompleter->setModel(this->portListcompleterModel); |
|
426 | this->portListcompleter->setModel(this->portListcompleterModel); | |
429 | this->UI->setCompleter(this->portListcompleter); |
|
427 | this->UI->setCompleter(this->portListcompleter); | |
430 | } |
|
428 | } | |
431 | rs232portslist_t* portlist = rs232getportlist(); |
|
429 | rs232portslist_t* portlist = rs232getportlist(); | |
432 | rs232portslist_t* portlistenum = portlist; |
|
430 | rs232portslist_t* portlistenum = portlist; | |
433 | QStringList wordList; |
|
431 | QStringList wordList; | |
434 | while(portlistenum!=NULL) |
|
432 | while(portlistenum!=NULL) | |
435 | { |
|
433 | { | |
436 | wordList << portlistenum->name; |
|
434 | wordList << portlistenum->name; | |
437 | portlistenum = portlistenum->next; |
|
435 | portlistenum = portlistenum->next; | |
438 | } |
|
436 | } | |
439 | rs232deleteportlist(portlist); |
|
437 | rs232deleteportlist(portlist); | |
440 | this->portListcompleterModel->setStringList(wordList); |
|
438 | this->portListcompleterModel->setStringList(wordList); | |
441 | } |
|
439 | } | |
442 |
|
440 | |||
443 | QVariantList ahbuartplugin::ReadBytes(unsigned int address, unsigned int count) |
|
441 | QVariantList ahbuartplugin::ReadBytes(unsigned int address, unsigned int count) | |
444 | { |
|
442 | { | |
445 | unsigned int data[(count/4)+1]; |
|
443 | unsigned int data[(count/4)+1]; | |
446 | QVariantList result; |
|
444 | QVariantList result; | |
447 | this->Read(data,(count/4)+1,address); |
|
445 | this->Read(data,(count/4)+1,address); | |
448 | for(unsigned int i = 0;i<count/4;i++) |
|
446 | for(unsigned int i = 0;i<count/4;i++) | |
449 | { |
|
447 | { | |
450 | result.append(QVariant((int)(0x0FF&(data[i]>>24)))); |
|
448 | result.append(QVariant((int)(0x0FF&(data[i]>>24)))); | |
451 | result.append(QVariant((int)(0x0FF&(data[i]>>16)))); |
|
449 | result.append(QVariant((int)(0x0FF&(data[i]>>16)))); | |
452 | result.append(QVariant((int)(0x0FF&(data[i]>>8)))); |
|
450 | result.append(QVariant((int)(0x0FF&(data[i]>>8)))); | |
453 | result.append(QVariant((int)(0x0FF&(data[i])))); |
|
451 | result.append(QVariant((int)(0x0FF&(data[i])))); | |
454 | } |
|
452 | } | |
455 |
|
453 | |||
456 | for(int i=0;i<(count%4);i++) |
|
454 | for(int i=0;i<(count%4);i++) | |
457 | { |
|
455 | { | |
458 | result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8))))); |
|
456 | result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8))))); | |
459 | } |
|
457 | } | |
460 |
|
458 | |||
461 | return result; |
|
459 | return result; | |
462 | } |
|
460 | } | |
463 |
|
461 | |||
464 | void ahbuartplugin::WriteBytes(unsigned int address, QList<QVariant> dataList) |
|
462 | void ahbuartplugin::WriteBytes(unsigned int address, QList<QVariant> dataList) | |
465 | { |
|
463 | { | |
466 | unsigned int data[dataList.count()/4]; |
|
464 | unsigned int data[dataList.count()/4]; | |
467 | for(int i = 0;i<(dataList.count()/4);i++) |
|
465 | for(int i = 0;i<(dataList.count()/4);i++) | |
468 | { |
|
466 | { | |
469 | data[i] = 0x0FF & ((unsigned int)dataList.at(4*i).toUInt()); |
|
467 | data[i] = 0x0FF & ((unsigned int)dataList.at(4*i).toUInt()); | |
470 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+1).toUInt())); |
|
468 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+1).toUInt())); | |
471 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+2).toUInt())); |
|
469 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+2).toUInt())); | |
472 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+3).toUInt())); |
|
470 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+3).toUInt())); | |
473 | } |
|
471 | } | |
474 | this->Write(data,dataList.count()/4,address); |
|
472 | this->Write(data,dataList.count()/4,address); | |
475 | } |
|
473 | } | |
476 |
|
474 | |||
477 |
|
475 | |||
478 |
|
476 | |||
479 |
|
477 | |||
480 |
|
478 | |||
481 |
|
479 | |||
482 |
|
480 | |||
483 |
|
481 | |||
484 |
|
482 | |||
485 |
|
483 | |||
486 |
|
484 | |||
487 |
|
485 | |||
488 |
|
486 | |||
489 |
|
487 | |||
490 |
|
488 | |||
491 |
|
489 | |||
492 |
|
490 |
@@ -1,23 +1,25 | |||||
1 | #ifndef AHBUARTPYWRAPPER_H |
|
1 | #ifndef AHBUARTPYWRAPPER_H | |
2 | #define AHBUARTPYWRAPPER_H |
|
2 | #define AHBUARTPYWRAPPER_H | |
|
3 | #include <socexplorerplugin.h> | |||
3 | #include <genericPySysdriver.h> |
|
4 | #include <genericPySysdriver.h> | |
4 | #include <QString> |
|
5 | #include <QString> | |
|
6 | #include <qobject.h> | |||
5 |
|
7 | |||
6 | class ahbuartPywrapper : public genericPySysdriver |
|
8 | class ahbuartPywrapper : public genericPySysdriver | |
7 | { |
|
9 | { | |
8 | Q_OBJECT |
|
10 | Q_OBJECT | |
9 | public: |
|
11 | public: | |
10 | explicit ahbuartPywrapper(socexplorerplugin *parent = 0); |
|
12 | explicit ahbuartPywrapper(socexplorerplugin *parent = 0); | |
11 |
|
13 | |||
12 | signals: |
|
14 | signals: | |
13 | bool open(QString PortName,int baudrate); |
|
15 | bool open(QString PortName,int baudrate); | |
14 | void close(); |
|
16 | void close(); | |
15 | QVariantList ReadBytes(unsigned int address,unsigned int count); |
|
17 | QVariantList ReadBytes(unsigned int address,unsigned int count); | |
16 | void WriteBytes(unsigned int address,QList<QVariant> dataList); |
|
18 | void WriteBytes(unsigned int address,QList<QVariant> dataList); | |
17 | public slots: |
|
19 | public slots: | |
18 | // bool dumpMemory(unsigned int address,unsigned int count,QString file); |
|
20 | // bool dumpMemory(unsigned int address,unsigned int count,QString file); | |
19 | // bool memSet(unsigned int address,int value, unsigned int count); |
|
21 | // bool memSet(unsigned int address,int value, unsigned int count); | |
20 | // bool loadbin(unsigned int address,QString file); |
|
22 | // bool loadbin(unsigned int address,QString file); | |
21 | }; |
|
23 | }; | |
22 |
|
24 | |||
23 | #endif // AHBUARTPYWRAPPER_H |
|
25 | #endif // AHBUARTPYWRAPPER_H |
General Comments 0
You need to be logged in to leave comments.
Login now