##// END OF EJS Templates
Removed deprecated genericPySysdriver interface.
jeandet -
r52:c8f8e77e323c default
parent child
Show More
@@ -1,177 +1,177
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "APBUARTPLUGIN.h"
23 23 #include <socexplorerengine.h>
24 24 #include <apbuartpywrapper.h>
25 25
26 26 ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent,false)
27 27 {
28 28 this->setBaseAddress(-1);
29 29 this->p_curentAPBUart = 0;
30 30 this->UI = new APBUART_Plugin_ui();
31 31 this->setWidget((QWidget*)this->UI);
32 32 this->uartConnected = false;
33 33 this->UartThread = new UARTPollingThread(this);
34 this->pyObject = new APBUartPyWrapper(this);
34 // this->pyObject = new APBUartPyWrapper(this);
35 35 connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(fifoDebugChangeState(int)));
36 36 connect(this->UartThread,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString)));
37 37 connect(this->UI,SIGNAL(connectPort()),this,SLOT(toggleUartState()));
38 38 connect(this->UI,SIGNAL(sendChar(char)),this->UartThread,SLOT(sendChar(char)));
39 39 connect(this->UI,SIGNAL(PortNameChanged(QString)),this->UartThread,SLOT(setPortName(QString)));
40 40 connect(this->UI,SIGNAL(UartSpeedChanged(QString)),this->UartThread,SLOT(setPortSpeedStr(QString)));
41 41 connect(this->UI,SIGNAL(updateAPBUartsList()),this,SLOT(updateAPBUartsList()));
42 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()));
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()));
49 49 this->UartThread->start();
50 50 }
51 51
52 52
53 53 ApbUartPlugin::~ApbUartPlugin()
54 54 {
55 55
56 56 }
57 57
58 58 int ApbUartPlugin::curentAPBUart()
59 59 {
60 60 return p_curentAPBUart;
61 61 }
62 62
63 63 void ApbUartPlugin::closeMe()
64 64 {
65 65 emit this->closePlugin(this);
66 66 }
67 67
68 68 void ApbUartPlugin::toggleUartState()
69 69 {
70 70 if(!uartConnected)
71 71 {
72 72 this->openUart();
73 73 }
74 74 else
75 75 {
76 76 this->closeUart();
77 77 }
78 78 }
79 79
80 80 void ApbUartPlugin::activate(bool flag)
81 81 {
82 82 socexplorerplugin::activate(flag);
83 83 this->updateAPBUartsList();
84 84 }
85 85
86 86 void ApbUartPlugin::updateAPBUartsList()
87 87 {
88 88 QList<unsigned int> addresses;
89 89 int count = SocExplorerEngine::self()->getEnumDeviceCount(this,this->VID(),this->PID());
90 90 for(int i=0;i<count;i++)
91 91 {
92 92 addresses.append(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),i));
93 93 }
94 94 this->UI->updateAPBUartList(addresses);
95 95 }
96 96
97 97 void ApbUartPlugin::setCurentAPBUart(int index)
98 98 {
99 99 this->p_curentAPBUart = index;
100 100 this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),index));
101 101 }
102 102
103 103 void ApbUartPlugin::openUart()
104 104 {
105 105 if(this->UartThread->fifoDebugEnabled())
106 106 setFifoDebugEnabled(false);
107 107 if(!uartConnected)
108 108 uartConnected = this->UartThread->openUart();
109 109 this->UI->setUartConnected(uartConnected);
110 110 }
111 111
112 112 void ApbUartPlugin::closeUart()
113 113 {
114 114 if(uartConnected)
115 115 this->UartThread->closeUart();
116 116 this->uartConnected = false;
117 117 this->UI->setUartConnected(uartConnected);
118 118 }
119 119
120 120 void ApbUartPlugin::setFifoDebugEnabled(bool enable)
121 121 {
122 122 if(uartConnected)
123 123 closeUart();
124 124 this->UI->setEnableForLoopBack(!enable);
125 125 this->UartThread->setFifoDebugEable(enable);
126 126 }
127 127
128 128 void ApbUartPlugin::setAPBUartIndex(int index)
129 129 {
130 130 this->UI->setAPBUartIndex(index);
131 131 }
132 132
133 133 void ApbUartPlugin::setUARTPortNane(QString name)
134 134 {
135 135 this->UI->setUartPortName(name);
136 136 }
137 137
138 138 void ApbUartPlugin::setUARTPortSpeed(int speed)
139 139 {
140 140 this->UI->setUartSpeed(speed);
141 141 }
142 142
143 143 void ApbUartPlugin::fifoDebugChangeState(int state)
144 144 {
145 145 if(state==Qt::Checked)
146 146 {
147 147 this->setFifoDebugEnabled(true);
148 148 }
149 149 else
150 150 {
151 151 this->setFifoDebugEnabled(false);
152 152 }
153 153 }
154 154
155 155
156 156 unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
157 157 {
158 158 if(parent!=NULL)
159 159 return parent->Read(Value,count,address);
160 160 return 0;
161 161 }
162 162
163 163
164 164 unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
165 165 {
166 166 if(parent!=NULL)
167 167 return parent->Write(Value,count,address);
168 168 return 0;
169 169 }
170 170
171 171
172 172
173 173
174 174
175 175
176 176
177 177
@@ -1,508 +1,550
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include <socexplorerengine.h>
23 23 #include "ahbuartplugin.h"
24 24 #include <unistd.h>
25 25 #include <errno.h>
26 26 #include <QApplication>
27 27 #include <QProgressBar>
28 28 #include <stdio.h>
29 29 #include <QThread>
30 30 #include "ahbuartpywrapper.h"
31 31 #include <QCompleter>
32 32 #include <QStringList>
33 33 #include <QLineEdit>
34 34 #include <socexplorerproxy.h>
35 35
36 36 ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false)
37 37 {
38 38 this->port =(rs232port_t)NULL;
39 39 this->portMutex = new QMutex(QMutex::Recursive);
40 40 this->UI = new ahbUartPluginUI();
41 41 this->setWidget((QWidget*)this->UI);
42 42 QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool)));
43 43 QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int)));
44 this->pyObject = new ahbuartPywrapper(this);
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()));
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>)));
44 // this->pyObject = new ahbuartPywrapper(this);
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()));
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>)));
49 49 QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList()));
50 50 QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int)));
51 51 QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int)));
52 52 this->portListcompleter = NULL;
53 53 this->scanDone = false;
54 54 updatePortList();
55 55 }
56 56
57 57
58 58 ahbuartplugin::~ahbuartplugin()
59 59 {
60 60 if(this->port!=(rs232port_t)NULL)
61 61 {
62 62 rs232close(this->port);
63 63 this->port = (rs232port_t)NULL;
64 64 }
65 65 this->UI->close();
66 66 this->UI->~ahbUartPluginUI();
67 67 }
68 68
69 69
70 70 void ahbuartplugin::closeMe()
71 71 {
72 72 if(this->port!=(rs232port_t)NULL)
73 73 {
74 74 rs232close(this->port);
75 75 this->port = (rs232port_t)NULL;
76 76 }
77 77 emit this->closePlugin(this);
78 78 }
79 79
80 80 int ahbuartplugin::registermenu(QMainWindow *menuHolder)
81 81 {
82 82 this->menu = menuHolder->menuBar()->addMenu(tr("&AHB UART"));
83 83 this->closeAction = this->menu->addAction(tr("Close plugin"));
84 84 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
85 85 return 1;
86 86 }
87 87
88 88
89 89 bool ahbuartplugin::checkConnection()
90 90 {
91 91 QTime timeout;
92 92 char test[5] ={(char)0x80,(char)0x80,(char)0,(char)0,(char)0};
93 93 char test2[1024];
94 94 int writen =0;
95 95 int read = 0;
96 96 timeout.start();
97 97 SocExplorerEngine::message(this,"Check connection",2);
98 98 QMutexLocker lock(portMutex);
99 99 while(writen!=5)
100 100 {
101 101 writen+=rs232write(this->port,test+writen,5-writen);
102 102 if(timeout.elapsed()>1000)
103 103 {
104 104 SocExplorerEngine::message(this,"Can't write any data on serial port",2);
105 105 return false;
106 106 }
107 107 }
108 108 #ifdef WIN32
109 109 usleep(1000);
110 110 #endif
111 111 timeout.restart();
112 112 int avail = 0;
113 113 do
114 114 {
115 115 avail = rs232availablebytes(this->port);
116 116 if(timeout.elapsed()>1000)
117 117 {
118 118 if(avail)
119 119 rs232read(this->port,test2,avail);
120 120 SocExplorerEngine::message(this,"Connection Error",2);
121 121 return false;
122 122 }
123 123 }while(avail<4);
124 124 read = rs232read(this->port,test2,avail);
125 125 if(read>0)
126 126 {
127 127 SocExplorerEngine::message(this,"Connection Ok",2);
128 128 return true;
129 129 }
130 130 else
131 131 {
132 132 SocExplorerEngine::message(this,"Connection Error",2);
133 133 return false;
134 134 }
135 135 }
136 136
137 137 void ahbuartplugin::connectPort(QString PortName, int baudrate)
138 138 {
139 139 QTime timeout;
140 140 SocExplorerEngine::message(this,"Try to connect to port "+PortName,2);
141 141 timeout.start();
142 142 QMutexLocker lock(portMutex);
143 143 if(this->port==(rs232port_t)NULL)
144 144 {
145 145 SocExplorerEngine::message(this,"Open port "+PortName,2);
146 146 this->port=rs232open((char*)PortName.toStdString().c_str());
147 147 }
148 148 if(this->port!=badPortValue)
149 149 {
150 150 SocExplorerEngine::message(this,"Port opened "+PortName,2);
151 151 SocExplorerEngine::message(this,"Configure port "+PortName,2);
152 152 rs232setup(this->port,8,baudrate,rs232parityNo,rs232OneStop);
153 153 char test[7] ={(char)0x55,(char)0x51,(char)0x80,(char)0x80,(char)0x0,(char)0x0,(char)0x14};
154 154 char test2[1024];
155 155 SAFEWRITE(test,1,timeout,2000,return);
156 156 SAFEWRITE((test+1),1,timeout,2000,return);
157 157 rs232read(this->port,test2,512);
158 158 int read = 0;
159 159 for(int i=0;i<10;i++)
160 160 {
161 161 SocExplorerEngine::message(this,"Send test patern :0x55,0x55,0x80,0x80,0x0,0x0,0x14",2);
162 162 SAFEWRITE(test+2,5,timeout,2000,return);
163 163 SocExplorerEngine::message(this,"Read Result",2);
164 164 read=rs232read(this->port,test2+read,16);
165 165 SocExplorerEngine::message(this,QString("Get ") + QString::number(read) + " bytes",2);
166 166 if(read>0)
167 167 {
168 168 SocExplorerEngine::message(this,"Flush port ",2);
169 169 while(rs232read(this->port,test2,1)>0);
170 170 this->Connected = true;
171 171 SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2);
172 172 emit this->activate(true);
173 173 if(this->scanDone==false)
174 174 {
175 175 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
176 176 this->scanDone=true;
177 177 }
178 this->UI->setSystemSpeed(this->detectSpeed());
178 179 break;
179 180 }
180 181 }
181 182 }
182 183 else
183 184 {
184 185 SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2);
185 186 this->port = (rs232port_t)NULL;
186 187 this->Connected = false;
187 188 emit this->activateSig(false);
188 189 return;
189 190 }
190 191 if(this->Connected == false)
191 192 {
192 193 SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2);
193 194 rs232close(this->port);
194 195 this->port = (rs232port_t)NULL;
195 196 emit this->activateSig(false);
196 197 }
197 198
198 199 }
199 200
200 201 bool ahbuartplugin::open(QString PortName,int baudrate)
201 202 {
202 203 if(this->port!=(rs232port_t)NULL)
203 204 this->close();
204 205 this->UI->setconfig(PortName,baudrate);
205 206 this->connectPort(PortName,baudrate);
206 207 return (this->port!=(rs232port_t)NULL);
207 208 }
208 209
209 210 void ahbuartplugin::close()
210 211 {
211 212 if(this->port!=(rs232port_t)NULL)
212 213 {
213 214 rs232close(this->port);
214 215 this->port = (rs232port_t)NULL;
215 216 this->Connected = false;
216 217 emit this->activateSig(false);
217 218 }
218 219 }
219 220
220 221 void ahbuartplugin::togglePort(QString PortName,int baudrate)
221 222 {
222 223 if(this->port!=(rs232port_t)NULL)
223 224 {
224 225 this->close();
225 226 }
226 227 else
227 228 {
228 229 this->connectPort(PortName,baudrate);
229 230 }
230 231 }
231 232
232 233
233 234 unsigned int ahbuartplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
234 235 {
235 236 QTime timeout;
236 237 timeout.start();
237 238 unsigned int read=0;
238 239 unsigned int cnt=count;
239 240 unsigned int nextUpdateTrig=0,updateStep=1024;
240 241 SocExplorerEngine::message(this,QString("Read ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2);
241 242 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
242 243 {
243 244 QMutexLocker lock(portMutex);
244 245 if(!this->checkConnection())
245 246 {
246 247 this->Connected = false;
247 248 emit this->activateSig(false);
248 249 this->portMutex->unlock();
249 250 return 0;
250 251 }
251 252 QProgressBar* progress=NULL;
252 253 if(cnt>128)
253 254 progress= SocExplorerEngine::getProgressBar("Reading on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
254 255 char CMD[5];
255 256 char* result = (char*)malloc(count*4);
256 257 while(count>32)
257 258 {
258 259 CMD[0] = 0x80 | (32-1);
259 260 CMD[1] = (char)((address>>24)&0xFF);
260 261 CMD[2] = (char)((address>>16)&0xFF);
261 262 CMD[3] = (char)((address>>8)&0xFF);
262 263 CMD[4] = (char)((address)&0xFF);
263 264 SAFEWRITE(CMD,5,timeout,1000,return 0);
264 265 timeout.restart();
265 266 int avail=0;
266 267 do{
267 268 avail=rs232availablebytes(this->port);
268 269 if(timeout.elapsed()>1000)
269 270 {
270 271 rs232close(this->port);
271 272 this->port = (rs232port_t)NULL;
272 273 this->Connected = false;
273 274 emit this->activateSig(false);
274 275 return 0;
275 276 }
276 277 }while(avail<(32*4));
277 278 rs232read(this->port,result+((cnt-count)*4),32*4);
278 279 count-=32;
279 280 address+=32*4;
280 281 if(cnt>128)
281 282 {
282 283
283 284 if((cnt-count)>=nextUpdateTrig)
284 285 {
285 286 progress->setValue(cnt-count);
286 287 qApp->processEvents();
287 288 nextUpdateTrig+=updateStep;
288 289 }
289 290 }
290 291 }
291 292 if(count>0)
292 293 {
293 294 CMD[0] = 0x80 | (count-1);
294 295 CMD[1] = (char)((address>>24)&0xFF);
295 296 CMD[2] = (char)((address>>16)&0xFF);
296 297 CMD[3] = (char)((address>>8)&0xFF);
297 298 CMD[4] = (char)((address)&0xFF);
298 299 SAFEWRITE(CMD,5,timeout,1000,return 0);
299 300 timeout.restart();
300 301 int avail=0;
301 302 do{
302 303 avail=rs232availablebytes(this->port);
303 304 if(timeout.elapsed()>1000)
304 305 {
305 306 rs232close(this->port);
306 307 this->port = (rs232port_t)NULL;
307 308 this->Connected = false;
308 309 emit this->activateSig(false);
309 310 return 0;
310 311 }
311 312 }while(avail<(count*4));
312 313 rs232read(this->port,result+((cnt-count)*4),count*4);
313 314 }
314 315 if(cnt>128)
315 316 {
316 317 progress->setValue(cnt-count);
317 318 qApp->processEvents();
318 319 }
319 320 for(int i=0;(unsigned int)i<cnt;i++)
320 321 {
321 322 #if __BYTE_ORDER == __LITTLE_ENDIAN
322 323 // for(int j =0;j<4;j++)
323 324 // {
324 325 // Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256;
325 326 // }
326 327 Value[i]= socexplorerBswap32(((uint32_t*)result)[i]);
327 328 #elif __BYTE_ORDER == __BIG_ENDIAN
328 329 Value[i]= ((uint32_t*)result)[i];
329 330 #endif
330 331 }
331 332 read = cnt*4;
332 333 if(cnt>128)
333 334 SocExplorerEngine::deleteProgressBar(progress);
334 335 free(result);
335 336 }
336 337 emit this->addReadBytes(read);
337 338 return read/4;
338 339 }
339 340
340 341 unsigned int ahbuartplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
341 342 {
342 343 QTime timeout;
343 344 timeout.start();
344 345 unsigned int writen=0;
345 346 unsigned int nextUpdateTrig=0,updateStep=1024;
346 347 SocExplorerEngine::message(this,QString("Write ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2);
347 348 if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL))
348 349 {
349 350 QMutexLocker lock(portMutex);
350 351 if(!this->checkConnection())
351 352 {
352 353 emit this->activateSig(false);
353 354 this->Connected = false;
354 355 this->portMutex->unlock();
355 356 return 0;
356 357 }
357 358 QProgressBar* progress = NULL;
358 359 if(count>128)
359 360 progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
360 361 int offset = 0;
361 362 char* CMD= (char*)malloc((32*4)+5);
362 363 writen=0;
363 364 while(count>32)
364 365 {
365 366 CMD[0] = 0xC0 | (32-1);
366 367 CMD[1] = (char)(((unsigned int)address>>24)&0xFF);
367 368 CMD[2] = (char)(((unsigned int)address>>16)&0xFF);
368 369 CMD[3] = (char)(((unsigned int)address>>8)&0xFF);
369 370 CMD[4] = (char)(((unsigned int)address)&0xFF);
370 371 for(int i=0;i<32;i++)
371 372 {
372 373 #if __BYTE_ORDER == __LITTLE_ENDIAN
373 374 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
374 375 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
375 376 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
376 377 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
377 378 #elif __BYTE_ORDER == __BIG_ENDIAN
378 379 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset])&0xFF);
379 380 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
380 381 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
381 382 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
382 383 #endif
383 384 }
384 385 SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0);
385 386 writen+=32;
386 387 count-=32;
387 388 offset+=32;
388 389 address+=32*4;
389 390 if(offset>=nextUpdateTrig && progress!=NULL)
390 391 {
391 392 progress->setValue(offset);
392 393 qApp->processEvents();
393 394 nextUpdateTrig +=updateStep;
394 395 }
395 396
396 397 }
397 398 if(count>0)
398 399 {
399 400 CMD[0] = 0xC0 | (count-1);
400 401 CMD[1] = (char)(((unsigned int)address>>24)&0xFF);
401 402 CMD[2] = (char)(((unsigned int)address>>16)&0xFF);
402 403 CMD[3] = (char)(((unsigned int)address>>8)&0xFF);
403 404 CMD[4] = (char)(((unsigned int)address)&0xFF);
404 405 for(int i=0;(unsigned int) i<(count);i++)
405 406 {
406 407 #if __BYTE_ORDER == __LITTLE_ENDIAN
407 408 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
408 409 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
409 410 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
410 411 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF);
411 412 #elif __BYTE_ORDER == __BIG_ENDIAN
412 413 CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset])&0xFF);
413 414 CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF);
414 415 CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF);
415 416 CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF);
416 417 #endif
417 418 }
418 419 SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0);
419 420 writen+=count;
420 421 }
421 422 if(progress!=NULL)
422 423 {
423 424 progress->setValue(writen);
424 425 qApp->processEvents();
425 426 SocExplorerEngine::deleteProgressBar(progress);
426 427 }
427 428 free(CMD);
428 429 emit this->addWritenBytes(writen*4);
429 430 return writen;
430 431 }
431 432 return 0;
432 433 }
433 434
434 435
435 436
436 437
437 438 void ahbuartplugin::updatePortList()
438 439 {
439 440 if(this->portListcompleter==(QCompleter*)NULL)
440 441 {
441 442 this->portListcompleter=new QCompleter(this);
442 443 this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive);
443 444 this->portListcompleterModel = new QStringListModel(this);
444 445 this->portListcompleter->setModel(this->portListcompleterModel);
445 446 this->UI->setCompleter(this->portListcompleter);
446 447 }
447 448 rs232portslist_t* portlist = rs232getportlist();
448 449 rs232portslist_t* portlistenum = portlist;
449 450 QStringList wordList;
450 451 while(portlistenum!=NULL)
451 452 {
452 453 wordList << portlistenum->name;
453 454 portlistenum = portlistenum->next;
454 455 }
455 456 rs232deleteportlist(portlist);
456 457 this->portListcompleterModel->setStringList(wordList);
457 458 }
458 459
459 460 QVariantList ahbuartplugin::ReadBytes(unsigned int address, unsigned int count)
460 461 {
461 462 unsigned int data[(count/4)+1];
462 463 QVariantList result;
463 464 this->Read(data,(count/4)+1,address);
464 465 for(unsigned int i = 0;i<count/4;i++)
465 466 {
466 467 result.append(QVariant((int)(0x0FF&(data[i]>>24))));
467 468 result.append(QVariant((int)(0x0FF&(data[i]>>16))));
468 469 result.append(QVariant((int)(0x0FF&(data[i]>>8))));
469 470 result.append(QVariant((int)(0x0FF&(data[i]))));
470 471 }
471 472
472 473 for(int i=0;i<(count%4);i++)
473 474 {
474 475 result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8)))));
475 476 }
476 477
477 478 return result;
478 479 }
479 480
480 481 void ahbuartplugin::WriteBytes(unsigned int address, QList<QVariant> dataList)
481 482 {
482 483 unsigned int data[dataList.count()/4];
483 484 for(int i = 0;i<(dataList.count()/4);i++)
484 485 {
485 486 data[i] = 0x0FF & ((unsigned int)dataList.at(4*i).toUInt());
486 487 data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+1).toUInt()));
487 488 data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+2).toUInt()));
488 489 data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+3).toUInt()));
489 490 }
490 491 this->Write(data,dataList.count()/4,address);
491 492 }
492 493
494 int ahbuartplugin::detectSpeed()
495 {
496 //scaler = (((system_clk*10)/(baudrate*8))-5)/10
497 unsigned int ahbUartBaseAddress = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01,0x007,0);
498 // unsigned int dsuBaseAddress = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01,0x0017,0);
499 unsigned int dsuBaseAddress = 0x90000000;
500 unsigned int scaler = 0,dsuVal1=0,dsuVal2=0;
501 int speed=0;
502 QElapsedTimer time;
503 if(dsuBaseAddress!=-1)
504 {
505 time.start();
506 if( this->Read(&dsuVal1,1,dsuBaseAddress+0x08)==1)
507 {
508 usleep(1000*1000);
509 qint64 el = time.elapsed();
510 this->Read(&dsuVal2,1,dsuBaseAddress+0x08);
511 if(dsuVal1!=dsuVal2)
512 return ((dsuVal2-dsuVal1)/el)*1000;
513 }
514 }
515 if(ahbUartBaseAddress!=-1)
516 {
517 if( this->Read(&scaler,1,ahbUartBaseAddress+0x0C)==1)
518 {
519 scaler&=0x3FFFF;
520 speed = (int)(((double)scaler*10.0)+5.0)*((double)this->UI->baudRate()/10.0)*8.0;
521 // speed = (int)((double)(scaler+1)*8.0*(double)this->UI->baudRate());
522 }
523 }
524 return speed;
525 }
526
527 void ahbuartplugin::postInstantiationTrigger()
528 {
529 if(this->scanDone && this->Connected)
530 {
531 this->UI->setSystemSpeed(this->detectSpeed());
532 }
533 }
493 534
494 535
495 536
496 537
497 538
498 539
499 540
500 541
501 542
502 543
503 544
504 545
505 546
506 547
507 548
508 549
550
@@ -1,99 +1,101
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef AHBUARTPLUGIN_H
23 23 #define AHBUARTPLUGIN_H
24 24 #include <QMenuBar>
25 25 #include <QMenu>
26 26 #include <QAction>
27 27 #include <QLayout>
28 28 #include <QMutex>
29 29 #include <QProgressDialog>
30 30 #include <QStringListModel>
31 31 #include <QTime>
32 32 #include <socexplorerplugin.h>
33 33 #include "ahbuartpluginui.h"
34 34 #include <RS232.h>
35 35 #include <unistd.h>
36 36
37 37
38 38 #define SAFEWRITE(data,count,timer,timeout,error) \
39 39 while(1)\
40 40 {\
41 41 unsigned int __writen__=0; \
42 42 (timer).restart(); \
43 43 while(__writen__!=(count)) \
44 44 {\
45 45 __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
46 46 if((timer).elapsed()>(timeout)) \
47 47 {\
48 48 this->port = (rs232port_t)NULL; \
49 49 this->Connected = false; \
50 50 emit this->activateSig(false); \
51 51 error; \
52 52 } \
53 53 } \
54 54 break;\
55 55 }
56 56
57 57
58 58
59 59
60 60
61 61 class ahbuartplugin : public socexplorerplugin
62 62 {
63 63 Q_OBJECT
64 64 public:
65 65 ahbuartplugin(QWidget *parent = 0);
66 66 ~ahbuartplugin();
67 67 int registermenu(QMainWindow *menuHolder);
68 68 int VID(){return driver_VID;}
69 69 int PID(){return driver_PID;}
70 70
71 71 public slots:
72 72 void togglePort(QString PortName,int baudrate);
73 73 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
74 74 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
75 75 void closeMe();
76 76 void close();
77 77 bool open(QString PortName,int baudrate);
78 78 void updatePortList();
79 79 QVariantList ReadBytes(unsigned int address,unsigned int count);
80 80 void WriteBytes(unsigned int address,QList<QVariant> dataList);
81 int detectSpeed();
82 void postInstantiationTrigger();
81 83 signals:
82 84 void setProgressValue(int progress);
83 85 void addWritenBytes(int count);
84 86 void addReadBytes(int count);
85 87 private:
86 88 bool scanDone;
87 89 QProgressDialog* progress;
88 90 QLayout * mainLayout;
89 91 ahbUartPluginUI* UI;
90 92 QMutex* portMutex;
91 93 rs232port_t port;
92 94 QCompleter *portListcompleter;
93 95 QStringListModel *portListcompleterModel;
94 96 void connectPort(QString PortName,int baudrate);
95 97 bool checkConnection();
96 98
97 99 };
98 100
99 101 #endif // AHBUARTPLUGIN_H
@@ -1,65 +1,62
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
4 #-------------------------------------------------
5
6 CONFIG += socexplorerplugin
7 TEMPLATE = lib
8 CONFIG += dll
9 CONFIG -= static
10 VERSION=1.4.0
11 TARGET = ahbuartplugin #$${DEBUG_EXT}
12 DEFINES += PLUGIN=ahbuartplugin
13 DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\"
14 DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\"
15 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
16 DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\"
17 DEFINES += driver_can_be_root=1
18 DEFINES += driver_can_be_child=0
19 DEFINES += driver_VID=0
20 DEFINES += driver_PID=0
21
22
23
24
25 INCLUDEPATH += \
26 $${PWD}
27
28
29 HEADERS += \
30 ahbuartplugin.h \
31 ahbuartpluginui.h \
32 ahbuartpywrapper.h \
33 ahbuartpywrapper.h
34
35
36
37 SOURCES += \
38 ahbuartplugin.cpp \
39 ahbuartpluginui.cpp \
40 ahbuartpywrapper.cpp
41
42 FORMS += \
43 ahbuartpluginui.ui
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
4 #-------------------------------------------------
5
6 CONFIG += socexplorerplugin
7 TEMPLATE = lib
8 CONFIG += dll
9 CONFIG -= static
10 VERSION=1.4.0
11 TARGET = ahbuartplugin #$${DEBUG_EXT}
12 DEFINES += PLUGIN=ahbuartplugin
13 DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\"
14 DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\"
15 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
16 DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\"
17 DEFINES += driver_can_be_root=1
18 DEFINES += driver_can_be_child=0
19 DEFINES += driver_VID=0
20 DEFINES += driver_PID=0
21
22
23
24
25 INCLUDEPATH += \
26 $${PWD}
27
28
29 HEADERS += \
30 ahbuartplugin.h \
31 ahbuartpluginui.h
32
33
34
35 SOURCES += \
36 ahbuartplugin.cpp \
37 ahbuartpluginui.cpp
38
39 FORMS += \
40 ahbuartpluginui.ui
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@@ -1,103 +1,121
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "ahbuartpluginui.h"
23 23 #include "ui_ahbuartpluginui.h"
24 24
25 25 ahbUartPluginUI::ahbUartPluginUI(QWidget *parent) :
26 26 QWidget(parent),
27 27 ui(new Ui::ahbUartPluginUI)
28 28 {
29 29 ui->setupUi(this);
30 30 connect(ui->OpenPort,SIGNAL(clicked()),this,SLOT(connectPort()));
31 31 // connect(ui->PortspeedSlider,SIGNAL(valueChanged(int)),ui->baurateLCD,SLOT(display(int)));
32 32 connect(ui->rescanPorts,SIGNAL(clicked()),this,SIGNAL(rescanPorts()));
33 33 QStringList allowedSpeeds;
34 34 allowedSpeeds<<"0"<<"50"<<"75"<<"110"<<"134"<<"150"<<
35 35 "200"<<"300"<<"600"<<"1200"<<"1800"<<"2400"<<
36 36 "4800"<<"9600"<<"19200"<<"38400"<<"57600"<<
37 37 "115200"<<"230400"<<"460800"<<"500000"<<"576000"<<
38 38 "921600"<<"1000000"<<"1152000"<<"1500000"<<"2000000"<<
39 39 "2500000"<<"3000000"<<"3500000"<<"4000000";
40 40
41 41 portSpeedCompleter = new QCompleter(allowedSpeeds);
42 42 this->ui->portSpeed->setCompleter(portSpeedCompleter);
43 43 this->writtenBytes = 0;
44 44 this->readBytes = 0;
45 45 }
46 46
47 47 void ahbUartPluginUI::connectPort()
48 48 {
49 49 int baudrate = ui->portSpeed->text().toInt();
50 50 emit this->connectPortsig(ui->PortName->text(),baudrate);
51 51 }
52 52
53 53 void ahbUartPluginUI::setConnected(bool connected)
54 54 {
55 55 if(connected == true)
56 56 {
57 57 ui->OpenPort->setText(tr("Close port"));
58 58 }
59 59 else
60 60 ui->OpenPort->setText(tr("Open port"));
61 61 }
62 62
63 63
64 64 ahbUartPluginUI::~ahbUartPluginUI()
65 65 {
66 66 delete ui;
67 67 }
68 68
69 69
70 70 void ahbUartPluginUI::setconfig(QString PortName, int baudrate)
71 71 {
72 72 this->ui->PortName->setText(PortName);
73 73 this->ui->portSpeed->setText(QString::number(baudrate));
74 74 }
75 75
76 76 void ahbUartPluginUI::addWritenBytes(int count)
77 77 {
78 78 this->writtenBytes+=count;
79 79 this->ui->WrBytesLCD->display(this->writtenBytes);
80 80 }
81 81
82 82 void ahbUartPluginUI::addReadBytes(int count)
83 83 {
84 84 this->readBytes+=count;
85 85 this->ui->RdBytesLCD->display(this->readBytes);
86 86 }
87 87
88 void ahbUartPluginUI::setSystemSpeed(int speed)
89 {
90 QStringList frLst = QStringList()<<"Hz"<<"kHz"<<"MHz"<<"GHz";
91 int ind=0;
92 double speedD = speed;
93 while(speedD>1000.0)
94 {
95 speedD/=1000.0;
96 ind++;
97 }
98 this->ui->detectedSpeedLbl->setText(QString::number(speedD)+frLst[ind]);
99 }
100
88 101
89 102 void ahbUartPluginUI::setCompleter(QCompleter *completer)
90 103 {
91 104 this->ui->PortName->setCompleter(completer);
92 105 }
93 106
107 int ahbUartPluginUI::baudRate()
108 {
109 return ui->portSpeed->text().toInt();
110 }
111
94 112 void ahbUartPluginUI::closeEvent(QCloseEvent *event)
95 113 {
96 114 event->accept();
97 115 }
98 116
99 117
100 118
101 119
102 120
103 121
@@ -1,69 +1,71
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef AHBUARTPLUGINUI_H
23 23 #define AHBUARTPLUGINUI_H
24 24
25 25 #include <QWidget>
26 26 #include <QFile>
27 27 #include <QTextStream>
28 28 #include <QFileDialog>
29 29 #include <QDir>
30 30 #include <QCloseEvent>
31 31 #include <QCompleter>
32 32
33 33 namespace Ui {
34 34 class ahbUartPluginUI;
35 35 }
36 36
37 37 class ahbUartPluginUI : public QWidget
38 38 {
39 39 Q_OBJECT
40 40
41 41 public:
42 42 explicit ahbUartPluginUI(QWidget *parent = 0);
43 43 ~ahbUartPluginUI();
44 44 void closeEvent(QCloseEvent *event);
45 45 void setCompleter(QCompleter* completer);
46 int baudRate();
46 47 public slots:
47 48 void setConnected(bool connected);
48 49 void connectPort();
49 50 void setconfig(QString PortName,int baudrate);
50 51 void addWritenBytes(int count);
51 52 void addReadBytes(int count);
53 void setSystemSpeed(int speed);
52 54
53 55 signals:
54 56 void connectPortsig(QString PortName,int baudrate);
55 57 void setLogFileName(QString FileName);
56 58 void rescanPorts();
57 59 private:
58 60 int writtenBytes;
59 61 int readBytes;
60 62 Ui::ahbUartPluginUI *ui;
61 63 QCompleter* portSpeedCompleter;
62 64 };
63 65
64 66 #endif // AHBUARTPLUGINUI_H
65 67
66 68
67 69
68 70
69 71
@@ -1,118 +1,135
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>ahbUartPluginUI</class>
4 4 <widget class="QWidget" name="ahbUartPluginUI">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 <width>884</width>
10 <height>221</height>
9 <width>902</width>
10 <height>256</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 16 <layout class="QGridLayout" name="gridLayout_2">
17 <item row="4" column="0" colspan="3">
17 <item row="5" column="0" colspan="3">
18 18 <widget class="QGroupBox" name="Statistiques">
19 19 <property name="title">
20 20 <string>Statistics</string>
21 21 </property>
22 22 <layout class="QGridLayout" name="gridLayout">
23 23 <item row="0" column="2">
24 24 <widget class="QLCDNumber" name="WrBytesLCD">
25 25 <property name="digitCount">
26 26 <number>8</number>
27 27 </property>
28 28 <property name="segmentStyle">
29 29 <enum>QLCDNumber::Flat</enum>
30 30 </property>
31 31 </widget>
32 32 </item>
33 33 <item row="1" column="2">
34 34 <widget class="QLCDNumber" name="RdBytesLCD">
35 35 <property name="digitCount">
36 36 <number>8</number>
37 37 </property>
38 38 <property name="segmentStyle">
39 39 <enum>QLCDNumber::Flat</enum>
40 40 </property>
41 41 </widget>
42 42 </item>
43 43 <item row="1" column="0">
44 44 <widget class="QLabel" name="RdBytesLbl">
45 45 <property name="text">
46 46 <string>Read Bytes</string>
47 47 </property>
48 48 </widget>
49 49 </item>
50 50 <item row="0" column="0">
51 51 <widget class="QLabel" name="WrBytesLbl">
52 52 <property name="text">
53 53 <string>Writen Bytes</string>
54 54 </property>
55 55 </widget>
56 56 </item>
57 57 </layout>
58 58 </widget>
59 59 </item>
60 60 <item row="1" column="0">
61 61 <widget class="QLabel" name="label_2">
62 62 <property name="text">
63 63 <string>Port Speed</string>
64 64 </property>
65 65 </widget>
66 66 </item>
67 67 <item row="0" column="0">
68 68 <widget class="QLabel" name="label">
69 69 <property name="text">
70 70 <string>Port Name</string>
71 71 </property>
72 72 </widget>
73 73 </item>
74 74 <item row="0" column="2">
75 75 <widget class="QPushButton" name="rescanPorts">
76 76 <property name="text">
77 77 <string>SCAN</string>
78 78 </property>
79 79 </widget>
80 80 </item>
81 81 <item row="0" column="1">
82 82 <widget class="QLineEdit" name="PortName"/>
83 83 </item>
84 84 <item row="3" column="0">
85 85 <spacer name="verticalSpacer">
86 86 <property name="orientation">
87 87 <enum>Qt::Vertical</enum>
88 88 </property>
89 89 <property name="sizeHint" stdset="0">
90 90 <size>
91 91 <width>20</width>
92 92 <height>40</height>
93 93 </size>
94 94 </property>
95 95 </spacer>
96 96 </item>
97 97 <item row="3" column="1" colspan="2">
98 98 <widget class="QPushButton" name="OpenPort">
99 99 <property name="text">
100 100 <string>Open Port</string>
101 101 </property>
102 102 </widget>
103 103 </item>
104 104 <item row="1" column="1" colspan="2">
105 105 <widget class="QLineEdit" name="portSpeed">
106 106 <property name="inputMask">
107 107 <string>00000000</string>
108 108 </property>
109 109 <property name="text">
110 110 <string>115200</string>
111 111 </property>
112 112 </widget>
113 113 </item>
114 <item row="4" column="0">
115 <widget class="QLabel" name="label_3">
116 <property name="text">
117 <string>Detected Speed</string>
118 </property>
119 </widget>
120 </item>
121 <item row="4" column="1" colspan="2">
122 <widget class="QLabel" name="detectedSpeedLbl">
123 <property name="text">
124 <string/>
125 </property>
126 <property name="alignment">
127 <set>Qt::AlignCenter</set>
128 </property>
129 </widget>
130 </item>
114 131 </layout>
115 132 </widget>
116 133 <resources/>
117 134 <connections/>
118 135 </ui>
@@ -1,333 +1,333
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "dsu3plugin.h"
23 23 #include <QFileDialog>
24 24 #include <QDir>
25 25 #include "dsu3pluginpywrapper.h"
26 26 #include <socexplorerengine.h>
27 27
28 28
29 29 struct acceptedMemctrlr_str
30 30 {
31 31 int vid;
32 32 int pid;
33 33 const char* name;
34 34 };
35 35
36 36 const struct acceptedMemctrlr_str acceptedMemctrlr[]=
37 37 {
38 38 {0x04,0x0f,"MCTRL"},
39 39 {0x01,0x51,"FTSRCTRL"},
40 40 {0x20,0x01,"SRCTRLE_0WS" },
41 41 {0x20,0x02,"SRCTRLE_1WS" }
42 42 };
43 43
44 44 #define acceptedMemctrlrCnt 4
45 45
46 46 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
47 47 {
48 48 this->UI = new dsu3pluginui();
49 49 this->setWidget((QWidget*)this->UI);
50 50 this->elfparserInst = new elfparser();
51 this->pyObject = new dsu3pluginPywrapper(this);
52 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString)));
53 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
54 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
55 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
56 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable()));
57 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable()));
58 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool)));
51 // this->pyObject = new dsu3pluginPywrapper(this);
52 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString)));
53 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
54 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
55 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
56 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable()));
57 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable()));
58 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool)));
59 59
60 60 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
61 61 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
62 62 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
63 63 connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*)));
64 64 this->running = false;
65 65 }
66 66
67 67
68 68 dsu3plugin::~dsu3plugin()
69 69 {
70 70
71 71 }
72 72
73 73
74 74 void dsu3plugin::openFile()
75 75 {
76 76 QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)"));
77 77 if(filename!="")
78 78 {
79 79 this->openFile(filename);
80 80 }
81 81 }
82 82
83 83 void dsu3plugin::openFile(QString fileName)
84 84 {
85 85 this->elfparserInst->setFilename(fileName);
86 86 emit this->updateInfo(this->elfparserInst);
87 87 }
88 88
89 89 bool dsu3plugin::configureTarget()
90 90 {
91 91 int detectedMctrlr=-1;
92 92 if(parent==NULL)
93 93 return false;
94 94 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
95 95 if(DSUBASEADDRESS == (unsigned int)-1)
96 96 DSUBASEADDRESS = 0x90000000;
97 97 unsigned int MCTRLBASEADDRESS =-1;
98 98 for(int i=0; i<acceptedMemctrlrCnt;i++)
99 99 {
100 100 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
101 101 if(MCTRLBASEADDRESS != (unsigned int)-1)
102 102 {
103 103 SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1);
104 104 detectedMctrlr=i;
105 105 break;
106 106 }
107 107 }
108 108 if(MCTRLBASEADDRESS == (unsigned int)-1)
109 109 {
110 110 SocExplorerEngine::message(this,"Can't any compatible memory controller",1);
111 111 return false;
112 112 }
113 113
114 114
115 115 //Force a debug break
116 116 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
117 117 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
118 118 //Clear time tag counter
119 119 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
120 120
121 121 //Clear ASR registers
122 122 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
123 123 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
124 124 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
125 125 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
126 126 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
127 127 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
128 128
129 129 // {0x04,0x0f,"MCTRL"},
130 130 // {0x01,0x51,"FTSRCTRL"},
131 131 // {0x20,0x01,"SRCTRLE_0WS" },
132 132 // {0x20,0x02,"SRCTRLE_1WS" }
133 133 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
134 134 {
135 135 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
136 136 }
137 137 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" )
138 138 {
139 139 //let's perform a mem Wash
140 140 unsigned int val = ReadReg(MCTRLBASEADDRESS);
141 141 val |=1<<31;
142 142 WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
143 143 usleep(1000*1000);
144 144 }
145 145
146 146
147 147 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
148 148 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
149 149
150 150 memSet(DSUBASEADDRESS+0x300000,0,1567);
151 151 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
152 152 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x403ffff0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020);
153 153 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
154 154
155 155 //Disable interrupts
156 156 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
157 157 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
158 158 return false;
159 159 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
160 160 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
161 161 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
162 162
163 163 //Set up timer
164 164 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
165 165 if(APBTIMERBASEADD == (unsigned int)-1)
166 166 return false;
167 167 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
168 168 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
169 169 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
170 170 return true;
171 171 }
172 172
173 173 bool dsu3plugin::cacheDisable()
174 174 {
175 175 return setCacheEnable(false);
176 176 }
177 177
178 178 bool dsu3plugin::cacheEnable()
179 179 {
180 180 return setCacheEnable(true);
181 181 }
182 182
183 183 bool dsu3plugin::setCacheEnable(bool enabled)
184 184 {
185 185 if(parent==NULL)
186 186 return false;
187 187 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
188 188 if(DSUBASEADDRESS == (unsigned int)-1)
189 189 DSUBASEADDRESS = 0x90000000;
190 190 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
191 191 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
192 192 if(enabled)
193 193 {
194 194 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
195 195 //flushes cache.
196 196 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
197 197 }
198 198 else
199 199 {
200 200 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
201 201 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
202 202 }
203 203 return true;
204 204 }
205 205
206 206 bool dsu3plugin::flashTarget()
207 207 {
208 208 stop();
209 209 cacheDisable();
210 210 configureTarget();
211 211 /*Write .text*/
212 212 this->writeSection(".text");
213 213 /*Write .data*/
214 214 this->writeSection(".data");
215 215 return true;
216 216 }
217 217
218 218 void dsu3plugin::run()
219 219 {
220 220 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
221 221 if(DSUBASEADDRESS == (unsigned int)-1)
222 222 DSUBASEADDRESS = 0x90000000;
223 223 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
224 224 this->running = true;
225 225 this->UI->setRunning(true);
226 226 }
227 227
228 228 void dsu3plugin::stop()
229 229 {
230 230 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
231 231 if(DSUBASEADDRESS == (unsigned int)-1)
232 232 DSUBASEADDRESS = 0x90000000;
233 233 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
234 234 this->running = false;
235 235 this->UI->setRunning(false);
236 236 }
237 237
238 238 void dsu3plugin::toggleRun()
239 239 {
240 240 if(this->running)
241 241 this->stop();
242 242 else
243 243 this->run();
244 244 }
245 245
246 246 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
247 247 {
248 248 unsigned int* buff;
249 249 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
250 250 for(int i=0;i<Values.count();i++)
251 251 {
252 252 buff[i]=Values.at(i);
253 253 }
254 254 parent->Write(buff,(unsigned int)Values.count(),address);
255 255 free(buff);
256 256 }
257 257
258 258 unsigned int dsu3plugin::ReadReg(unsigned int address)
259 259 {
260 260 unsigned int buff;
261 261 parent->Read(&buff,1,address);
262 262 return buff;
263 263 }
264 264
265 265 void dsu3plugin::writeSection(int index)
266 266 {
267 267 char* buffch=NULL;
268 268 unsigned int* buff;
269 269 int size = this->elfparserInst->getSectionDatasz(index);
270 270 int sizeInt = size/4;
271 271 if(parent==NULL)
272 272 return;
273 273 this->elfparserInst->getSectionData(index,&buffch);
274 274 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
275 275 for(int i=0;i<sizeInt;i++)
276 276 {
277 277 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
278 278 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
279 279 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
280 280 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
281 281 }
282 282 if(size%4)
283 283 {
284 284 buff[sizeInt]=0;
285 285 for(int i=(size%4);i>0;i--)
286 286 {
287 287 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
288 288 }
289 289 sizeInt++;
290 290 }
291 291 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index));
292 292 free(buff);
293 293 }
294 294
295 295 void dsu3plugin::writeSection(const QString &name)
296 296 {
297 297 for(int i=0;i<this->elfparserInst->getSectioncount();i++)
298 298 {
299 299 if(!this->elfparserInst->getSectionName(i).compare(name))
300 300 {
301 301 printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i));
302 302 writeSection(i);
303 303 }
304 304 }
305 305 }
306 306
307 307
308 308 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
309 309 {
310 310 if(parent!=NULL)
311 311 return parent->Write(Value,count,address);
312 312 return 0;
313 313 }
314 314
315 315 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
316 316 {
317 317 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
318 318 if(buffer!=NULL)
319 319 {
320 320 memset((void*)buffer,value,count*sizeof(unsigned int));
321 321 parent->Write(buffer,count,address);
322 322 free(buffer );
323 323 return true;
324 324 }
325 325 return false;
326 326 }
327 327
328 328 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
329 329 {
330 330 if(parent!=NULL)
331 331 return parent->Read(Value,count,address);
332 332 return 0;
333 333 }
@@ -1,68 +1,70
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef DSU3PLUGIN_H
23 23 #define DSU3PLUGIN_H
24 24 #include "dsu3pluginui.h"
25 25 #include <QMenuBar>
26 26 #include <QMenu>
27 27 #include <QAction>
28 28 #include <QMainWindow>
29 29 #include <QList>
30 30 #include "elfparser.h"
31 31 #include <socexplorerplugin.h>
32 32 #include <socexplorerengine.h>
33 33
34 34 typedef QList<unsigned int> uIntlist;
35 35
36 36 class dsu3plugin : public socexplorerplugin
37 37 {
38 38 Q_OBJECT
39 39 public:
40 40 explicit dsu3plugin(QWidget *parent = 0);
41 41 ~dsu3plugin();
42 42 bool memSet(unsigned int address, int value, unsigned int count);
43 43 public slots:
44 44 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
45 45 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
46 46 void openFile();
47 47 void openFile(QString fileName);
48 48 bool configureTarget();
49 49 bool cacheDisable();
50 50 bool cacheEnable();
51 51 bool setCacheEnable(bool enabled);
52 52 bool flashTarget();
53 53 void run();
54 54 void stop();
55 55 void toggleRun();
56 //added for python backward compatibility
57 void loadFile(){this->flashTarget();}
56 58 signals:
57 59 void updateInfo(elfparser* parser);
58 60 private:
59 61 void WriteRegs(uIntlist Values, unsigned int address);
60 62 unsigned int ReadReg(unsigned int address);
61 63 void writeSection(int index);
62 64 void writeSection(const QString& name);
63 65 dsu3pluginui* UI;
64 66 elfparser* elfparserInst;
65 67 bool running;
66 68 };
67 69
68 70 #endif // DSU3PLUGIN_H
@@ -1,68 +1,66
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7
8 8 TEMPLATE = lib
9 9
10 10 QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign
11 11 QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign
12 12
13 13 VERSION=0.2.0
14 14 TARGET = dsu3plugin #$${DEBUG_EXT}
15 15
16 16 DEFINES += PLUGIN=dsu3plugin
17 17 DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\"
18 18 DEFINES += driver_Name="\"\\\"dsu3plugin"\\\"\"
19 19 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
20 20 DEFINES += driver_Description="\"\\\"DSU driver, works with GAISLER's DSU3 unit."\\\"\"
21 21 DEFINES += driver_can_be_root=0
22 22 DEFINES += driver_can_be_child=1
23 23 DEFINES += driver_VID=0x00
24 24 DEFINES += driver_PID=0x00
25 25
26 26
27 27 INCLUDEPATH += \
28 28 $${PWD}
29 29
30 30
31 31
32 32 HEADERS += \
33 33 dsu3plugin.h \
34 dsu3pluginui.h \
35 dsu3pluginpywrapper.h
34 dsu3pluginui.h
36 35
37 36 SOURCES += \
38 37 dsu3plugin.cpp \
39 dsu3pluginui.cpp \
40 dsu3pluginpywrapper.cpp
38 dsu3pluginui.cpp
41 39
42 40
43 41
44 42
45 43
46 44
47 45
48 46
49 47
50 48
51 49
52 50
53 51
54 52
55 53
56 54
57 55
58 56
59 57
60 58
61 59
62 60
63 61
64 62
65 63
66 64
67 65
68 66
@@ -1,61 +1,61
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "genericrwplugin.h"
23 23 #include "genericrwpluginpywrapper.h"
24 24 genericrwplugin::genericrwplugin(QWidget *parent):socexplorerplugin(parent,false)
25 25 {
26 26 this->UI = new genericrwpluginUi();
27 27 this->setWidget((QWidget*)this->UI);
28 28 connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint)));
29 29 connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint)));
30 this->pyObject = new genericRWpluginPyWrapper(this);
31 //QObject::connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint)));
32 //QObject::connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint)));
33 QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(refresh()),this->UI,SIGNAL(refresh()));
34 QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setAddress(quint32)),this->UI,SIGNAL(setAddress(quint32)));
35 QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setLength(quint32)),this->UI,SIGNAL(setLength(quint32)));
30 // this->pyObject = new genericRWpluginPyWrapper(this);
31 // //QObject::connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint)));
32 // //QObject::connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint)));
33 // QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(refresh()),this->UI,SIGNAL(refresh()));
34 // QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setAddress(quint32)),this->UI,SIGNAL(setAddress(quint32)));
35 // QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setLength(quint32)),this->UI,SIGNAL(setLength(quint32)));
36 36 }
37 37
38 38 genericrwplugin::~genericrwplugin()
39 39 {}
40 40
41 41 int genericrwplugin::registermenu(QMainWindow *menuHolder)
42 42 {
43 43 this->menu = menuHolder->menuBar()->addMenu(tr("&Generic RW Driver"));
44 44 this->closeAction = this->menu->addAction(tr("Close plugin"));
45 45 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
46 46 return 1;
47 47 }
48 48
49 49 unsigned int genericrwplugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
50 50 {
51 51 if(parent!=NULL)
52 52 return parent->Write(Value,count,address);
53 53 return 0;
54 54 }
55 55
56 56 unsigned int genericrwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
57 57 {
58 58 if(parent!=NULL)
59 59 return parent->Read(Value,count,address);
60 60 return 0;
61 61 }
@@ -1,48 +1,46
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 CONFIG += dll
8 8 CONFIG -= static
9 9
10 10 VERSION=1.1.0
11 11 TARGET = genericrwplugin
12 12 DEFINES += PLUGIN=genericrwplugin
13 13 DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\"
14 14 DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\"
15 15 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
16 16 DEFINES += driver_Description="\"\\\"Generic plugin, gives you R/W access to any memory area."\\\"\"
17 17 DEFINES += driver_can_be_root=0
18 18 DEFINES += driver_can_be_child=1
19 19 DEFINES += driver_VID=0
20 20 DEFINES += driver_PID=0
21 21
22 22
23 23 INCLUDEPATH += \
24 24 $${PWD}
25 25
26 26 #LIBS +=-llppmoncommon$${DEBUG_EXT}
27 27
28 28 HEADERS += \
29 29 genericrwplugin.h \
30 30 genericrwpluginui.h \
31 memeditor.h \
32 genericrwpluginpywrapper.h
31 memeditor.h
33 32
34 33 SOURCES += \
35 34 genericrwplugin.cpp \
36 35 genericrwpluginui.cpp \
37 memeditor.cpp \
38 genericrwpluginpywrapper.cpp
36 memeditor.cpp
39 37
40 38
41 39
42 40
43 41
44 42
45 43
46 44
47 45
48 46
@@ -1,85 +1,85
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "memctrlrplugin.h"
23 23 #include "memctrlrpywrapper.h"
24 24
25 25 memctrlrplugin::memctrlrplugin(QWidget *parent):socexplorerplugin(parent,false)
26 26 {
27 27 this->UI = new memctrlrPluginUi();
28 28 this->setWidget((QWidget*)this->UI);
29 29 connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint)));
30 30 connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint)));
31 this->pyObject = new memctrlrPyWrapper(this);
32 connect(this->pyObject,SIGNAL(launchTest(uint,uint)),this,SLOT(launchTest(uint,uint)));
31 // this->pyObject = new memctrlrPyWrapper(this);
32 // connect(this->pyObject,SIGNAL(launchTest(uint,uint)),this,SLOT(launchTest(uint,uint)));
33 33 }
34 34
35 35 memctrlrplugin::~memctrlrplugin()
36 36 {}
37 37
38 38 int memctrlrplugin::registermenu(QMainWindow *menuHolder)
39 39 {
40 40 this->menu = menuHolder->menuBar()->addMenu(tr("&Memory Controler"));
41 41 this->closeAction = this->menu->addAction(tr("Close plugin"));
42 42 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
43 43 return 1;
44 44 }
45 45
46 46 unsigned int memctrlrplugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
47 47 {
48 48 if(parent)
49 49 return parent->Write(Value,count,address);
50 50 return 0;
51 51 }
52 52
53 53 unsigned int memctrlrplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
54 54 {
55 55 if(parent)
56 56 return parent->Read(Value,count,address);
57 57 return 0;
58 58 }
59 59
60 60
61 61 bool memctrlrplugin::launchTest(unsigned int baseAddress,unsigned int size)
62 62 {
63 63 if(parent==NULL)return false;
64 64 unsigned int* dataLocal = (unsigned int*)malloc(size);
65 65 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
66 66 bool res=true;
67 67 for(int i=0;(unsigned int)i<(size>>2);i++)
68 68 {
69 69 dataLocal[i]= (0xFFFF&rand())+(rand()<<16);
70 70 }
71 71 parent->Write(dataLocal,size>>2,baseAddress);
72 72 parent->Read(dataOnBoard,size>>2,baseAddress);
73 73 for(int i=0;(unsigned int)i<(size>>2);i++)
74 74 {
75 75 if(dataLocal[i]!=dataOnBoard[i])
76 76 res=false;
77 77 }
78 78
79 79 free(dataLocal);
80 80 free(dataOnBoard);
81 81 return res;
82 82 }
83 83
84 84
85 85
@@ -1,67 +1,65
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 CONFIG += dll
8 8 CONFIG -= static
9 9
10 10 VERSION=1.0.1
11 11 TARGET = memctrlrplugin
12 12 DEFINES += PLUGIN=memctrlrplugin
13 13 DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\"
14 14 DEFINES += driver_Name="\"\\\"MemControler"\\\"\"
15 15 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
16 16 DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\"
17 17 DEFINES += driver_can_be_root=0
18 18 DEFINES += driver_can_be_child=1
19 19 DEFINES += driver_VID=0x04
20 20 DEFINES += driver_PID=0x0f
21 21
22 22 #LIBS +=-llppmoncommon
23 23
24 24 INCLUDEPATH += \
25 25 $${PWD}
26 26
27 27 HEADERS += \
28 28 memctrlrplugin.h \
29 29 memctrlrpluginui.h \
30 30 memorycheck.h \
31 genericmemoryspacecheck.h \
32 memctrlrpywrapper.h
31 genericmemoryspacecheck.h
33 32
34 33 SOURCES += \
35 34 memctrlrplugin.cpp \
36 35 memctrlrpluginui.cpp \
37 36 memorycheck.cpp \
38 genericmemoryspacecheck.cpp \
39 memctrlrpywrapper.cpp
37 genericmemoryspacecheck.cpp
40 38
41 39
42 40
43 41
44 42
45 43
46 44
47 45
48 46
49 47
50 48
51 49
52 50
53 51
54 52
55 53
56 54
57 55
58 56
59 57
60 58
61 59
62 60
63 61
64 62
65 63
66 64
67 65
@@ -1,182 +1,182
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22
23 23 #include "spwplugin.h"
24 24 #include "stardundeespw_usb.h"
25 25 #include "gr_esb_bridge.h"
26 26 #include <socexplorerproxy.h>
27 27 #include "spwpywrapper.h"
28 28
29 29
30 30 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
31 31 {
32 32 Q_UNUSED(parent)
33 33 this->bridge = NULL;
34 34 this->scanDone = false;
35 this->pyObject = new spwPyWrapper(this);
35 // this->pyObject = new spwPyWrapper(this);
36 36 this->tcpServer = new SpwTcpPacketServer(this);
37 37 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
38 38 this->bridgeSelector = new QComboBox(this);
39 39 this->mainTabWidgt = new QTabWidget(this);
40 40 this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration");
41 41 this->mainTabWidgt->addTab(this->tcpServer,"TCP Server");
42 42 this->mainLayout = new QGridLayout(this->mainGroupBox);
43 43 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
44 44 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
45 45 this->setWidget(this->mainTabWidgt);
46 46 this->bridgeSelector->addItem("none");
47 47 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
48 48 this->bridgeSelector->addItem("GR-ESB");
49 49 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
50 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
51 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer()));
52 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
53 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
54 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString)));
50 connect(this,SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
51 connect(this,SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer()));
52 connect(this,SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
53 connect(this,SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
54 connect(this,SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString)));
55 55 }
56 56
57 57
58 58 spwplugin::~spwplugin()
59 59 {
60 60
61 61 }
62 62
63 63
64 64
65 65 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
66 66 {
67 67 if(Connected)
68 68 {
69 69 return bridge->Read(Value,count,address);
70 70 }
71 71 return 0;
72 72 }
73 73
74 74 void spwplugin::bridgeSelectionChanged(const QString &text)
75 75 {
76 76 printf("test");
77 77 if(text=="none")
78 78 {
79 79 if(this->bridge!=NULL)
80 80 {
81 81 this->mainLayout->removeWidget(this->bridge->getGUI());
82 82 this->disconnect(this,SLOT(setConnected(bool)));
83 83 delete this->bridge;
84 84 this->bridge= NULL;
85 85 }
86 86 }
87 87 if(text=="STAR-Dundee Spw USB Brick")
88 88 {
89 89 if(this->bridge!=NULL)
90 90 {
91 91 this->mainLayout->removeWidget(this->bridge->getGUI());
92 92 this->disconnect(this,SLOT(setConnected(bool)));
93 93 delete this->bridge;
94 94 }
95 95 this->bridge = new stardundeeSPW_USB(this);
96 96 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
97 97 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
101 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString)));
102 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString)));
103 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
104 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
105 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
106 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
107 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetAvailableBrickCount()),
98 connect(this,SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
99 connect(this,SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
100 connect(this,SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
101 connect(this,SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString)));
102 connect(this,SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString)));
103 connect(this,SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
104 connect(this,SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
105 connect(this,SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
106 connect(this,SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
107 connect(this,SIGNAL(StarDundeeGetAvailableBrickCount()),
108 108 ((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount()));
109 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()),
109 connect(this,SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()),
110 110 ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw()));
111 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()),
111 connect(this,SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()),
112 112 ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()));
113 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber()));
114 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsAninterface(bool)),
113 connect(this,SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber()));
114 connect(this->,SIGNAL(StarDundeeSetBrickAsAninterface(bool)),
115 115 ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool)));
116 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsARouter(bool)),
116 connect(this,SIGNAL(StarDundeeSetBrickAsARouter(bool)),
117 117 ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool)));
118 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeStartTimecodes(bool)),
118 connect(this,SIGNAL(StarDundeeStartTimecodes(bool)),
119 119 ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool)));
120 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetTimecodeFrequency(double)),
120 connect(this,SIGNAL(StarDundeeSetTimecodeFrequency(double)),
121 121 ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double)));
122 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSendOneTimecode(unsigned char)),
122 connect(this,SIGNAL(StarDundeeSendOneTimecode(unsigned char)),
123 123 ((stardundeeSPW_USB*)bridge),SIGNAL(SendOneTimecode(unsigned char)));
124 124 connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int)));
125 125 connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int)));
126 126 }
127 127 if(text=="GR-ESB")
128 128 {
129 129 if(this->bridge!=NULL)
130 130 {
131 131 this->mainLayout->removeWidget(this->bridge->getGUI());
132 132 this->disconnect(this,SLOT(setConnected(bool)));
133 133 delete this->bridge;
134 134 }
135 135 this->bridge = new GR_ESB_bridge(this);
136 136 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
137 137 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
138 138 }
139 139 }
140 140
141 141
142 142 void spwplugin::selectBridge(const QString &text)
143 143 {
144 144
145 145 if(text=="none")
146 146 {
147 147 this->bridgeSelector->setCurrentIndex(0);
148 148 }
149 149 if(text=="STAR-Dundee Spw USB Brick")
150 150 {
151 151 this->bridgeSelector->setCurrentIndex(1);
152 152 }
153 153 }
154 154
155 155 void spwplugin::setConnected(bool connected)
156 156 {
157 157 this->bridgeSelector->setDisabled(connected);
158 158 this->Connected = connected;
159 159 emit activateSig(connected);
160 160 if(!this->scanDone)
161 161 {
162 162 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
163 163 this->scanDone=true;
164 164 }
165 165 }
166 166
167 167 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
168 168 {
169 169 if(Connected)
170 170 {
171 171 return bridge->Write(Value,count,address);
172 172 }
173 173 return 0;
174 174 }
175 175
176 176
177 177
178 178
179 179
180 180
181 181
182 182
@@ -1,79 +1,103
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef spwplugin_H
23 23 #define spwplugin_H
24 24 #include <QMenuBar>
25 25 #include <QMenu>
26 26 #include <QAction>
27 27 #include <QLayout>
28 28 #include <QGroupBox>
29 29 #include <QComboBox>
30 30 #include <QLabel>
31 31 #include <QTabWidget>
32 32
33 33 #include <abstractspwbridge.h>
34 34 #include <socexplorerplugin.h>
35 35
36 36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
37 37
38 38 // TODO switch to a class factory approach with self registration
39 39
40 40 class spwplugin : public socexplorerplugin
41 41 {
42 42 Q_OBJECT
43 43 public:
44 44 explicit spwplugin(QWidget *parent = 0);
45 45 ~spwplugin();
46 46 /* You can implement the folowing function if you want to overwrite
47 47 * their default behavior
48 48 */
49 49 /*
50 50 int registermenu(QMainWindow *menuHolder);
51 51 int isConnected();
52 52 int connect();
53 53 int VID(){return driver_VID;}
54 54 int PID(){return driver_PID;}
55 55 */
56 56
57 57 public slots:
58 58 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
59 59 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
60 60
61 61 void bridgeSelectionChanged( const QString & text );
62 62 void selectBridge( const QString & text );
63 63 void setConnected(bool connected);
64 64
65 65 signals:
66 void selectBridge(const QString &bridgeName);
67 bool connectBridge();
68 bool disconnectBridge();
69 void StarDundeeSelectBrick(int brickIndex);
70 void StarDundeeSelectLinkNumber(int linkIndex);
71 void StarDundeeSelectLinkSpeed(int linkSpeed);
72 void StarDundeeSetSourceAddress(const QString & destKey);
73 void StarDundeeSetDestinationAddress(const QString & address);
74 void StarDundeeSetDestinationKey(const QString & key);
75 void StarDundeeSetRmapTimeout(const QString & timeout);
76 int StarDundeeGetAvailableBrickCount();
77 unsigned int StarDundeeGetNbPacketsTransmittedToSpw( void );
78 unsigned int StarDundeeGetNbCCSDSPacketsTransmittedToSpw( void );
79 int StarDundeeGetLinkNumber();
80 void StarDundeeSetBrickAsAninterface( bool );
81 void StarDundeeSetBrickAsARouter( bool );
82 void StarDundeeSetTimecodeFrequency( double );
83 void StarDundeeStartTimecodes( bool );
84 void StarDundeeSendOneTimecode( unsigned char timecode );
85
86 void TCPServerConnect();
87 void TCPServerDisconnect();
88 void TCPServerSetPort(qint32 port);
89 void TCPServerSetIP(QString ip);
66 90
67 91 private:
68 92 SpwTcpPacketServer* tcpServer;
69 93 abstractSpwBridge* bridge;
70 94 bool scanDone;
71 95 QTabWidget* mainTabWidgt;
72 96 QGroupBox* mainGroupBox;
73 97 QComboBox* bridgeSelector;
74 98 QGridLayout* mainLayout;
75 99
76 100 };
77 101
78 102 #endif // spwplugin_H
79 103
@@ -1,90 +1,88
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 QT += network webkit
8 8 greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets
9 9
10 10 win32:CONFIG += dll
11 11 win32:CONFIG -= static
12 12 VERSION=0.5.0
13 13 TARGET = spwplugin
14 14 DEFINES += PLUGIN=spwplugin
15 15 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
16 16 DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"
17 17 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org; Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\"
18 18 DEFINES += driver_Description="\"\\\"This plugin allows you to use spacewire's RMAP protocol with Stardundee USB brick v1"\\\"\"
19 19 DEFINES += driver_can_be_root=1
20 20 DEFINES += driver_can_be_child=0
21 21 DEFINES += driver_VID=0
22 22 DEFINES += driver_PID=0
23 23
24 24 STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/
25 25
26 26 LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \
27 27 $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so
28 28
29 29 INCLUDEPATH += \
30 30 $${PWD} \
31 31 $$STARTDUNDEEPATH/inc \
32 32 StarDundee \
33 33 SpwTcpPacketServer \
34 34 GR-ESB
35 35
36 36 HEADERS += \
37 37 spwplugin.h \
38 38 StarDundee/stardundeespw_usb.h \
39 39 abstractspwbridge.h \
40 40 spw.h \
41 41 StarDundee/stardundeegui.h \
42 42 SpwTcpPacketServer/spwtcppacketserver.h \
43 spwpywrapper.h \
44 43 GR-ESB/gr_esb_bridge.h \
45 44 GR-ESB/gr_esb_ui.h \
46 45 SpwTcpPacketServer/incomingpacketparser.h
47 46
48 47
49 48 SOURCES += \
50 49 spwplugin.cpp \
51 50 StarDundee/stardundeespw_usb.cpp \
52 51 abstractspwbridge.cpp \
53 52 StarDundee/stardundeegui.cpp \
54 53 SpwTcpPacketServer/spwtcppacketserver.cpp \
55 spwpywrapper.cpp \
56 54 GR-ESB/gr_esb_bridge.cpp \
57 55 GR-ESB/gr_esb_ui.cpp \
58 56 SpwTcpPacketServer/incomingpacketparser.cpp
59 57
60 58 FORMS += \
61 59 StarDundee/stardundeeGUI.ui \
62 60 SpwTcpPacketServer/spwtcppacketserver.ui \
63 61 GR-ESB/gr_esb_ui.ui
64 62
65 63 RESOURCES += \
66 64 spwRessources.qrc
67 65
68 66
69 67
70 68
71 69
72 70
73 71
74 72
75 73
76 74
77 75
78 76
79 77
80 78
81 79
82 80
83 81
84 82
85 83
86 84
87 85
88 86
89 87
90 88
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now