##// END OF EJS Templates
Added stop function to dsu3plugin...
jeandet -
r14:f4bd616a53e5 default
parent child
Show More
@@ -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 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #include "spwpywrapper.h"
23
24 spwPyWrapper::spwPyWrapper(socexplorerplugin *parent) :
25 genericPySysdriver(parent)
26 {
27 }
@@ -0,0 +1,25
1 #ifndef SPWPYWRAPPER_H
2 #define SPWPYWRAPPER_H
3 #include <genericPySysdriver.h>
4
5 class spwPyWrapper : public genericPySysdriver
6 {
7 Q_OBJECT
8 public:
9 explicit spwPyWrapper(socexplorerplugin *parent = 0);
10
11 signals:
12 bool connectBridge();
13 bool disconnectBridge();
14 void StarDundeeSelectBrick(int brickIndex);
15 void StarDundeeSelectLinkNumber(int linkIndex);
16 void StarDundeeSelectLinkSpeed(int linkSpeed);
17 void StarDundeeSetDestinationKey(const QString & destKey);
18 void StarDundeeSetRmapAddress(const QString & address);
19 void StarDundeeSetRmapKey(const QString & key);
20 void StarDundeeSetRmapTimeout(const QString & timeout);
21 public slots:
22
23 };
24
25 #endif // SPWPYWRAPPER_H
@@ -1,7 +1,8
1 1 syntax: glob
2 2 *.pro.user
3 3 *.o
4 4 moc_*
5 5 *.so*
6 6 ui_*.h
7 7 Makefile
8 qrc_*.cpp
@@ -1,69 +1,69
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 win32:CONFIG += dll
8 8 win32:CONFIG -= static
9 9
10 10 CONFIG(debug, debug|release) {
11 11 DEBUG_EXT = _d
12 12 } else {
13 13 DEBUG_EXT =
14 14 }
15 15
16 16 TARGET = ApbUartPlugin$${DEBUG_EXT}
17 17
18 18 DEFINES += PLUGIN=ApbUartPlugin
19 19 DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\"
20 DEFINES += driver_Name="\"\\\"APB UART PLUGIN"\\\"\"
20 DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\"
21 21 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
22 22 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
23 23 DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\"
24 24 DEFINES += driver_can_be_root=0
25 25 DEFINES += driver_can_be_child=1
26 26 DEFINES += driver_VID=1
27 27 DEFINES += driver_PID=0x0c
28 28
29 29
30 30
31 31 INCLUDEPATH += \
32 32 $${PWD}
33 33
34 34 HEADERS += \
35 35 APBUARTPLUGIN.h \
36 36 apbuartpluginui.h \
37 37 apbuartcfg.h \
38 38 apbuartterminal.h
39 39
40 40
41 41 SOURCES += \
42 42 APBUARTPLUGIN.cpp \
43 43 apbuartpluginui.cpp \
44 44 apbuartcfg.cpp \
45 45 apbuartterminal.cpp
46 46
47 47
48 48
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
@@ -1,225 +1,247
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 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
29 29 {
30 30 this->UI = new dsu3pluginui();
31 31 this->setWidget((QWidget*)this->UI);
32 32 this->elfparserInst = new elfparser();
33 33 this->pyObject = new dsu3pluginPywrapper(this);
34 34 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString)));
35 35 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
36 36 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
37 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
37 38 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
38 39 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
39 connect(this->UI,SIGNAL(run()),this,SLOT(run()));
40 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
40 41 connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*)));
42 this->running = false;
41 43 }
42 44
43 45
44 46 dsu3plugin::~dsu3plugin()
45 47 {
46 48
47 49 }
48 50
49 51
50 52 void dsu3plugin::openFile()
51 53 {
52 54 QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)"));
53 55 if(filename!="")
54 56 {
55 57 this->openFile(filename);
56 58 }
57 59 }
58 60
59 61 void dsu3plugin::openFile(QString fileName)
60 62 {
61 63 this->elfparserInst->setFilename(fileName);
62 64 emit this->updateInfo(this->elfparserInst);
63 65 }
64 66
65 67 bool dsu3plugin::configureTarget()
66 68 {
67 69 if(parent==NULL)
68 70 return false;
69 71 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
70 72 if(DSUBASEADDRESS == (unsigned int)-1)
71 73 DSUBASEADDRESS = 0x90000000;
72 74 unsigned int MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x04 , 0x00F,0);
73 75 if(MCTRLBASEADDRESS == (unsigned int)-1)
74 76 return false;
75 77
76 78 //Force a debug break
77 79 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
78 80 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
79 81 //Clear time tag counter
80 82 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
81 83
82 84 //Clear ASR registers
83 85 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
84 86 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
85 87 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
86 88 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
87 89 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
88 90 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
89 91
90 92
91 93
92 94 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
93 95
94 96
95 97 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
96 98 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
97 99
98 100 unsigned int buff=0;
99 101 // for(int i=0;i<1567;i++)
100 102 // {
101 103 // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i));
102 104 // }
103 105 memSet(DSUBASEADDRESS+0x300000,0,1567);
104 106 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
105 107 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);
106 108 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
107 109
108 110 //Disable interrupts
109 111 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
110 112 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
111 113 return false;
112 114 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
113 115 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
114 116 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
115 117
116 118 //Set up timer
117 119 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
118 120 if(APBTIMERBASEADD == (unsigned int)-1)
119 121 return false;
120 122 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
121 123 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
122 124 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
123 125 return true;
124 126 }
125 127
126 128 bool dsu3plugin::flashTarget()
127 129 {
128 130 configureTarget();
129 131
130 132 /*Write .text*/
131 133 this->writeSection(".text");
132 134 /*Write .data*/
133 135 this->writeSection(".data");
134 136 return true;
135 137 }
136 138
137 139 void dsu3plugin::run()
138 140 {
139 141 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
140 142 if(DSUBASEADDRESS == (unsigned int)-1)
141 143 DSUBASEADDRESS = 0x90000000;
142 144 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
145 this->running = true;
146 this->UI->setRunning(true);
147 }
148
149 void dsu3plugin::stop()
150 {
151 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
152 if(DSUBASEADDRESS == (unsigned int)-1)
153 DSUBASEADDRESS = 0x90000000;
154 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
155 this->running = false;
156 this->UI->setRunning(false);
157 }
158
159 void dsu3plugin::toggleRun()
160 {
161 if(this->running)
162 this->stop();
163 else
164 this->run();
143 165 }
144 166
145 167 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
146 168 {
147 169 unsigned int* buff;
148 170 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
149 171 for(int i=0;i<Values.count();i++)
150 172 {
151 173 buff[i]=Values.at(i);
152 174 }
153 175 parent->Write(buff,(unsigned int)Values.count(),address);
154 176 free(buff);
155 177 }
156 178
157 179 void dsu3plugin::writeSection(int index)
158 180 {
159 181 char* buffch=NULL;
160 182 unsigned int* buff;
161 183 int size = this->elfparserInst->getSectionDatasz(index);
162 184 int sizeInt = size/4;
163 185 if(parent==NULL)
164 186 return;
165 187 this->elfparserInst->getSectionData(index,&buffch);
166 188 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
167 189 for(int i=0;i<sizeInt;i++)
168 190 {
169 191 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
170 192 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
171 193 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
172 194 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
173 195 }
174 196 if(size%4)
175 197 {
176 198 buff[sizeInt]=0;
177 199 for(int i=(size%4);i>0;i--)
178 200 {
179 201 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
180 202 }
181 203 sizeInt++;
182 204 }
183 205 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index));
184 206 free(buff);
185 207 }
186 208
187 209 void dsu3plugin::writeSection(const QString &name)
188 210 {
189 211 for(int i=0;i<this->elfparserInst->getSectioncount();i++)
190 212 {
191 213 if(!this->elfparserInst->getSectionName(i).compare(name))
192 214 {
193 215 printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i));
194 216 writeSection(i);
195 217 }
196 218 }
197 219 }
198 220
199 221
200 222 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
201 223 {
202 224 if(parent!=NULL)
203 225 return parent->Write(Value,count,address);
204 226 return 0;
205 227 }
206 228
207 229 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
208 230 {
209 231 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
210 232 if(buffer!=NULL)
211 233 {
212 234 memset((void*)buffer,value,count*sizeof(unsigned int));
213 235 parent->Write(buffer,count,address);
214 236 free(buffer );
215 237 return true;
216 238 }
217 239 return false;
218 240 }
219 241
220 242 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
221 243 {
222 244 if(parent!=NULL)
223 245 return parent->Read(Value,count,address);
224 246 return 0;
225 247 }
@@ -1,61 +1,64
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 flashTarget();
50 50 void run();
51 void stop();
52 void toggleRun();
51 53 signals:
52 54 void updateInfo(elfparser* parser);
53 55 private:
54 56 void WriteRegs(uIntlist Values, unsigned int address);
55 57 void writeSection(int index);
56 58 void writeSection(const QString& name);
57 59 dsu3pluginui* UI;
58 60 elfparser* elfparserInst;
61 bool running;
59 62 };
60 63
61 64 #endif // DSU3PLUGIN_H
@@ -1,19 +1,20
1 1 #ifndef DSU3PLUGINPYWRAPPER_H
2 2 #define DSU3PLUGINPYWRAPPER_H
3 3 #include <genericPySysdriver.h>
4 4
5 5 class dsu3pluginPywrapper : public genericPySysdriver
6 6 {
7 7 Q_OBJECT
8 8 public:
9 9 explicit dsu3pluginPywrapper(socexplorerplugin *parent = 0);
10 10
11 11 signals:
12 12 bool openFile(QString fileName);
13 13 bool loadFile();
14 14 bool run();
15 bool stop();
15 16 public slots:
16 17
17 18 };
18 19
19 20 #endif // DSU3PLUGINPYWRAPPER_H
@@ -1,54 +1,62
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22
23 23 #include <dsu3pluginui.h>
24 24
25 25 dsu3pluginui::dsu3pluginui(QWidget *parent)
26 26 :QWidget(parent)
27 27 {
28 28 this->openFileQpb = new QPushButton(tr("Open File"));
29 29 this->flashTargetQpb = new QPushButton(tr("Flash Target"));
30 30 this->runQpb = new QPushButton(tr("Run"));
31 31 this->mainLayout = new QGridLayout();
32 32 this->elfInfoWdgtInst = new elfInfoWdgt;
33 33 this->mainLayout->addWidget(this->openFileQpb,0,0,1,1);
34 34 this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1);
35 35 this->mainLayout->addWidget(this->runQpb,0,2,1,1);
36 36 this->mainLayout->addWidget(this->elfInfoWdgtInst,1,0,1,-1);
37 37 this->setLayout(this->mainLayout);
38 38 connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile()));
39 39 connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget()));
40 40 connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run()));
41 41 connect(this,SIGNAL(updateInfo(elfparser*)),this->elfInfoWdgtInst,SLOT(updateInfo(elfparser*)));
42 42
43 43 }
44 44
45 void dsu3pluginui::setRunning(bool running)
46 {
47 if(running)
48 this->runQpb->setText("Stop");
49 else
50 this->runQpb->setText("Run");
51 }
45 52
46 53
47 54
48 55
49 56
50 57
51 58
52 59
53 60
54 61
62
@@ -1,58 +1,57
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 DSU3PLUGINUI_H
23 23 #define DSU3PLUGINUI_H
24 24
25 25 #include <QWidget>
26 26 #include <QHBoxLayout>
27 27 #include <QPushButton>
28 28 #include <qhexedit.h>
29 29 #include <QSplitter>
30 30 #include <QVBoxLayout>
31 31 #include <QGridLayout>
32 32 #include "elfinfowdgt.h"
33 33
34 34 class dsu3pluginui : public QWidget
35 35 {
36 36 Q_OBJECT
37 37 public:
38 38 explicit dsu3pluginui(QWidget *parent = 0);
39 39
40 40 public slots:
41
41 void setRunning(bool running);
42 42 signals:
43 43 void openFile();
44 44 void updateInfo(elfparser* parser);
45 45 bool flashTarget();
46 46 void run();
47 47 private:
48 48 QGridLayout* mainLayout;
49 49 QPushButton* openFileQpb;
50 50 QPushButton* flashTargetQpb;
51 51 QPushButton* runQpb;
52 52 elfInfoWdgt* elfInfoWdgtInst;
53
54 53 };
55 54
56 55 #endif // DSU3PLUGINUI_H
57 56
58 57
@@ -1,14 +1,35
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
1 22 #include "spwtcppacketserver.h"
2 23 #include "ui_spwtcppacketserver.h"
3 24
4 25 SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) :
5 26 QWidget(parent),
6 27 ui(new Ui::SpwTcpPacketServer)
7 28 {
8 29 ui->setupUi(this);
9 30 }
10 31
11 32 SpwTcpPacketServer::~SpwTcpPacketServer()
12 33 {
13 34 delete ui;
14 35 }
@@ -1,22 +1,43
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
1 22 #ifndef SPWTCPPACKETSERVER_H
2 23 #define SPWTCPPACKETSERVER_H
3 24
4 25 #include <QWidget>
5 26
6 27 namespace Ui {
7 28 class SpwTcpPacketServer;
8 29 }
9 30
10 31 class SpwTcpPacketServer : public QWidget
11 32 {
12 33 Q_OBJECT
13 34
14 35 public:
15 36 explicit SpwTcpPacketServer(QWidget *parent = 0);
16 37 ~SpwTcpPacketServer();
17 38
18 39 private:
19 40 Ui::SpwTcpPacketServer *ui;
20 41 };
21 42
22 43 #endif // SPWTCPPACKETSERVER_H
@@ -1,113 +1,128
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 <socexplorerproxy.h>
26
27 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true)
26 #include "spwpywrapper.h"
27 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
28 28 {
29 29 Q_UNUSED(parent)
30 30 this->bridge = NULL;
31 31 this->scanDone = false;
32 this->pyObject = new spwPyWrapper(this);
32 33 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
33 34 this->bridgeSelector = new QComboBox(this);
34 35 this->mainLayout = new QGridLayout(this);
35 36 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
36 37 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
37 38 this->mainGroupBox->setLayout(this->mainLayout);
38 39 this->setWidget(this->mainGroupBox);
39 40 this->bridgeSelector->addItem("none");
40 41 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
41 42 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
42 43 }
43 44
44 45
45 46 spwplugin::~spwplugin()
46 47 {
47 48
48 49 }
49 50
50 51
51 52
52 53 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
53 54 {
54 55 if(Connected)
55 56 {
56 57 return bridge->Read(Value,count,address);
57 58 }
58 59 return 0;
59 60 }
60 61
61 62 void spwplugin::bridgeSelectionChanged(const QString &text)
62 63 {
63 64 printf("test");
64 65 if(text=="none")
65 66 {
66 67 if(this->bridge!=NULL)
67 68 {
68 69 this->mainLayout->removeWidget(this->bridge->getGUI());
69 70 this->disconnect(this,SLOT(setConnected(bool)));
70 71 delete this->bridge;
71 72 this->bridge= NULL;
72 73 }
73 74 }
74 75 if(text=="STAR-Dundee Spw USB Brick")
75 76 {
76 77 if(this->bridge!=NULL)
77 78 {
78 79 this->mainLayout->removeWidget(this->bridge->getGUI());
79 80 this->disconnect(this,SLOT(setConnected(bool)));
80 81 delete this->bridge;
81 82 }
82 83 this->bridge = new stardundeeSPW_USB(this);
83 84 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
84 85 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
86 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
87 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
88 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
89 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
90 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
91 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
85 95 }
86 96
87 97 }
88 98
89 99 void spwplugin::setConnected(bool connected)
90 100 {
91 101 this->bridgeSelector->setDisabled(connected);
92 102 this->Connected = connected;
93 103 emit activateSig(connected);
104 if(!this->scanDone)
105 {
106 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
107 this->scanDone=true;
108 }
94 109 }
95 110
96 111
97 112
98 113 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
99 114 {
100 115 if(Connected)
101 116 {
102 117 return bridge->Write(Value,count,address);
103 118 }
104 119 return 0;
105 120 }
106 121
107 122
108 123
109 124
110 125
111 126
112 127
113 128
@@ -1,80 +1,82
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 win32:CONFIG += dll
8 8 win32:CONFIG -= static
9 9 CONFIG(debug, debug|release) {
10 10 DEBUG_EXT = _d
11 11 } else {
12 12 DEBUG_EXT =
13 13 }
14 14 TARGET = spwplugin$${DEBUG_EXT}
15 15 DEFINES += PLUGIN=spwplugin
16 16 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
17 17 DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"
18 18 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
19 19 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
20 20 DEFINES += driver_Description="\"\\\"Driver description"\\\"\"
21 21 DEFINES += driver_can_be_root=1
22 22 DEFINES += driver_can_be_child=0
23 23 DEFINES += driver_VID=0
24 24 DEFINES += driver_PID=0
25 25
26 26 STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/
27 27
28 28 LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \
29 29 $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so
30 30
31 31 INCLUDEPATH += \
32 32 $${PWD} \
33 33 $$STARTDUNDEEPATH/inc \
34 34
35 35 HEADERS += \
36 36 spwplugin.h \
37 37 stardundeespw_usb.h \
38 38 abstractspwbridge.h \
39 39 spw.h \
40 40 stardundeegui.h \
41 SpwTcpPacketServer/spwtcppacketserver.h
41 SpwTcpPacketServer/spwtcppacketserver.h \
42 spwpywrapper.h
42 43
43 44
44 45 SOURCES += \
45 46 spwplugin.cpp \
46 47 stardundeespw_usb.cpp \
47 48 abstractspwbridge.cpp \
48 49 stardundeegui.cpp \
49 SpwTcpPacketServer/spwtcppacketserver.cpp
50 SpwTcpPacketServer/spwtcppacketserver.cpp \
51 spwpywrapper.cpp
50 52
51 53 FORMS += \
52 54 stardundeeGUI.ui \
53 55 SpwTcpPacketServer/spwtcppacketserver.ui
54 56
55 57 RESOURCES += \
56 58 spwRessources.qrc
57 59
58 60
59 61
60 62
61 63
62 64
63 65
64 66
65 67
66 68
67 69
68 70
69 71
70 72
71 73
72 74
73 75
74 76
75 77
76 78
77 79
78 80
79 81
80 82
@@ -1,162 +1,188
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>StarDundeeUI</class>
4 4 <widget class="QWidget" name="StarDundeeUI">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 <width>778</width>
10 <height>271</height>
9 <width>397</width>
10 <height>243</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 16 <layout class="QFormLayout" name="formLayout">
17 17 <item row="0" column="0">
18 18 <widget class="QLabel" name="selectBrickLbl">
19 19 <property name="text">
20 20 <string>Select Brick</string>
21 21 </property>
22 22 </widget>
23 23 </item>
24 24 <item row="0" column="1">
25 25 <widget class="QComboBox" name="selectBrickCmbx">
26 26 <property name="toolTip">
27 27 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select the brick you want to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
28 28 </property>
29 29 <property name="whatsThis">
30 30 <string/>
31 31 </property>
32 32 <item>
33 33 <property name="text">
34 34 <string>None</string>
35 35 </property>
36 36 </item>
37 37 </widget>
38 38 </item>
39 39 <item row="1" column="0">
40 40 <widget class="QLabel" name="selectLinkLbl">
41 41 <property name="text">
42 42 <string>Select link number</string>
43 43 </property>
44 44 </widget>
45 45 </item>
46 46 <item row="1" column="1">
47 47 <widget class="QComboBox" name="selectLinkCmbx">
48 48 <property name="toolTip">
49 49 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select the link number you want to use.&lt;/p&gt;&lt;p&gt;The link number correspond to the numbers on the brick:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;:/imgs/stardundee.tif&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
50 50 </property>
51 51 <item>
52 52 <property name="text">
53 53 <string>1</string>
54 54 </property>
55 55 </item>
56 56 <item>
57 57 <property name="text">
58 58 <string>2</string>
59 59 </property>
60 60 </item>
61 61 </widget>
62 62 </item>
63 63 <item row="2" column="0">
64 64 <widget class="QLabel" name="selectLinkSpeedLbl">
65 65 <property name="text">
66 66 <string>Link Speed</string>
67 67 </property>
68 68 </widget>
69 69 </item>
70 70 <item row="2" column="1">
71 71 <widget class="QComboBox" name="setLinkSpeedCmbx">
72 72 <property name="toolTip">
73 73 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select the Space Wire link speed you want to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
74 74 </property>
75 75 <item>
76 76 <property name="text">
77 77 <string>10MHz</string>
78 78 </property>
79 79 </item>
80 80 </widget>
81 81 </item>
82 82 <item row="3" column="0">
83 83 <widget class="QLabel" name="setDestKeyLbl">
84 84 <property name="text">
85 85 <string>Destination key</string>
86 86 </property>
87 87 </widget>
88 88 </item>
89 89 <item row="3" column="1">
90 90 <widget class="QLineEdit" name="destKeyLineEdit">
91 91 <property name="toolTip">
92 92 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the Space Wire Brick destination Key, the default value is 32 (0x20).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
93 93 </property>
94 94 <property name="inputMask">
95 95 <string comment="ddD"/>
96 96 </property>
97 97 <property name="text">
98 98 <string>32</string>
99 99 </property>
100 100 <property name="maxLength">
101 101 <number>3</number>
102 102 </property>
103 103 </widget>
104 104 </item>
105 105 <item row="4" column="0">
106 106 <widget class="QLabel" name="RMAPaddressLbl">
107 107 <property name="text">
108 108 <string>RMAP Target address</string>
109 109 </property>
110 110 </widget>
111 111 </item>
112 112 <item row="4" column="1">
113 113 <widget class="QLineEdit" name="RMAPAddresslineEdit">
114 114 <property name="toolTip">
115 115 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP target address, this address will be used as destination address for all the RMAP transfers.&lt;/p&gt;&lt;p&gt;This is you SOC spw address.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
116 116 </property>
117 117 <property name="inputMask">
118 118 <string comment="ddD"/>
119 119 </property>
120 120 <property name="text">
121 121 <string>254</string>
122 122 </property>
123 123 <property name="maxLength">
124 124 <number>3</number>
125 125 </property>
126 126 </widget>
127 127 </item>
128 128 <item row="5" column="0">
129 129 <widget class="QLabel" name="RMAPKeyLbl">
130 130 <property name="text">
131 131 <string>RMAP Target key</string>
132 132 </property>
133 133 </widget>
134 134 </item>
135 135 <item row="5" column="1">
136 136 <widget class="QLineEdit" name="RMAPKeylineEdit">
137 137 <property name="toolTip">
138 138 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP target key, this key will be used for all the RMAP transfers.&lt;/p&gt;&lt;p&gt;This is you SOC spw key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
139 139 </property>
140 140 <property name="inputMask">
141 141 <string comment="ddD"/>
142 142 </property>
143 143 <property name="text">
144 144 <string comment="ddD">2</string>
145 145 </property>
146 146 <property name="maxLength">
147 147 <number>3</number>
148 148 </property>
149 149 </widget>
150 150 </item>
151 <item row="6" column="1">
151 <item row="7" column="1">
152 152 <widget class="QPushButton" name="connectQpb">
153 153 <property name="text">
154 154 <string>Connect</string>
155 155 </property>
156 156 </widget>
157 157 </item>
158 <item row="6" column="1">
159 <widget class="QLineEdit" name="RMAPTimeoutLineEdit">
160 <property name="toolTip">
161 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the RMAP timeout, when waiting for a RMAP answer the driver will give up after this time if it doesn't get any answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
162 </property>
163 <property name="inputMethodHints">
164 <set>Qt::ImhDigitsOnly</set>
165 </property>
166 <property name="inputMask">
167 <string comment="DDdd;"/>
168 </property>
169 <property name="text">
170 <string>500</string>
171 </property>
172 <property name="maxLength">
173 <number>5</number>
174 </property>
175 </widget>
176 </item>
177 <item row="6" column="0">
178 <widget class="QLabel" name="RMAPTimeoutLbl">
179 <property name="text">
180 <string>RMAP timeout(ms)</string>
181 </property>
182 </widget>
183 </item>
158 184 </layout>
159 185 </widget>
160 186 <resources/>
161 187 <connections/>
162 188 </ui>
@@ -1,107 +1,174
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 #include "stardundeegui.h"
23 23
24 24 #include "ui_stardundeeGUI.h"
25 25 #include <spw_usb_api.h>
26 26 #include <spw_config_library.h>
27 27
28 28 StarDundeeGUI::StarDundeeGUI(QWidget *parent) :
29 29 QWidget(parent),ui(new Ui::StarDundeeUI)
30 30 {
31 31 this->ui->setupUi(this);
32 32 connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int)));
33 33 connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int)));
34 34 connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString)));
35 35 connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString)));
36 36 connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString)));
37 37 connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString)));
38 connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString)));
38 39 connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked()));
39 40
40 41 }
41 42
42 43 int StarDundeeGUI::getBrickSelection()
43 44 {
44 45 return ui->selectBrickCmbx->currentIndex();
45 46 }
46 47
47 48 int StarDundeeGUI::getLinkNumberSelection()
48 49 {
49 50 return ui->selectLinkCmbx->currentIndex();
50 51 }
51 52
52 53 QString StarDundeeGUI::getLinkSpeedSelection()
53 54 {
54 55 return ui->setLinkSpeedCmbx->currentText();
55 56 }
56 57
57 58 QString StarDundeeGUI::getDestinationKey()
58 59 {
59 60 return ui->destKeyLineEdit->text();
60 61 }
61 62
62 63 QString StarDundeeGUI::getRmapAddress()
63 64 {
64 65 return ui->RMAPAddresslineEdit->text();
65 66 }
66 67
67 68 QString StarDundeeGUI::getRmapKey()
68 69 {
69 70 return ui->RMAPKeylineEdit->text();
70 71 }
71 72
73 QString StarDundeeGUI::getRmapTimeout()
74 {
75 return ui->RMAPTimeoutLineEdit->text();
76 }
77
72 78
73 79
74 80 void StarDundeeGUI::lock(bool lock)
75 81 {
76 82 this->ui->selectBrickCmbx->setDisabled(lock);
77 83 this->ui->selectLinkCmbx->setDisabled(lock);
78 84 this->ui->setLinkSpeedCmbx->setDisabled(lock);
79 85 this->ui->destKeyLineEdit->setDisabled(lock);
80 86 this->ui->RMAPAddresslineEdit->setDisabled(lock);
81 87 this->ui->RMAPKeylineEdit->setDisabled(lock);
88 this->ui->RMAPTimeoutLineEdit->setDisabled(lock);
82 89 if(lock)
83 90 this->ui->connectQpb->setText("Disconnect");
84 91 else
85 92 this->ui->connectQpb->setText("Connect");
86 93 }
87 94
88 95 void StarDundeeGUI::updateAvailableBrickCount(int count)
89 96 {
90 97 this->ui->selectBrickCmbx->clear();
91 98 this->ui->selectBrickCmbx->addItem("none");
92 99 for(int i =0;i<32;i++)
93 100 {
94 101 if((count&1)==1)
95 102 {
96 103 star_device_handle hDevice;
97 104 char serial[11]="";
98 105 if (USBSpaceWire_Open(&hDevice, 0))
99 106 {
100 107 USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial);
101 108 USBSpaceWire_Close(hDevice);
102 109 }
103 110 this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial);
104 111 }
105 112 count>>=1;
106 113 }
107 114 }
115
116 void StarDundeeGUI::setRmapTimeout(const QString &timeout)
117 {
118 this->ui->RMAPTimeoutLineEdit->setText(timeout);
119 }
120
121 void StarDundeeGUI::selectBrick(int brickIndex)
122 {
123 if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count())
124 {
125 this->ui->selectBrickCmbx->setCurrentIndex(brickIndex);
126 }
127 }
128
129 void StarDundeeGUI::selectLinkNumber(int linkNumber)
130 {
131 if(linkNumber==1 || linkNumber==2)
132 {
133 this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1);
134 }
135 }
136
137 void StarDundeeGUI::selectLinkSpeed(int linkSpeed)
138 {
139 #define MHz *(1000*1000)
140 if(linkSpeed==10 MHz)
141 {
142 this->ui->selectLinkCmbx->setCurrentIndex(0);
143 }
144 }
145
146 void StarDundeeGUI::setDestinationKey(const QString &destKey)
147 {
148 bool ok;
149 int Key=destKey.toInt(&ok,10);
150 if(ok)
151 {
152 this->ui->destKeyLineEdit->setText(destKey);
153 }
154 }
155
156 void StarDundeeGUI::setRmapAddress(const QString &address)
157 {
158 bool ok;
159 int tmp=address.toInt(&ok,10);
160 if(ok)
161 {
162 this->ui->RMAPAddresslineEdit->setText(address);
163 }
164 }
165
166 void StarDundeeGUI::setRmapKey(const QString &key)
167 {
168 bool ok;
169 int tmp=key.toInt(&ok,10);
170 if(ok)
171 {
172 this->ui->RMAPKeylineEdit->setText(key);
173 }
174 }
@@ -1,58 +1,66
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 STARDUNDEEGUI_H
23 23 #define STARDUNDEEGUI_H
24 24
25 25 #include <QWidget>
26 26
27 27 namespace Ui {
28 28 class StarDundeeUI;
29 29 }
30 30
31 31 class StarDundeeGUI : public QWidget
32 32 {
33 33 Q_OBJECT
34 34 public:
35 35 explicit StarDundeeGUI(QWidget *parent = 0);
36 36 int getBrickSelection();
37 37 int getLinkNumberSelection();
38 38 QString getLinkSpeedSelection();
39 39 QString getDestinationKey();
40 40 QString getRmapAddress();
41 41 QString getRmapKey();
42 QString getRmapTimeout();
42 43 signals:
43 44 void brickSelectionChanged(int brickIndex);
44 45 void linkNumberSelectionChanged(int linkIndex);
45 46 void linkSpeedSelectionChanged(const QString & linkSpeed);
46 47 void destinationKeyChanged(const QString & destKey);
47 48 void rmapAddressChanged(const QString & address);
48 49 void rmapKeyChanged(const QString & key);
50 void rmapTimeoutChanged(const QString & timeout);
49 51 void connectClicked();
50 52 public slots:
51 53 void lock(bool lock);
52 54 void updateAvailableBrickCount(int count);
53
55 void selectBrick(int brickIndex);
56 void selectLinkNumber(int linkIndex);
57 void selectLinkSpeed(int linkSpeed);
58 void setDestinationKey(const QString & destKey);
59 void setRmapAddress(const QString & address);
60 void setRmapKey(const QString & key);
61 void setRmapTimeout(const QString & timeout);
54 62 private:
55 63 Ui::StarDundeeUI *ui;
56 64 };
57 65
58 66 #endif // STARDUNDEEGUI_H
@@ -1,607 +1,644
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 "stardundeespw_usb.h"
24 24 #include <socexplorerengine.h>
25 25 #include <qhexedit.h>
26 26
27 27 stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) :
28 28 abstractSpwBridge(parent)
29 29 {
30 30 Q_UNUSED(parent)
31 31 this->manager = new stardundeeSPW_USB_Manager(parent,this);
32 32 makeGUI(parent);
33 33 this->manager->start();
34 34 }
35 35
36 36 stardundeeSPW_USB::~stardundeeSPW_USB()
37 37 {
38 38 this->manager->requestInterruption();
39 39 delete this->p_GUI;
40 40 }
41 41
42 42 void stardundeeSPW_USB::toggleBridgeConnection()
43 43 {
44 44 if(this->plugin->isConnected())
45 45 {
46 if(this->disconnectBridge())
47 {
48 ((StarDundeeGUI*)this->p_GUI)->lock(false);
49 emit setConnected(false);
50 }
46 this->disconnectBridge();
51 47 }
52 48 else
53 49 {
54 if(this->connectBridge())
55 {
56 ((StarDundeeGUI*)this->p_GUI)->lock(true);
57 emit setConnected(true);
58 }
50 this->connectBridge();
59 51 }
60 52 }
61 53
62 54 bool stardundeeSPW_USB::connectBridge()
63 55 {
64 return this->manager->connectBridge();
56 if(this->manager->connectBridge())
57 {
58 ((StarDundeeGUI*)this->p_GUI)->lock(true);
59 emit setConnected(true);
60 return true;
61 }
62 return false;
65 63 }
66 64
67 65 bool stardundeeSPW_USB::disconnectBridge()
68 66 {
69 return this->manager->disconnectBridge();
67 if(this->manager->disconnectBridge())
68 {
69 ((StarDundeeGUI*)this->p_GUI)->lock(false);
70 emit setConnected(false);
71 return true;
72 }
73 return false;
70 74 }
71 75
76
72 77 int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size)
73 78 {
74 79 return this->manager->sendPacket(packet,size);
75 80 }
76 81
77 82 unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
78 83 {
79 84 char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
80 85 writeBuffer[0]=this->manager->linkNumber;//Link number
81 86 int transactionID = 0;
82 87 int written=0;
83 88 SocExplorerEngine::message(this->plugin,"Enter Write function",2);
84 89 QProgressBar* progress=NULL;
90 SocExplorerAutoProgressBar autopb;
85 91 if(count>RMAP_MAX_XFER_SIZE)
92 {
86 93 progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
94 autopb.setProgressBar(progress);
95 }
87 96 //Quite stupide loop, I guess that I always get the number of byte I asked for!
88 97 while(count>=RMAP_MAX_XFER_SIZE)
89 98 {
90 99 for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++)
91 100 {
92 101 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
93 102 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
94 103 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
95 104 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
96 105 }
97 106 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1);
98 107 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
99 108 written+=RMAP_MAX_XFER_SIZE;
100 109 count-=RMAP_MAX_XFER_SIZE;
101 110 progress->setValue(written);
102 111 qApp->processEvents();
103 112 }
104 113 if(count>0)
105 114 {
106 115 for(int i=0;i<((int)count);i++)
107 116 {
108 117 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF);
109 118 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF);
110 119 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
111 120 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
112 121 }
113 122 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1);
114 123 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
115 124 written+=count;
116 125 if(progress!=NULL)
117 126 {
118 127 progress->setValue(written);
119 128 qApp->processEvents();
120 129 }
121 130 }
122 if(progress!=NULL)
123 {
124 SocExplorerEngine::deleteProgressBar(progress);
125 }
131 // if(progress!=NULL)
132 // {
133 // SocExplorerEngine::deleteProgressBar(progress);
134 // }
126 135 return written;
127 136 }
128 137
129 138 unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address)
130 139 {
131 140 char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1];
132 141 char* RMAP_AnswerBuffer;
133 142 requestBuffer[0]=this->manager->linkNumber;//Link number
134 143 int transactionID = 0;
135 144 int read=0;
136 145 QProgressBar* progress=NULL;
146 SocExplorerAutoProgressBar autopb;
137 147 if(count>RMAP_MAX_XFER_SIZE)
148 {
138 149 progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
150 autopb.setProgressBar(progress);
151 }
139 152 SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2);
140 153
141 154 //Quite stupide loop, I guess that I always get the number of byte I asked for!
142 155 while((int)count>=(int)RMAP_MAX_XFER_SIZE)
143 156 {
144 157 transactionID = manager->getRMAPtransactionID();
145 158 SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2);
146 159 RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1);
147 160 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
148 161 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
149 162 if(len==-1)
150 163 {
151 164 this->toggleBridgeConnection();
152 165 return 0;
153 166 }
154 167 for(int i=0;i<((len-13)/4);i++)
155 168 {
156 169 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
157 170 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
158 171 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
159 172 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
160 173 }
161 174 free(RMAP_AnswerBuffer);
162 175 read+=RMAP_MAX_XFER_SIZE;
163 176 count-=RMAP_MAX_XFER_SIZE;
164 177 progress->setValue(read);
165 178 qApp->processEvents();
166 179 }
167 180 if((int)count>0)
168 181 {
169 182 transactionID = manager->getRMAPtransactionID();
170 183 SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2);
171 184 SocExplorerEngine::message(this->plugin,QString("Building request with:"),2);
172 185 SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2);
173 186 SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2);
174 187 SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2);
175 188 RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1);
176 189 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
177 190 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
178 191 if(len==-1)
179 192 {
180 193 this->toggleBridgeConnection();
181 194 return 0;
182 195 }
183 196 for(int i=0;i<((len-13)/4);i++)
184 197 {
185 198 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
186 199 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13]));
187 200 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14]));
188 201 Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15]));
189 202 }
190 203 free(RMAP_AnswerBuffer);
191 204 read+=count;
192 205 if(progress!=NULL)
193 206 {
194 207 progress->setValue(read);
195 208 qApp->processEvents();
196 209 }
197 210 }
198 if(progress!=NULL)
199 {
200 SocExplorerEngine::deleteProgressBar(progress);
201 }
211 // if(progress!=NULL)
212 // {
213 // SocExplorerEngine::deleteProgressBar(progress);
214 // }
202 215 return read;
203 216 }
204 217
205 218 void stardundeeSPW_USB::brickSelectionChanged(int brickIndex)
206 219 {
207 220 this->manager->selectedBrick = brickIndex-1;
208 SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick));
221 SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1);
209 222 }
210 223
211 224 void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex)
212 225 {
213 226 this->manager->linkNumber = linkIndex + 1;
214 SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber));
227 SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1);
215 228 }
216 229
217 230 void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed)
218 231 {
219 232 this->manager->linkSpeed = linkSpeed.toInt();
220 233
221 SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed));
234 SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1);
222 235 }
223 236
224 237 void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey)
225 238 {
226 239 this->manager->destinationKey = destKey.toInt();
227 SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey));
240 SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey),1);
228 241 }
229 242
230 243 void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress)
231 244 {
232 245 this->manager->rmapAddress = rmapaddress.toInt();
233 SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress));
246 SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress),1);
234 247 }
235 248
236 249 void stardundeeSPW_USB::rmapKeyChanged(const QString &key)
237 250 {
238 251 this->manager->rmapKey = key.toInt();
239 SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey));
252 SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey),1);
240 253 }
241 254
255 void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout)
256 {
257 int tim=timeout.toInt();
258 if(tim<50)
259 {
260 tim = 50;
261 ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim));
262 }
263 this->manager->RMAPtimeout = tim;
264 SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1);
265 }
266
267
242 268 void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent)
243 269 {
244 270 this->p_GUI = new StarDundeeGUI();
245 271 // this->mainLayout = new QGridLayout(this->p_GUI);
246 272 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
247 273 connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int)));
248 274 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int)));
249 275 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int)));
250 276 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString)));
251 277 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString)));
252 278 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString)));
253 279 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString)));
280 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString)));
281
254 282 this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection());
255 283 this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection());
256 284 this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection());
257 285 this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey());
258 286 this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress());
259 287 this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey());
288 this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout());
289
290 connect(this,SIGNAL(SelectBrick(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int)));
291 connect(this,SIGNAL(SelectLinkNumber(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int)));
292 connect(this,SIGNAL(SelectLinkSpeed(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int)));
293 connect(this,SIGNAL(SetDestinationKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString)));
294 connect(this,SIGNAL(SetRmapAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString)));
295 connect(this,SIGNAL(SetRmapKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString)));
296 connect(this,SIGNAL(SetRmapTimeout(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString)));
260 297
261 298 }
262 299
263 300 stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent)
264 301 :QThread((QObject*)parent)
265 302 {
266 303 this->RMAPtimeout = 2000;
267 304 this->handleMutex = new QMutex(QMutex::NonRecursive);
268 305 this->RMAP_AnswersSem = new QSemaphore(0);
269 306 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
270 307 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
271 308 this->plugin = plugin;
272 309 connected = false;
273 310 this->moveToThread(this);
274 311 }
275 312
276 313 stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager()
277 314 {
278 315 this->terminate();
279 316 while (!this->isFinished()) {
280 317 this->usleep(1000);
281 318 }
282 319 }
283 320
284 321
285 322 void stardundeeSPW_USB_Manager::run()
286 323 {
287 324 USB_SPACEWIRE_PACKET_PROPERTIES properties;
288 325 USB_SPACEWIRE_ID pIdentifier=NULL;
289 326 USB_SPACEWIRE_STATUS stat;
290 327 SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1);
291 328 char buffer[(RMAP_MAX_XFER_SIZE*4)+50];
292 329 while (!this->isInterruptionRequested())
293 330 {
294 331 if(this->connected)
295 332 {
296 333 handleMutex->lock();
297 334 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
298 335 if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01))
299 336 {
300 337 SocExplorerEngine::message(this->plugin,"Got packet",2);
301 338 stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier);
302 339 if (stat == TRANSFER_SUCCESS)
303 340 {
304 341 if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET)
305 342 {
306 343 SocExplorerEngine::message(this->plugin,"It's a SPW packet",2);
307 344 if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP)
308 345 {
309 SocExplorerEngine::message(this->plugin,"Got end of packet");
346 SocExplorerEngine::message(this->plugin,"Got end of packet",2);
310 347 if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
311 348 {
312 349 SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
313 350 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2);
314 351 if(properties.len>8)
315 352 {
316 353 char* packetbuffer = (char*)malloc(properties.len);
317 354 memcpy(packetbuffer,buffer,properties.len);
318 355 USBSpaceWire_FreeRead(hDevice, pIdentifier);
319 356 pIdentifier = NULL;
320 357 handleMutex->unlock();
321 358 RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len);
322 359 RMAP_AnswersMtx->lock();
323 360 RMAP_Answers.append(packet);
324 361 RMAP_AnswersMtx->unlock();
325 362 RMAP_AnswersSem->release();
326 363
327 364 }
328 365 else //it's a RMAP write response
329 366 {
330 367 USBSpaceWire_FreeRead(hDevice, pIdentifier);
331 368 pIdentifier = NULL;
332 369 handleMutex->unlock();
333 370 }
334 371
335 372 }
336 373 else //any non-rmap packet will be pushed to the network
337 374 {
338 375 USBSpaceWire_FreeRead(hDevice, pIdentifier);
339 376 handleMutex->unlock();
340 377 SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
341 378 }
342 379 }
343 380 else
344 381 {
345 382 SocExplorerEngine::message(this->plugin,"No EOP received",2);
346 383 }
347 384 }
348 385
349 386 }
350 387 else
351 388 {
352 389 USBSpaceWire_FreeRead(hDevice, pIdentifier);
353 390 handleMutex->unlock();
354 391 }
355 392 }
356 393 else
357 394 {
358 395 USBSpaceWire_FreeRead(hDevice, pIdentifier);
359 396 handleMutex->unlock();
360 397 }
361 398 }
362 399 else
363 400 {
364 401 //do some sanity checks!
365 402 int list = USBSpaceWire_ListDevices();
366 403 if(this->brickList!=list)
367 404 {
368 405 this->brickList = list;
369 406 emit updateAvailableBrickCount(this->brickList);
370 407 }
371 sleep(1);
408 usleep(RMAPtimeout/2);
372 409 }
373 410 usleep(1000);
374 411 }
375 412 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
376 413 }
377 414
378 415 bool stardundeeSPW_USB_Manager::connectBridge()
379 416 {
380 417 QMutexLocker mlock(this->handleMutex);
381 418 int status;
382 419 U32 statusControl;
383 420 this->connected = false;
384 421 if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
385 422 {
386 423 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0);
387 424 return false;
388 425 }
389 426 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0);
390 427
391 428 USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
392 429 CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration
393 430 CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices
394 431
395 432 // Set the path and return path to the device
396 433 CFGSpaceWire_StackClear();
397 434 CFGSpaceWire_AddrStackPush(0);
398 435 CFGSpaceWire_AddrStackPush(254);
399 436 CFGSpaceWire_RetAddrStackPush(254);
400 437 // set the base transmit rate to 100 MHz
401 438 status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff);
402 439 if (status != CFG_TRANSFER_SUCCESS)
403 440 {
404 441 SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1);
405 442 return false;
406 443 }
407 444 else
408 445 {
409 446 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1);
410 447 }
411 448
412 449 // read the link status
413 450 if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
414 451 {
415 452 SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1);
416 453 return false;
417 454 }
418 455 else
419 456 {
420 457 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1);
421 458
422 459 // Set the link status control register properties
423 460 CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
424 461 CFGSpaceWire_LSEnableStart(&statusControl, 1);
425 462 CFGSpaceWire_LSEnableDisabled(&statusControl, 0);
426 463 CFGSpaceWire_LSEnableTristate(&statusControl, 0);
427 464 CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz
428 465
429 466 // Set the link status control register
430 467 if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
431 468 {
432 469 SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1);
433 470 return false;
434 471 }
435 472 else
436 473 {
437 474 SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1);
438 475 }
439 476 }
440 477
441 478 if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS)
442 479 {
443 480 SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1);
444 481 return false;
445 482 }
446 483 else
447 484 {
448 485 SocExplorerEngine::message(this->plugin,"Device set to be an interface",1);
449 486 }
450 487
451 488 USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
452 489 USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
453 490 USBSpaceWire_SetTimeout(hDevice,1.0);
454 491 SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1);
455 492 SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1);
456 493 SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1);
457 494 this->connected = true;
458 495 return true;
459 496 }
460 497
461 498 bool stardundeeSPW_USB_Manager::disconnectBridge()
462 499 {
463 500 this->handleMutex->lock();
464 501 USBSpaceWire_Close(hDevice); // Close the device
465 502 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0);
466 503 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
467 504 this->handleMutex->unlock();
468 505 this->RMAP_pending_transaction_IDsMtx->lock();
469 506 this->RMAP_pending_transaction_IDs.clear();
470 507 this->RMAP_pending_transaction_IDsMtx->unlock();
471 508 this->RMAP_AnswersMtx->lock();
472 509 this->RMAP_Answers.clear();
473 510 this->RMAP_AnswersMtx->unlock();
474 511 this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
475 512 return true;
476 513 }
477 514
478 515 int stardundeeSPW_USB_Manager::getRMAPtransactionID()
479 516 {
480 517 this->RMAP_pending_transaction_IDsMtx->lock();
481 518 int ID=0;
482 519 bool found=true;
483 520 while(ID<511)
484 521 {
485 522 for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
486 523 {
487 524 if(RMAP_pending_transaction_IDs[i]==ID)found=false;
488 525 }
489 526 if(found==true)break;
490 527 ID++;
491 528 found = true;
492 529 }
493 530 if(found)
494 531 {
495 532 RMAP_pending_transaction_IDs.append(ID);
496 533 }
497 534 this->RMAP_pending_transaction_IDsMtx->unlock();
498 535 return ID;
499 536 }
500 537
501 538 int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer)
502 539 {
503 540 QTime timeout;
504 541 *buffer=NULL;
505 542 int count=0;
506 543 SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
507 544 timeout.start();
508 545 while (*buffer==NULL)
509 546 {
510 547 this->RMAP_AnswersMtx->lock();
511 548 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
512 549 SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
513 550 for(int i=0;i<RMAP_Answers.count();i++)
514 551 {
515 552 if(RMAP_Answers[i]->transactionID==transactionID)
516 553 {
517 554 this->RMAP_pending_transaction_IDsMtx->lock();
518 555 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2);
519 556 for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
520 557 {
521 558 if(RMAP_pending_transaction_IDs[j]==transactionID)
522 559 {
523 560 RMAP_pending_transaction_IDs.removeAt(j);
524 561 }
525 562 }
526 563 this->RMAP_pending_transaction_IDsMtx->unlock();
527 564 *buffer = RMAP_Answers[i]->data;
528 565 count = RMAP_Answers[i]->len;
529 566 RMAP_Answer* tmp=RMAP_Answers[i];
530 567 RMAP_Answers.removeAt(i);
531 568 delete tmp;
532 569 }
533 570 }
534 571 this->RMAP_AnswersMtx->unlock();
535 572 //if no answer found in the stack wait until a new packet is pushed
536 573 SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2);
537 574 if(*buffer==NULL)
538 575 {
539 576 while (0==this->RMAP_AnswersSem->available())
540 577 {
541 578 SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2);
542 579 if(timeout.elapsed()>=RMAPtimeout)
543 580 {
544 581 SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
545 582 return -1;
546 583 }
547 584 usleep(1000);
548 585 }
549 586 this->RMAP_AnswersSem->acquire();
550 587 }
551 588 }
552 589 return count;
553 590 }
554 591
555 592 bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size)
556 593 {
557 594 USB_SPACEWIRE_STATUS result;
558 595 USB_SPACEWIRE_ID pIdentifier;
559 596 SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
560 597 this->handleMutex->lock();
561 598 result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier);
562 599 if (result != TRANSFER_SUCCESS)
563 600 {
564 601 SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
565 602 this->handleMutex->unlock();
566 603 return false;
567 604 }
568 605 else
569 606 {
570 607 SocExplorerEngine::message(this->plugin,"Packet sent",2);
571 608 USBSpaceWire_FreeSend(hDevice, pIdentifier);
572 609 }
573 610 this->handleMutex->unlock();
574 611 return true;
575 612 }
576 613
577 614 void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len)
578 615 {
579 616 char* packetbuffer = (char*)malloc(len);
580 617 memcpy(packetbuffer,packet,len);
581 618 RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len);
582 619 RMAP_AnswersMtx->lock();
583 620 RMAP_Answers.append(RMPAPpacket);
584 621 RMAP_AnswersMtx->unlock();
585 622 }
586 623
587 624
588 625
589 626
590 627
591 628
592 629
593 630
594 631
595 632
596 633
597 634
598 635
599 636
600 637
601 638
602 639
603 640
604 641
605 642
606 643
607 644
@@ -1,118 +1,128
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 STARDUNDEESPW_USB_H
23 23 #define STARDUNDEESPW_USB_H
24 24
25 25 #include <QObject>
26 26 #include <spw_usb_api.h>
27 27 #include <spw_config_library.h>
28 28 #include <socexplorerplugin.h>
29 29 #include <abstractspwbridge.h>
30 30 #include <QThread>
31 31 #include <QMutex>
32 32 #include <QSemaphore>
33 33 #include <QGridLayout>
34 34 #include <QPushButton>
35 35 #include <QComboBox>
36 36 #include <QLabel>
37 37 #include "stardundeegui.h"
38 38
39 39 class RMAP_Answer
40 40 {
41 41 public:
42 42 RMAP_Answer(int ID,char* data,int len)
43 43 {
44 44 transactionID = ID;
45 45 this->data = data;
46 46 this->len = len;
47 47 }
48 48 int transactionID;
49 49 char* data;
50 50 int len;
51 51 };
52 52
53 53 class stardundeeSPW_USB_Manager: public QThread
54 54 {
55 55 Q_OBJECT
56 56 public:
57 57 explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
58 58 ~stardundeeSPW_USB_Manager();
59 59 void run();
60 60 bool connectBridge();
61 61 bool disconnectBridge();
62 62 int getRMAPtransactionID();
63 63 int getRMAPanswer(int transactionID,char** buffer);
64 64 bool sendPacket(char* packet,int size);
65 65
66 66 signals:
67 67 void updateAvailableBrickCount(int count);
68 68 private:
69 69 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
70 70 QSemaphore* RMAP_AnswersSem;
71 71 void pushRmapPacket(char* packet,int len);
72 72 star_device_handle hDevice;
73 73 socexplorerplugin* plugin;
74 74 bool connected;
75 75 char* SPWPacketBuff;
76 76 QList<RMAP_Answer*> RMAP_Answers;
77 77 QList<int> RMAP_pending_transaction_IDs;
78 78
79 79 public:
80 80 int selectedBrick;
81 81 int linkNumber;
82 82 int brickList;
83 83 int linkSpeed;
84 84 int destinationKey;
85 85 int rmapAddress;
86 86 int rmapKey;
87 87 int RMAPtimeout;
88 88 };
89 89
90 90 class stardundeeSPW_USB : public abstractSpwBridge
91 91 {
92 92 Q_OBJECT
93 93 public:
94 94 explicit stardundeeSPW_USB(socexplorerplugin *parent = 0);
95 95 ~stardundeeSPW_USB();
96 96
97 97 signals:
98 98
99 void setRmapTimeout(const QString & timeout);
100 void SelectBrick(int brickIndex);
101 void SelectLinkNumber(int linkIndex);
102 void SelectLinkSpeed(int linkSpeed);
103 void SetDestinationKey(const QString & destKey);
104 void SetRmapAddress(const QString & address);
105 void SetRmapKey(const QString & key);
106 void SetRmapTimeout(const QString & timeout);
107
99 108 public slots:
100 109 void toggleBridgeConnection();
101 110 bool connectBridge();
102 111 bool disconnectBridge();
103 112 int pushRMAPPacket(char* packet,int size);
104 113 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
105 114 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
106 115 void brickSelectionChanged(int brickIndex);
107 116 void linkNumberSelectionChanged(int linkIndex);
108 117 void linkSpeedSelectionChanged(const QString & linkSpeed);
109 118 void destinationKeyChanged(const QString & destKey);
110 119 void rmapAddressChanged(const QString & rmapaddress);
111 120 void rmapKeyChanged(const QString & key);
121 void rmapTimeoutChanged(const QString & timeout);
112 122 private:
113 123 void makeGUI(socexplorerplugin *parent);
114 124 stardundeeSPW_USB_Manager* manager;
115 125 // QGridLayout* mainLayout;
116 126 };
117 127
118 128 #endif // STARDUNDEESPW_USB_H
General Comments 0
You need to be logged in to leave comments. Login now