@@ -0,0 +1,185 | |||
|
1 | /*------------------------------------------------------------------------------ -- This file is a part of the LPPMON Software | |
|
2 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS | |
|
3 | -- | |
|
4 | -- This program is free software; you can redistribute it and/or modify | |
|
5 | -- it under the terms of the GNU General Public License as published by | |
|
6 | -- the Free Software Foundation; either version 3 of the License, or | |
|
7 | -- (at your option) any later version. | |
|
8 | -- | |
|
9 | -- This program is distributed in the hope that it will be useful, | |
|
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | -- GNU General Public License for more details. | |
|
13 | -- | |
|
14 | -- You should have received a copy of the GNU General Public License | |
|
15 | -- along with this program; if not, write to the Free Software | |
|
16 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
17 | -------------------------------------------------------------------------------*/ | |
|
18 | /*-- Author : Alexis Jeandet | |
|
19 | -- Mail : alexis.jeandet@member.fsf.org | |
|
20 | ----------------------------------------------------------------------------*/ | |
|
21 | #include "APBUARTPLUGIN.h" | |
|
22 | #include <socexplorerengine.h> | |
|
23 | ||
|
24 | ||
|
25 | ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent) | |
|
26 | { | |
|
27 | this->UI = new ApbUartPluginUi(); | |
|
28 | this->setWindowTitle(tr("APBUART")); | |
|
29 | this->setWidget((QWidget*)this->UI); | |
|
30 | this->useLoopBack = false; | |
|
31 | connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int))); | |
|
32 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); | |
|
33 | connect(&this->loopBackTimer,SIGNAL(timeout()),this,SLOT(uartReadout())); | |
|
34 | } | |
|
35 | ||
|
36 | ||
|
37 | ApbUartPlugin::~ApbUartPlugin() | |
|
38 | { | |
|
39 | ||
|
40 | } | |
|
41 | ||
|
42 | void ApbUartPlugin::closeMe() | |
|
43 | { | |
|
44 | emit this->closePlugin(this); | |
|
45 | } | |
|
46 | ||
|
47 | void ApbUartPlugin::postInstantiationTrigger() | |
|
48 | { | |
|
49 | if(this->isEnabled()) | |
|
50 | { | |
|
51 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); | |
|
52 | loopbackChangeState(Qt::Checked); | |
|
53 | } | |
|
54 | } | |
|
55 | ||
|
56 | void ApbUartPlugin::loopbackChangeState(int state) | |
|
57 | { | |
|
58 | if(state==Qt::Checked) | |
|
59 | { | |
|
60 | enableLoopback(); | |
|
61 | } | |
|
62 | else | |
|
63 | { | |
|
64 | disableLoopback(); | |
|
65 | } | |
|
66 | } | |
|
67 | ||
|
68 | void ApbUartPlugin::uartReadout() | |
|
69 | { | |
|
70 | if(this->isEnabled() && parent!=NULL) | |
|
71 | { | |
|
72 | if(this->useLoopBack) | |
|
73 | { | |
|
74 | if(this->baseAddress()!=-1) | |
|
75 | { | |
|
76 | unsigned int status_reg,data; | |
|
77 | char ch; | |
|
78 | QString printdata=""; | |
|
79 | parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); | |
|
80 | while ((status_reg&4)==0) { | |
|
81 | parent->Read(&data,1,this->baseAddress()+APB_UART_FIFO_DEBUG_REG); | |
|
82 | ch = (char)(0xff & data); | |
|
83 | printdata+=ch; | |
|
84 | parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); | |
|
85 | } | |
|
86 | if(printdata!="") | |
|
87 | emit apbUartTextReceived(printdata); | |
|
88 | } | |
|
89 | else | |
|
90 | { | |
|
91 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); | |
|
92 | this->enableLoopback(); | |
|
93 | } | |
|
94 | } | |
|
95 | } | |
|
96 | } | |
|
97 | ||
|
98 | void ApbUartPlugin::activate(bool flag) | |
|
99 | { | |
|
100 | this->setEnabled(flag); | |
|
101 | emit this->activateSig(flag); | |
|
102 | if(this->isEnabled()) | |
|
103 | {this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); | |
|
104 | ||
|
105 | loopbackChangeState(Qt::Checked); | |
|
106 | } | |
|
107 | } | |
|
108 | ||
|
109 | void ApbUartPlugin::activateScan(bool flag) | |
|
110 | { | |
|
111 | if(flag) | |
|
112 | this->loopBackTimer.start(100); | |
|
113 | else | |
|
114 | this->loopBackTimer.stop(); | |
|
115 | } | |
|
116 | ||
|
117 | int ApbUartPlugin::enableLoopback() | |
|
118 | { | |
|
119 | ||
|
120 | this->useLoopBack = true; | |
|
121 | this->loopBackTimer.start(100); | |
|
122 | SocExplorerEngine::message(this,"Set FiFo debug mode mode"); | |
|
123 | if(parent==NULL) | |
|
124 | { | |
|
125 | SocExplorerEngine::message(this,"Can't set FiFo debug mode no parent driver accessible"); | |
|
126 | return -1; | |
|
127 | } | |
|
128 | if(this->baseAddress()==-1) | |
|
129 | { | |
|
130 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); | |
|
131 | if(this->baseAddress()==-1) | |
|
132 | return -1; | |
|
133 | } | |
|
134 | unsigned int ctrl_reg= 0x843; | |
|
135 | parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); | |
|
136 | return 0; | |
|
137 | } | |
|
138 | ||
|
139 | int ApbUartPlugin::disableLoopback() | |
|
140 | { | |
|
141 | SocExplorerEngine::message(this,"Disable FiFo debug mode mode"); | |
|
142 | if(parent==NULL) | |
|
143 | { | |
|
144 | SocExplorerEngine::message(this,"Can't disable FiFo debug mode no parent driver accessible"); | |
|
145 | return -1; | |
|
146 | } | |
|
147 | if(this->baseAddress()==-1) | |
|
148 | { | |
|
149 | this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); | |
|
150 | if(this->baseAddress()==-1) | |
|
151 | return -1; | |
|
152 | } | |
|
153 | unsigned int ctrl_reg; | |
|
154 | this->loopBackTimer.stop(); | |
|
155 | /* Firts get Control reg value*/ | |
|
156 | parent->Read(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); | |
|
157 | ctrl_reg = ctrl_reg & (~(1<<11)); | |
|
158 | parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); | |
|
159 | this->useLoopBack = false; | |
|
160 | return 0; | |
|
161 | } | |
|
162 | ||
|
163 | ||
|
164 | unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
165 | { | |
|
166 | if(parent!=NULL) | |
|
167 | return parent->Read(Value,count,address); | |
|
168 | return 0; | |
|
169 | } | |
|
170 | ||
|
171 | ||
|
172 | unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
|
173 | { | |
|
174 | if(parent!=NULL) | |
|
175 | return parent->Write(Value,count,address); | |
|
176 | return 0; | |
|
177 | } | |
|
178 | ||
|
179 | ||
|
180 | ||
|
181 | ||
|
182 | ||
|
183 | ||
|
184 | ||
|
185 |
@@ -0,0 +1,69 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 | #ifndef APBUARTPLUGIN_H | |
|
23 | #define APBUARTPLUGIN_H | |
|
24 | #include <QMenuBar> | |
|
25 | #include <QMenu> | |
|
26 | #include <QAction> | |
|
27 | #include <QLayout> | |
|
28 | ||
|
29 | #include <socexplorerplugin.h> | |
|
30 | #include <apbuartpluginui.h> | |
|
31 | #include <QTimer> | |
|
32 | ||
|
33 | #define APB_UART_DATA_REG 0x0 | |
|
34 | #define APB_UART_STATUS_REG 0x4 | |
|
35 | #define APB_UART_CONTROL_REG 0x8 | |
|
36 | #define APB_UART_SCALE_REG 0xC | |
|
37 | #define APB_UART_FIFO_DEBUG_REG 0x10 | |
|
38 | ||
|
39 | ||
|
40 | class ApbUartPlugin : public socexplorerplugin | |
|
41 | { | |
|
42 | Q_OBJECT | |
|
43 | public: | |
|
44 | explicit ApbUartPlugin(QWidget *parent = 0); | |
|
45 | ~ApbUartPlugin(); | |
|
46 | int VID(){return driver_VID;} | |
|
47 | int PID(){return driver_PID;} | |
|
48 | ||
|
49 | public slots: | |
|
50 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
51 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
52 | void closeMe(); | |
|
53 | void postInstantiationTrigger(); | |
|
54 | void loopbackChangeState( int state ); | |
|
55 | void uartReadout(); | |
|
56 | void activateScan(bool flag); | |
|
57 | void activate(bool flag); | |
|
58 | signals: | |
|
59 | void apbUartTextReceived(QString text); | |
|
60 | private: | |
|
61 | ApbUartPluginUi* UI; | |
|
62 | bool useLoopBack; | |
|
63 | QTimer loopBackTimer; | |
|
64 | int enableLoopback(); | |
|
65 | int disableLoopback(); | |
|
66 | }; | |
|
67 | ||
|
68 | #endif // APBUARTPLUGIN_H | |
|
69 |
@@ -0,0 +1,69 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | win32:CONFIG += dll | |
|
8 | win32:CONFIG -= static | |
|
9 | ||
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | ||
|
16 | TARGET = ApbUartPlugin$${DEBUG_EXT} | |
|
17 | ||
|
18 | DEFINES += PLUGIN=ApbUartPlugin | |
|
19 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" | |
|
20 | DEFINES += driver_Name="\"\\\"APB UART PLUGIN"\\\"\" | |
|
21 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
|
22 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
|
23 | DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\" | |
|
24 | DEFINES += driver_can_be_root=0 | |
|
25 | DEFINES += driver_can_be_child=1 | |
|
26 | DEFINES += driver_VID=1 | |
|
27 | DEFINES += driver_PID=0x0c | |
|
28 | ||
|
29 | ||
|
30 | ||
|
31 | INCLUDEPATH += \ | |
|
32 | $${PWD} | |
|
33 | ||
|
34 | HEADERS += \ | |
|
35 | APBUARTPLUGIN.h \ | |
|
36 | apbuartpluginui.h \ | |
|
37 | apbuartcfg.h \ | |
|
38 | apbuartterminal.h | |
|
39 | ||
|
40 | ||
|
41 | SOURCES += \ | |
|
42 | APBUARTPLUGIN.cpp \ | |
|
43 | apbuartpluginui.cpp \ | |
|
44 | apbuartcfg.cpp \ | |
|
45 | apbuartterminal.cpp | |
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 |
@@ -0,0 +1,33 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 "apbuartcfg.h" | |
|
23 | ||
|
24 | ApbUartCfg::ApbUartCfg(QWidget *parent) : | |
|
25 | QWidget(parent) | |
|
26 | { | |
|
27 | this->mainLayout = new QGridLayout(this); | |
|
28 | this->loopbackChkBx = new QCheckBox(tr("Enable loopback"),this); | |
|
29 | this->loopbackChkBx->setChecked(true); | |
|
30 | this->mainLayout->addWidget(this->loopbackChkBx); | |
|
31 | this->setLayout(this->mainLayout); | |
|
32 | connect(this->loopbackChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); | |
|
33 | } |
@@ -0,0 +1,46 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 | #ifndef APBUARTCFG_H | |
|
23 | #define APBUARTCFG_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QCheckBox> | |
|
27 | #include <QLabel> | |
|
28 | #include <QGridLayout> | |
|
29 | ||
|
30 | class ApbUartCfg : public QWidget | |
|
31 | { | |
|
32 | Q_OBJECT | |
|
33 | public: | |
|
34 | explicit ApbUartCfg(QWidget *parent = 0); | |
|
35 | ||
|
36 | signals: | |
|
37 | void loopbackChkBxStateChanged( int state ); | |
|
38 | public slots: | |
|
39 | ||
|
40 | private: | |
|
41 | QCheckBox* loopbackChkBx; | |
|
42 | QGridLayout* mainLayout; | |
|
43 | ||
|
44 | }; | |
|
45 | ||
|
46 | #endif // APBUARTCFG_H |
@@ -0,0 +1,34 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 "apbuartpluginui.h" | |
|
23 | ||
|
24 | ApbUartPluginUi::ApbUartPluginUi(QWidget *parent) : | |
|
25 | QTabWidget(parent) | |
|
26 | { | |
|
27 | this->terminal = new ApbUartTerminal(this); | |
|
28 | this->cfg = new ApbUartCfg(this); | |
|
29 | ||
|
30 | this->addTab(this->cfg,"Config"); | |
|
31 | this->addTab(this->terminal,"terminal"); | |
|
32 | connect(this->cfg,SIGNAL(loopbackChkBxStateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); | |
|
33 | connect(this,SIGNAL(apbUartTextReceived(QString)),this->terminal,SIGNAL(apbUartTextReceived(QString))); | |
|
34 | } |
@@ -0,0 +1,51 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 | #ifndef APBUARTPLUGINUI_H | |
|
23 | #define APBUARTPLUGINUI_H | |
|
24 | ||
|
25 | #include "apbuartcfg.h" | |
|
26 | #include <QWidget> | |
|
27 | #include <QGridLayout> | |
|
28 | #include <QTabWidget> | |
|
29 | #include <QCheckBox> | |
|
30 | #include <QLabel> | |
|
31 | #include <QLineEdit> | |
|
32 | #include <QTextEdit> | |
|
33 | #include "apbuartterminal.h" | |
|
34 | ||
|
35 | class ApbUartPluginUi : public QTabWidget | |
|
36 | { | |
|
37 | Q_OBJECT | |
|
38 | public: | |
|
39 | explicit ApbUartPluginUi(QWidget *parent = 0); | |
|
40 | ||
|
41 | signals: | |
|
42 | void loopbackChkBxStateChanged( int state ); | |
|
43 | void apbUartTextReceived(QString text); | |
|
44 | public slots: | |
|
45 | ||
|
46 | private: | |
|
47 | ApbUartCfg* cfg; | |
|
48 | ApbUartTerminal* terminal; | |
|
49 | }; | |
|
50 | ||
|
51 | #endif // APBUARTPLUGINUI_H |
@@ -0,0 +1,28 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 "apbuartterminal.h" | |
|
23 | ||
|
24 | ApbUartTerminal::ApbUartTerminal(QWidget *parent) : | |
|
25 | QTextEdit(parent) | |
|
26 | { | |
|
27 | connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString))); | |
|
28 | } |
@@ -0,0 +1,41 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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 | #ifndef APBUARTTERMINAL_H | |
|
23 | #define APBUARTTERMINAL_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QTextEdit> | |
|
27 | ||
|
28 | ||
|
29 | class ApbUartTerminal : public QTextEdit | |
|
30 | { | |
|
31 | Q_OBJECT | |
|
32 | public: | |
|
33 | explicit ApbUartTerminal(QWidget *parent = 0); | |
|
34 | ||
|
35 | signals: | |
|
36 | void apbUartTextReceived(QString text); | |
|
37 | public slots: | |
|
38 | ||
|
39 | }; | |
|
40 | ||
|
41 | #endif // APBUARTTERMINAL_H |
@@ -0,0 +1,12 | |||
|
1 | TEMPLATE = subdirs | |
|
2 | CONFIG += ordered | |
|
3 | ||
|
4 | ||
|
5 | SUBDIRS = \ | |
|
6 | ahbuartplugin \ | |
|
7 | ambaplugin \ | |
|
8 | APBUARTPLUGIN \ | |
|
9 | dsu3plugin \ | |
|
10 | genericrwplugin \ | |
|
11 | memctrlrplugin \ | |
|
12 | spwplugin |
@@ -0,0 +1,459 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include <socexplorerengine.h> | |
|
23 | #include "ahbuartplugin.h" | |
|
24 | #include <unistd.h> | |
|
25 | #include <errno.h> | |
|
26 | #include <QApplication> | |
|
27 | #include <QProgressBar> | |
|
28 | #include <stdio.h> | |
|
29 | #include <QThread> | |
|
30 | #include "ahbuartpywrapper.h" | |
|
31 | #include <QCompleter> | |
|
32 | #include <QStringList> | |
|
33 | #include <QLineEdit> | |
|
34 | #include <socexplorerproxy.h> | |
|
35 | ||
|
36 | ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false) | |
|
37 | { | |
|
38 | this->port =(rs232port_t)NULL; | |
|
39 | this->portMutex = new QMutex(QMutex::Recursive); | |
|
40 | this->UI = new ahbUartPluginUI(); | |
|
41 | this->setWidget((QWidget*)this->UI); | |
|
42 | this->setWindowTitle(tr("AHB UART")); | |
|
43 | QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool))); | |
|
44 | QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int))); | |
|
45 | this->pyObject = new ahbuartPywrapper(this); | |
|
46 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int))); | |
|
47 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close())); | |
|
48 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint))); | |
|
49 | QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>))); | |
|
50 | QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList())); | |
|
51 | this->portListcompleter = NULL; | |
|
52 | this->scanDone = false; | |
|
53 | updatePortList(); | |
|
54 | } | |
|
55 | ||
|
56 | ||
|
57 | ahbuartplugin::~ahbuartplugin() | |
|
58 | { | |
|
59 | if(this->port!=(rs232port_t)NULL) | |
|
60 | { | |
|
61 | rs232close(this->port); | |
|
62 | this->port = (rs232port_t)NULL; | |
|
63 | } | |
|
64 | this->UI->close(); | |
|
65 | this->UI->~ahbUartPluginUI(); | |
|
66 | } | |
|
67 | ||
|
68 | ||
|
69 | void ahbuartplugin::closeMe() | |
|
70 | { | |
|
71 | if(this->port!=(rs232port_t)NULL) | |
|
72 | { | |
|
73 | rs232close(this->port); | |
|
74 | this->port = (rs232port_t)NULL; | |
|
75 | } | |
|
76 | emit this->closePlugin(this); | |
|
77 | } | |
|
78 | ||
|
79 | int ahbuartplugin::registermenu(QMainWindow *menuHolder) | |
|
80 | { | |
|
81 | this->menu = menuHolder->menuBar()->addMenu(tr("&AHB UART")); | |
|
82 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
|
83 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
|
84 | return 1; | |
|
85 | } | |
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | bool ahbuartplugin::checkConnection() | |
|
91 | { | |
|
92 | QTime timeout; | |
|
93 | char test[5] ={(char)0x80,(char)0x80,(char)0,(char)0,(char)0}; | |
|
94 | char test2[1024]; | |
|
95 | int writen =0; | |
|
96 | int read = 0; | |
|
97 | timeout.start(); | |
|
98 | SocExplorerEngine::message(this,"Check connection",2); | |
|
99 | while(writen!=5) | |
|
100 | { | |
|
101 | writen+=rs232write(this->port,test+writen,5-writen); | |
|
102 | if(timeout.elapsed()>1000) | |
|
103 | { | |
|
104 | SocExplorerEngine::message(this,"Can't write any data on serial port",2); | |
|
105 | return false; | |
|
106 | } | |
|
107 | } | |
|
108 | timeout.restart(); | |
|
109 | while(read!=4) | |
|
110 | { | |
|
111 | read += rs232read(this->port,test2,4-read); | |
|
112 | if(timeout.elapsed()>1000) break; | |
|
113 | } | |
|
114 | if(read>0) | |
|
115 | { | |
|
116 | SocExplorerEngine::message(this,"Connection Ok",2); | |
|
117 | return true; | |
|
118 | } | |
|
119 | else | |
|
120 | { | |
|
121 | SocExplorerEngine::message(this,"Connection Error",2); | |
|
122 | return false; | |
|
123 | } | |
|
124 | ||
|
125 | } | |
|
126 | ||
|
127 | void ahbuartplugin::connectPort(QString PortName, int baudrate) | |
|
128 | { | |
|
129 | QTime timeout; | |
|
130 | SocExplorerEngine::message(this,"Try to connect to port "+PortName,2); | |
|
131 | timeout.start(); | |
|
132 | if(this->port==(rs232port_t)NULL) | |
|
133 | { | |
|
134 | SocExplorerEngine::message(this,"Open port "+PortName,2); | |
|
135 | this->port=rs232open((char*)PortName.toStdString().c_str()); | |
|
136 | } | |
|
137 | if(this->port!=badPortValue) | |
|
138 | { | |
|
139 | SocExplorerEngine::message(this,"Port opened "+PortName,2); | |
|
140 | SocExplorerEngine::message(this,"Configure port "+PortName,2); | |
|
141 | rs232setup(this->port,8,baudrate,rs232parityNo,rs232OneStop); | |
|
142 | char test[7] ={(char)0x55,(char)0x51,(char)0x80,(char)0x80,(char)0x0,(char)0x0,(char)0x14}; | |
|
143 | char test2[1024]; | |
|
144 | SAFEWRITE(test,1,timeout,2000,return); | |
|
145 | SAFEWRITE((test+1),1,timeout,2000,return); | |
|
146 | APPENDTOLOG(QString("Flush port ")); | |
|
147 | rs232read(this->port,test2,512); | |
|
148 | int read = 0; | |
|
149 | for(int i=0;i<10;i++) | |
|
150 | { | |
|
151 | SocExplorerEngine::message(this,"Send test patern :0x55,0x55,0x80,0x80,0x0,0x0,0x14",2); | |
|
152 | SAFEWRITE(test+2,5,timeout,2000,return); | |
|
153 | SocExplorerEngine::message(this,"Read Result",2); | |
|
154 | read=rs232read(this->port,test2+read,16); | |
|
155 | SocExplorerEngine::message(this,QString("Get ") + QString::number(read) + " bytes",2); | |
|
156 | if(read>0) | |
|
157 | { | |
|
158 | SocExplorerEngine::message(this,"Flush port ",2); | |
|
159 | while(rs232read(this->port,test2,1)>0); | |
|
160 | this->Connected = true; | |
|
161 | SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2); | |
|
162 | emit this->activate(true); | |
|
163 | if(this->scanDone==false) | |
|
164 | { | |
|
165 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
|
166 | this->scanDone=true; | |
|
167 | } | |
|
168 | break; | |
|
169 | } | |
|
170 | } | |
|
171 | } | |
|
172 | else | |
|
173 | { | |
|
174 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); | |
|
175 | this->port = (rs232port_t)NULL; | |
|
176 | this->Connected = false; | |
|
177 | emit this->activateSig(false); | |
|
178 | return; | |
|
179 | } | |
|
180 | if(this->Connected == false) | |
|
181 | { | |
|
182 | SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); | |
|
183 | rs232close(this->port); | |
|
184 | this->port = (rs232port_t)NULL; | |
|
185 | emit this->activateSig(false); | |
|
186 | } | |
|
187 | ||
|
188 | } | |
|
189 | ||
|
190 | bool ahbuartplugin::open(QString PortName,int baudrate) | |
|
191 | { | |
|
192 | if(this->port!=(rs232port_t)NULL) | |
|
193 | this->close(); | |
|
194 | this->UI->setconfig(PortName,baudrate); | |
|
195 | this->connectPort(PortName,baudrate); | |
|
196 | return (this->port!=(rs232port_t)NULL); | |
|
197 | } | |
|
198 | ||
|
199 | void ahbuartplugin::close() | |
|
200 | { | |
|
201 | if(this->port!=(rs232port_t)NULL) | |
|
202 | { | |
|
203 | rs232close(this->port); | |
|
204 | this->port = (rs232port_t)NULL; | |
|
205 | this->Connected = false; | |
|
206 | emit this->activateSig(false); | |
|
207 | } | |
|
208 | } | |
|
209 | ||
|
210 | void ahbuartplugin::togglePort(QString PortName,int baudrate) | |
|
211 | { | |
|
212 | if(this->port!=(rs232port_t)NULL) | |
|
213 | { | |
|
214 | this->close(); | |
|
215 | } | |
|
216 | else | |
|
217 | { | |
|
218 | this->connectPort(PortName,baudrate); | |
|
219 | } | |
|
220 | } | |
|
221 | ||
|
222 | ||
|
223 | unsigned int ahbuartplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
224 | { | |
|
225 | QTime timeout; | |
|
226 | timeout.start(); | |
|
227 | unsigned int read=0; | |
|
228 | unsigned int cnt=count; | |
|
229 | unsigned int nextUpdateTrig=0,updateStep=512; | |
|
230 | SocExplorerEngine::message(this,QString("Read ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); | |
|
231 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) | |
|
232 | { | |
|
233 | if(!this->portMutex->tryLock()) | |
|
234 | return 0; | |
|
235 | if(!this->checkConnection()) | |
|
236 | { | |
|
237 | this->Connected = false; | |
|
238 | emit this->activateSig(false); | |
|
239 | this->portMutex->unlock(); | |
|
240 | return 0; | |
|
241 | } | |
|
242 | QProgressBar* progress=NULL; | |
|
243 | if(cnt>128) | |
|
244 | progress= SocExplorerEngine::getProgressBar("Reading on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
|
245 | char CMD[5]; | |
|
246 | char* result = (char*)malloc(count*4); | |
|
247 | while(count>32) | |
|
248 | { | |
|
249 | CMD[0] = 0x80 | (32-1); | |
|
250 | CMD[1] = (char)((address>>24)&0xFF); | |
|
251 | CMD[2] = (char)((address>>16)&0xFF); | |
|
252 | CMD[3] = (char)((address>>8)&0xFF); | |
|
253 | CMD[4] = (char)((address)&0xFF); | |
|
254 | // APENDTABLETOLOG(CMD,5,logmessage,"Write CMD : "); | |
|
255 | SAFEWRITE(CMD,5,timeout,1000,return 0); | |
|
256 | SAFEREAD(result+((cnt-count)*4),32*4,timeout,1000,return 0); | |
|
257 | // APENDTABLETOLOG((result+((cnt-count)*4)),32*4,logmessage, QString("Get ") + QString::number(32*4) + " Bytes : "); | |
|
258 | count-=32; | |
|
259 | address+=32*4; | |
|
260 | if(cnt>128) | |
|
261 | { | |
|
262 | ||
|
263 | if((cnt-count)>=nextUpdateTrig) | |
|
264 | { | |
|
265 | progress->setValue(cnt-count); | |
|
266 | qApp->processEvents(); | |
|
267 | nextUpdateTrig+=updateStep; | |
|
268 | } | |
|
269 | } | |
|
270 | } | |
|
271 | if(count>0) | |
|
272 | { | |
|
273 | CMD[0] = 0x80 | (count-1); | |
|
274 | CMD[1] = (char)((address>>24)&0xFF); | |
|
275 | CMD[2] = (char)((address>>16)&0xFF); | |
|
276 | CMD[3] = (char)((address>>8)&0xFF); | |
|
277 | CMD[4] = (char)((address)&0xFF); | |
|
278 | SAFEWRITE(CMD,5,timeout,1000,return 0); | |
|
279 | SAFEREAD(result+((cnt-count)*4),(count*4),timeout,1000,return 0); | |
|
280 | // APENDTABLETOLOG((result+((cnt-count)*4)),(count*4),logmessage, QString("Get ") + QString::number(32*4) + " Bytes : "); | |
|
281 | } | |
|
282 | if(cnt>128) | |
|
283 | { | |
|
284 | progress->setValue(cnt-count); | |
|
285 | qApp->processEvents(); | |
|
286 | } | |
|
287 | for(int i=0;(unsigned int)i<cnt;i++) | |
|
288 | { | |
|
289 | for(int j =0;j<4;j++) | |
|
290 | { | |
|
291 | Value[i]= ((unsigned char)(result[i*4+j])) + Value[i]*256; | |
|
292 | } | |
|
293 | read = cnt*4; | |
|
294 | ||
|
295 | } | |
|
296 | if(cnt>128) | |
|
297 | SocExplorerEngine::deleteProgressBar(progress); | |
|
298 | free(result); | |
|
299 | this->portMutex->unlock(); | |
|
300 | } | |
|
301 | return read/4; | |
|
302 | } | |
|
303 | ||
|
304 | unsigned int ahbuartplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
|
305 | { | |
|
306 | QTime timeout; | |
|
307 | timeout.start(); | |
|
308 | unsigned int writen=0; | |
|
309 | unsigned int nextUpdateTrig=0,updateStep=512; | |
|
310 | SocExplorerEngine::message(this,QString("Write ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); | |
|
311 | if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) | |
|
312 | { | |
|
313 | if(!this->portMutex->tryLock()) | |
|
314 | return 0; | |
|
315 | if(!this->checkConnection()) | |
|
316 | { | |
|
317 | emit this->activateSig(false); | |
|
318 | this->Connected = false; | |
|
319 | this->portMutex->unlock(); | |
|
320 | return 0; | |
|
321 | } | |
|
322 | QProgressBar* progress = NULL; | |
|
323 | if(count>128) | |
|
324 | progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
|
325 | int offset = 0; | |
|
326 | char* CMD= (char*)malloc((32*4)+5); | |
|
327 | while(count>32) | |
|
328 | { | |
|
329 | writen=0; | |
|
330 | CMD[0] = 0xC0 | (32-1); | |
|
331 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); | |
|
332 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); | |
|
333 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); | |
|
334 | CMD[4] = (char)(((unsigned int)address)&0xFF); | |
|
335 | for(int i=0;i<32;i++) | |
|
336 | { | |
|
337 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); | |
|
338 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); | |
|
339 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); | |
|
340 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); | |
|
341 | } | |
|
342 | SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0); | |
|
343 | writen+=32; | |
|
344 | count-=32; | |
|
345 | offset+=32; | |
|
346 | address+=32*4; | |
|
347 | if(offset>=nextUpdateTrig && progress!=NULL) | |
|
348 | { | |
|
349 | progress->setValue(offset); | |
|
350 | qApp->processEvents(); | |
|
351 | nextUpdateTrig +=updateStep; | |
|
352 | } | |
|
353 | ||
|
354 | } | |
|
355 | if(count>0) | |
|
356 | { | |
|
357 | CMD[0] = 0xC0 | (count-1); | |
|
358 | CMD[1] = (char)(((unsigned int)address>>24)&0xFF); | |
|
359 | CMD[2] = (char)(((unsigned int)address>>16)&0xFF); | |
|
360 | CMD[3] = (char)(((unsigned int)address>>8)&0xFF); | |
|
361 | CMD[4] = (char)(((unsigned int)address)&0xFF); | |
|
362 | for(int i=0;(unsigned int) i<(count);i++) | |
|
363 | { | |
|
364 | CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); | |
|
365 | CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); | |
|
366 | CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); | |
|
367 | CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); | |
|
368 | } | |
|
369 | SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0); | |
|
370 | writen+=count; | |
|
371 | } | |
|
372 | if(progress!=NULL) | |
|
373 | { | |
|
374 | progress->setValue(writen); | |
|
375 | qApp->processEvents(); | |
|
376 | SocExplorerEngine::deleteProgressBar(progress); | |
|
377 | } | |
|
378 | free(CMD); | |
|
379 | this->portMutex->unlock(); | |
|
380 | return writen; | |
|
381 | } | |
|
382 | return 0; | |
|
383 | } | |
|
384 | ||
|
385 | ||
|
386 | ||
|
387 | ||
|
388 | void ahbuartplugin::updatePortList() | |
|
389 | { | |
|
390 | if(this->portListcompleter==(QCompleter*)NULL) | |
|
391 | { | |
|
392 | this->portListcompleter=new QCompleter(this); | |
|
393 | this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); | |
|
394 | this->portListcompleterModel = new QStringListModel(this); | |
|
395 | this->portListcompleter->setModel(this->portListcompleterModel); | |
|
396 | this->UI->setCompleter(this->portListcompleter); | |
|
397 | } | |
|
398 | rs232portslist_t* portlist = rs232getportlist(); | |
|
399 | rs232portslist_t* portlistenum = portlist; | |
|
400 | QStringList wordList; | |
|
401 | while(portlistenum!=NULL) | |
|
402 | { | |
|
403 | wordList << portlistenum->name; | |
|
404 | portlistenum = portlistenum->next; | |
|
405 | } | |
|
406 | rs232deleteportlist(portlist); | |
|
407 | this->portListcompleterModel->setStringList(wordList); | |
|
408 | } | |
|
409 | ||
|
410 | QVariantList ahbuartplugin::ReadBytes(unsigned int address, unsigned int count) | |
|
411 | { | |
|
412 | unsigned int data[(count/4)+1]; | |
|
413 | QVariantList result; | |
|
414 | this->Read(data,(count/4)+1,address); | |
|
415 | for(unsigned int i = 0;i<count/4;i++) | |
|
416 | { | |
|
417 | result.append(QVariant((int)(0x0FF&(data[i]>>24)))); | |
|
418 | result.append(QVariant((int)(0x0FF&(data[i]>>16)))); | |
|
419 | result.append(QVariant((int)(0x0FF&(data[i]>>8)))); | |
|
420 | result.append(QVariant((int)(0x0FF&(data[i])))); | |
|
421 | } | |
|
422 | ||
|
423 | for(int i=0;i<(count%4);i++) | |
|
424 | { | |
|
425 | result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8))))); | |
|
426 | } | |
|
427 | ||
|
428 | return result; | |
|
429 | } | |
|
430 | ||
|
431 | void ahbuartplugin::WriteBytes(unsigned int address, QList<QVariant> dataList) | |
|
432 | { | |
|
433 | unsigned int data[dataList.count()/4]; | |
|
434 | for(int i = 0;i<(dataList.count()/4);i++) | |
|
435 | { | |
|
436 | data[i] = 0x0FF & ((unsigned int)dataList.at(4*i).toUInt()); | |
|
437 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+1).toUInt())); | |
|
438 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+2).toUInt())); | |
|
439 | data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+3).toUInt())); | |
|
440 | } | |
|
441 | this->Write(data,dataList.count()/4,address); | |
|
442 | } | |
|
443 | ||
|
444 | ||
|
445 | ||
|
446 | ||
|
447 | ||
|
448 | ||
|
449 | ||
|
450 | ||
|
451 | ||
|
452 | ||
|
453 | ||
|
454 | ||
|
455 | ||
|
456 | ||
|
457 | ||
|
458 | ||
|
459 |
@@ -0,0 +1,133 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AHBUARTPLUGIN_H | |
|
23 | #define AHBUARTPLUGIN_H | |
|
24 | #include <QMenuBar> | |
|
25 | #include <QMenu> | |
|
26 | #include <QAction> | |
|
27 | #include <QLayout> | |
|
28 | #include <QMutex> | |
|
29 | #include <QProgressDialog> | |
|
30 | #include <QStringListModel> | |
|
31 | #include <QTime> | |
|
32 | #include <socexplorerplugin.h> | |
|
33 | #include "ahbuartpluginui.h" | |
|
34 | ||
|
35 | #ifdef WinRs232 | |
|
36 | #include "librs232/RS232.h" | |
|
37 | #else | |
|
38 | #include <RS232.h> | |
|
39 | #undef debug | |
|
40 | #endif | |
|
41 | ||
|
42 | ||
|
43 | ||
|
44 | ||
|
45 | #define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message) | |
|
46 | ||
|
47 | #define APENDTABLETOLOG(table,size,Qstr,message) \ | |
|
48 | Qstr.clear();\ | |
|
49 | Qstr+=message;\ | |
|
50 | for(int __i__tbllog__=0;(unsigned int)__i__tbllog__<size;__i__tbllog__++)\ | |
|
51 | {\ | |
|
52 | if(__i__tbllog__%16==0) Qstr += "\n"; \ | |
|
53 | Qstr += "0x" + QString::number((int)(0xff & table[__i__tbllog__]),16) +"\t";\ | |
|
54 | }\ | |
|
55 | APPENDTOLOG(Qstr); | |
|
56 | ||
|
57 | ||
|
58 | #define SAFEWRITE(data,count,timer,timeout,error) \ | |
|
59 | while(1)\ | |
|
60 | {\ | |
|
61 | unsigned int __writen__=0; \ | |
|
62 | (timer).restart(); \ | |
|
63 | while(__writen__!=(count)) \ | |
|
64 | {\ | |
|
65 | __writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \ | |
|
66 | if((timer).elapsed()>(timeout)) \ | |
|
67 | {\ | |
|
68 | APPENDTOLOG(QString("Timeout error while writing"));\ | |
|
69 | this->port = (rs232port_t)NULL; \ | |
|
70 | this->Connected = false; \ | |
|
71 | emit this->activateSig(false); \ | |
|
72 | error; \ | |
|
73 | } \ | |
|
74 | } \ | |
|
75 | break;\ | |
|
76 | } | |
|
77 | ||
|
78 | ||
|
79 | #define SAFEREAD(data,count,timer,timeout,error) \ | |
|
80 | unsigned int __read__=0; \ | |
|
81 | (timer).restart(); \ | |
|
82 | while(__read__ != (count)) \ | |
|
83 | { \ | |
|
84 | __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \ | |
|
85 | if((timer).elapsed()>(timeout)) \ | |
|
86 | { \ | |
|
87 | APPENDTOLOG(QString("Timeout error while reading"));\ | |
|
88 | this->Connected = false; \ | |
|
89 | emit this->activateSig(false); \ | |
|
90 | this->portMutex->unlock(); \ | |
|
91 | error; \ | |
|
92 | } \ | |
|
93 | } \ | |
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | class ahbuartplugin : public socexplorerplugin | |
|
98 | { | |
|
99 | Q_OBJECT | |
|
100 | public: | |
|
101 | ahbuartplugin(QWidget *parent = 0); | |
|
102 | ~ahbuartplugin(); | |
|
103 | int registermenu(QMainWindow *menuHolder); | |
|
104 | int VID(){return driver_VID;} | |
|
105 | int PID(){return driver_PID;} | |
|
106 | ||
|
107 | public slots: | |
|
108 | void togglePort(QString PortName,int baudrate); | |
|
109 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
110 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
111 | void closeMe(); | |
|
112 | void close(); | |
|
113 | bool open(QString PortName,int baudrate); | |
|
114 | void updatePortList(); | |
|
115 | QVariantList ReadBytes(unsigned int address,unsigned int count); | |
|
116 | void WriteBytes(unsigned int address,QList<QVariant> dataList); | |
|
117 | signals: | |
|
118 | void setProgressValue(int progress); | |
|
119 | private: | |
|
120 | bool scanDone; | |
|
121 | QProgressDialog* progress; | |
|
122 | QLayout * mainLayout; | |
|
123 | ahbUartPluginUI* UI; | |
|
124 | QMutex* portMutex; | |
|
125 | rs232port_t port; | |
|
126 | QCompleter *portListcompleter; | |
|
127 | QStringListModel *portListcompleterModel; | |
|
128 | void connectPort(QString PortName,int baudrate); | |
|
129 | bool checkConnection(); | |
|
130 | ||
|
131 | }; | |
|
132 | ||
|
133 | #endif // AHBUARTPLUGIN_H |
@@ -0,0 +1,80 | |||
|
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 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | TARGET = ahbuartplugin$${DEBUG_EXT} | |
|
16 | DEFINES += PLUGIN=ahbuartplugin | |
|
17 | DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\" | |
|
18 | DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\" | |
|
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
|
20 | DEFINES += driver_Version="\"\\\"1.3.2"\\\"\" | |
|
21 | DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\" | |
|
22 | DEFINES += driver_can_be_root=1 | |
|
23 | DEFINES += driver_can_be_child=0 | |
|
24 | DEFINES += driver_VID=0 | |
|
25 | DEFINES += driver_PID=0 | |
|
26 | ||
|
27 | ||
|
28 | ||
|
29 | win32:LIBS += $${PWD}/librs232/bin/librs232-2.1.a | |
|
30 | unix:LIBS += -lrs232-2.1 | |
|
31 | ||
|
32 | ||
|
33 | INCLUDEPATH += \ | |
|
34 | $${PWD} | |
|
35 | ||
|
36 | ||
|
37 | HEADERS += \ | |
|
38 | ahbuartplugin.h \ | |
|
39 | ahbuartpluginui.h \ | |
|
40 | ahbuartpywrapper.h \ | |
|
41 | ahbuartpywrapper.h | |
|
42 | ||
|
43 | ||
|
44 | ||
|
45 | win32:HEADERS+=librs232/RS232.h | |
|
46 | win32:INCLUDEPATH+=librs232 | |
|
47 | ||
|
48 | SOURCES += \ | |
|
49 | ahbuartplugin.cpp \ | |
|
50 | ahbuartpluginui.cpp \ | |
|
51 | ahbuartpywrapper.cpp | |
|
52 | ||
|
53 | ||
|
54 | OTHER_FILES += \ | |
|
55 | librs232/bin/librs232-1.0-1.dll | |
|
56 | ||
|
57 | FORMS += \ | |
|
58 | ahbuartpluginui.ui | |
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 |
@@ -0,0 +1,124 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ahbuartpluginui.h" | |
|
23 | #include "ui_ahbuartpluginui.h" | |
|
24 | ||
|
25 | ahbUartPluginUI::ahbUartPluginUI(QWidget *parent) : | |
|
26 | QWidget(parent), | |
|
27 | ui(new Ui::ahbUartPluginUI) | |
|
28 | { | |
|
29 | ui->setupUi(this); | |
|
30 | connect(ui->OpenPort,SIGNAL(clicked()),this,SLOT(connectPort())); | |
|
31 | connect(ui->PortspeedSlider,SIGNAL(valueChanged(int)),ui->baurateLCD,SLOT(display(int))); | |
|
32 | connect(ui->logFileChooseBp,SIGNAL(clicked()),this,SLOT(chooseLogFile())); | |
|
33 | connect(this,SIGNAL(setLogFileName(QString)),this->ui->logFileName,SLOT(setText(QString))); | |
|
34 | connect(ui->rescanPorts,SIGNAL(clicked()),this,SIGNAL(rescanPorts())); | |
|
35 | this->logFile = new QFile(); | |
|
36 | } | |
|
37 | ||
|
38 | void ahbUartPluginUI::connectPort() | |
|
39 | { | |
|
40 | emit this->connectPortsig(ui->PortName->text(),ui->PortspeedSlider->value()); | |
|
41 | } | |
|
42 | ||
|
43 | void ahbUartPluginUI::setConnected(bool connected) | |
|
44 | { | |
|
45 | if(connected == true) | |
|
46 | { | |
|
47 | ui->OpenPort->setText(tr("Close port")); | |
|
48 | } | |
|
49 | else | |
|
50 | ui->OpenPort->setText(tr("Open port")); | |
|
51 | } | |
|
52 | ||
|
53 | ||
|
54 | ahbUartPluginUI::~ahbUartPluginUI() | |
|
55 | { | |
|
56 | delete ui; | |
|
57 | } | |
|
58 | ||
|
59 | ||
|
60 | void ahbUartPluginUI::chooseLogFile() | |
|
61 | { | |
|
62 | if(this->logFile->isOpen()) | |
|
63 | this->logFile->close(); | |
|
64 | this->logFile->setFileName(QFileDialog::getSaveFileName(this,tr("Open Log file"),QDir::homePath(), tr("Log Files (*.txt *.log)"))); | |
|
65 | if(this->logFile->open(QIODevice::WriteOnly)) | |
|
66 | { | |
|
67 | this->logFileStrm = new QTextStream(this->logFile); | |
|
68 | emit this->setLogFileName(this->logFile->fileName()); | |
|
69 | } | |
|
70 | } | |
|
71 | ||
|
72 | void ahbUartPluginUI::setconfig(QString PortName, int baudrate) | |
|
73 | { | |
|
74 | this->ui->PortName->setText(PortName); | |
|
75 | this->ui->PortspeedSlider->setValue(baudrate); | |
|
76 | } | |
|
77 | ||
|
78 | ||
|
79 | void ahbUartPluginUI::logFileEnDisable(int state) | |
|
80 | { | |
|
81 | if(state==Qt::Checked) | |
|
82 | { | |
|
83 | this->logFileEn = true; | |
|
84 | } | |
|
85 | else if(state==Qt::Unchecked) | |
|
86 | { | |
|
87 | this->logFileEn = false; | |
|
88 | } | |
|
89 | } | |
|
90 | ||
|
91 | bool ahbUartPluginUI::islogfileenable() | |
|
92 | { | |
|
93 | return this->logFileEn; | |
|
94 | } | |
|
95 | ||
|
96 | void ahbUartPluginUI::appendToLogFile(const QString & text) | |
|
97 | { | |
|
98 | if(this->logFileEn && this->logFile->isOpen()) | |
|
99 | { | |
|
100 | *(this->logFileStrm) << text << endl; | |
|
101 | } | |
|
102 | } | |
|
103 | ||
|
104 | void ahbUartPluginUI::setCompleter(QCompleter *completer) | |
|
105 | { | |
|
106 | this->ui->PortName->setCompleter(completer); | |
|
107 | } | |
|
108 | ||
|
109 | void ahbUartPluginUI::closeEvent(QCloseEvent *event) | |
|
110 | { | |
|
111 | if(this->logFile->isOpen()) | |
|
112 | { | |
|
113 | this->logFileStrm->flush(); | |
|
114 | this->logFile->waitForBytesWritten(3000); | |
|
115 | this->logFile->close(); | |
|
116 | } | |
|
117 | event->accept(); | |
|
118 | } | |
|
119 | ||
|
120 | ||
|
121 | ||
|
122 | ||
|
123 | ||
|
124 |
@@ -0,0 +1,71 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AHBUARTPLUGINUI_H | |
|
23 | #define AHBUARTPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QFile> | |
|
27 | #include <QTextStream> | |
|
28 | #include <QFileDialog> | |
|
29 | #include <QDir> | |
|
30 | #include <QCloseEvent> | |
|
31 | #include <QCompleter> | |
|
32 | ||
|
33 | namespace Ui { | |
|
34 | class ahbUartPluginUI; | |
|
35 | } | |
|
36 | ||
|
37 | class ahbUartPluginUI : public QWidget | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | ||
|
41 | public: | |
|
42 | explicit ahbUartPluginUI(QWidget *parent = 0); | |
|
43 | ~ahbUartPluginUI(); | |
|
44 | bool islogfileenable(); | |
|
45 | void appendToLogFile(const QString & text); | |
|
46 | void closeEvent(QCloseEvent *event); | |
|
47 | void setCompleter(QCompleter* completer); | |
|
48 | public slots: | |
|
49 | void setConnected(bool connected); | |
|
50 | void connectPort(); | |
|
51 | void chooseLogFile(); | |
|
52 | void logFileEnDisable(int state); | |
|
53 | void setconfig(QString PortName,int baudrate); | |
|
54 | ||
|
55 | signals: | |
|
56 | void connectPortsig(QString PortName,int baudrate); | |
|
57 | void setLogFileName(QString FileName); | |
|
58 | void rescanPorts(); | |
|
59 | private: | |
|
60 | Ui::ahbUartPluginUI *ui; | |
|
61 | QFile* logFile; | |
|
62 | QTextStream* logFileStrm; | |
|
63 | bool logFileEn; | |
|
64 | }; | |
|
65 | ||
|
66 | #endif // AHBUARTPLUGINUI_H | |
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | ||
|
71 |
@@ -0,0 +1,111 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>ahbUartPluginUI</class> | |
|
4 | <widget class="QWidget" name="ahbUartPluginUI"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>947</width> | |
|
10 | <height>279</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="windowTitle"> | |
|
14 | <string>Form</string> | |
|
15 | </property> | |
|
16 | <layout class="QGridLayout" name="gridLayout_2"> | |
|
17 | <item row="1" column="1"> | |
|
18 | <widget class="QSlider" name="PortspeedSlider"> | |
|
19 | <property name="maximum"> | |
|
20 | <number>3000000</number> | |
|
21 | </property> | |
|
22 | <property name="singleStep"> | |
|
23 | <number>9600</number> | |
|
24 | </property> | |
|
25 | <property name="pageStep"> | |
|
26 | <number>1</number> | |
|
27 | </property> | |
|
28 | <property name="value"> | |
|
29 | <number>921600</number> | |
|
30 | </property> | |
|
31 | <property name="orientation"> | |
|
32 | <enum>Qt::Horizontal</enum> | |
|
33 | </property> | |
|
34 | </widget> | |
|
35 | </item> | |
|
36 | <item row="0" column="1"> | |
|
37 | <widget class="QLineEdit" name="PortName"/> | |
|
38 | </item> | |
|
39 | <item row="3" column="2"> | |
|
40 | <widget class="QPushButton" name="OpenPort"> | |
|
41 | <property name="text"> | |
|
42 | <string>Open Port</string> | |
|
43 | </property> | |
|
44 | </widget> | |
|
45 | </item> | |
|
46 | <item row="2" column="0"> | |
|
47 | <widget class="QCheckBox" name="logEnableChkBx"> | |
|
48 | <property name="text"> | |
|
49 | <string>Enable Logs</string> | |
|
50 | </property> | |
|
51 | </widget> | |
|
52 | </item> | |
|
53 | <item row="2" column="1"> | |
|
54 | <widget class="QPushButton" name="logFileChooseBp"> | |
|
55 | <property name="text"> | |
|
56 | <string>Choose file</string> | |
|
57 | </property> | |
|
58 | </widget> | |
|
59 | </item> | |
|
60 | <item row="0" column="2"> | |
|
61 | <widget class="QPushButton" name="rescanPorts"> | |
|
62 | <property name="text"> | |
|
63 | <string>SCAN</string> | |
|
64 | </property> | |
|
65 | </widget> | |
|
66 | </item> | |
|
67 | <item row="0" column="0"> | |
|
68 | <widget class="QLabel" name="label"> | |
|
69 | <property name="text"> | |
|
70 | <string>Port Name</string> | |
|
71 | </property> | |
|
72 | </widget> | |
|
73 | </item> | |
|
74 | <item row="1" column="0"> | |
|
75 | <widget class="QLabel" name="label_2"> | |
|
76 | <property name="text"> | |
|
77 | <string>Port Speed</string> | |
|
78 | </property> | |
|
79 | </widget> | |
|
80 | </item> | |
|
81 | <item row="3" column="0" colspan="2"> | |
|
82 | <widget class="QLabel" name="logFileName"> | |
|
83 | <property name="text"> | |
|
84 | <string/> | |
|
85 | </property> | |
|
86 | </widget> | |
|
87 | </item> | |
|
88 | <item row="1" column="2"> | |
|
89 | <widget class="QLCDNumber" name="baurateLCD"> | |
|
90 | <property name="font"> | |
|
91 | <font> | |
|
92 | <weight>75</weight> | |
|
93 | <bold>true</bold> | |
|
94 | </font> | |
|
95 | </property> | |
|
96 | <property name="numDigits"> | |
|
97 | <number>7</number> | |
|
98 | </property> | |
|
99 | <property name="digitCount"> | |
|
100 | <number>7</number> | |
|
101 | </property> | |
|
102 | <property name="segmentStyle"> | |
|
103 | <enum>QLCDNumber::Flat</enum> | |
|
104 | </property> | |
|
105 | </widget> | |
|
106 | </item> | |
|
107 | </layout> | |
|
108 | </widget> | |
|
109 | <resources/> | |
|
110 | <connections/> | |
|
111 | </ui> |
@@ -0,0 +1,32 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ahbuartpywrapper.h" | |
|
23 | #include <QObject> | |
|
24 | #include <QFile> | |
|
25 | #include <QTextStream> | |
|
26 | #include <byteswap.h> | |
|
27 | #include <stdint.h> | |
|
28 | ||
|
29 | ahbuartPywrapper::ahbuartPywrapper(socexplorerplugin *parent) : | |
|
30 | genericPySysdriver(parent) | |
|
31 | { | |
|
32 | } |
@@ -0,0 +1,23 | |||
|
1 | #ifndef AHBUARTPYWRAPPER_H | |
|
2 | #define AHBUARTPYWRAPPER_H | |
|
3 | #include <genericPySysdriver.h> | |
|
4 | #include <QString> | |
|
5 | ||
|
6 | class ahbuartPywrapper : public genericPySysdriver | |
|
7 | { | |
|
8 | Q_OBJECT | |
|
9 | public: | |
|
10 | explicit ahbuartPywrapper(socexplorerplugin *parent = 0); | |
|
11 | ||
|
12 | signals: | |
|
13 | bool open(QString PortName,int baudrate); | |
|
14 | void close(); | |
|
15 | QVariantList ReadBytes(unsigned int address,unsigned int count); | |
|
16 | void WriteBytes(unsigned int address,QList<QVariant> dataList); | |
|
17 | public slots: | |
|
18 | // bool dumpMemory(unsigned int address,unsigned int count,QString file); | |
|
19 | // bool memSet(unsigned int address,int value, unsigned int count); | |
|
20 | // bool loadbin(unsigned int address,QString file); | |
|
21 | }; | |
|
22 | ||
|
23 | #endif // AHBUARTPYWRAPPER_H |
@@ -0,0 +1,52 | |||
|
1 | // SOPSUYSI_RS232.h | |
|
2 | #ifndef RS232_H | |
|
3 | #define RS232_H | |
|
4 | //#define debug | |
|
5 | ||
|
6 | #define badPortValue -1 | |
|
7 | #define rs232noerr 0 | |
|
8 | typedef int rs232port_t; | |
|
9 | typedef int rs232speed_t; | |
|
10 | typedef enum {rs232OneStop,rs232One5Stop,rs232TwoStop}rs232stop; | |
|
11 | typedef enum {rs232parityNo,rs232parityOdd,rs232parityEven}rs232parity; | |
|
12 | ||
|
13 | #ifdef __cplusplus | |
|
14 | extern "C" { | |
|
15 | #endif | |
|
16 | typedef struct rs232portslist_t | |
|
17 | { | |
|
18 | char* name; | |
|
19 | struct rs232portslist_t* next; | |
|
20 | }rs232portslist_t; | |
|
21 | #ifdef __cplusplus | |
|
22 | } | |
|
23 | #endif | |
|
24 | ||
|
25 | ||
|
26 | #ifdef __cplusplus | |
|
27 | #define rs232extern extern "C" | |
|
28 | #else | |
|
29 | #define rs232extern extern | |
|
30 | #endif | |
|
31 | rs232extern rs232port_t rs232open(char* psPortName); | |
|
32 | rs232extern rs232portslist_t* rs232getportlist(); | |
|
33 | rs232extern void rs232deleteportlist(rs232portslist_t* list); | |
|
34 | rs232extern int rs232close(rs232port_t fd); | |
|
35 | rs232extern int rs232setup(rs232port_t fd, int ChSize, int BaudeRate, rs232parity Parity, rs232stop NbStop); | |
|
36 | rs232extern int rs232write(rs232port_t fd,char *psWrite, int WriteBufferSize); | |
|
37 | rs232extern int rs232read(rs232port_t fd,char *psRead, int ReadBufferSize); | |
|
38 | rs232extern int rs232setparity(rs232port_t fd, rs232parity Parity); | |
|
39 | rs232extern int rs232setnbstop(rs232port_t fd, rs232stop NbStop); | |
|
40 | rs232extern int rs232setcsize(rs232port_t fd, int ChSize); | |
|
41 | rs232extern int rs232setbaudrate(rs232port_t fd, int baudrate); | |
|
42 | rs232extern int rs232setRTS(rs232port_t fd); | |
|
43 | rs232extern int rs232clearRTS(rs232port_t fd); | |
|
44 | rs232extern int rs232setDTR(rs232port_t fd); | |
|
45 | rs232extern int rs232clearDTR(rs232port_t fd); | |
|
46 | rs232extern int rs232saferead(rs232port_t fd,char* data,int count ); | |
|
47 | rs232extern int rs232safewrite(rs232port_t fd,char* data,int count); | |
|
48 | ||
|
49 | #endif | |
|
50 | ||
|
51 | ||
|
52 |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,87 | |||
|
1 | /* src/rs232config.h. Generated from rs232config.h.in by configure. */ | |
|
2 | /* src/rs232config.h.in. Generated from configure.ac by autoheader. */ | |
|
3 | ||
|
4 | /* Define to 1 if you have the <dirent.h> header file. */ | |
|
5 | #define HAVE_DIRENT_H 1 | |
|
6 | ||
|
7 | /* Define to 1 if you have the <dlfcn.h> header file. */ | |
|
8 | /* #undef HAVE_DLFCN_H */ | |
|
9 | ||
|
10 | /* Define to 1 if you have the <errno.h> header file. */ | |
|
11 | #define HAVE_ERRNO_H 1 | |
|
12 | ||
|
13 | /* Define to 1 if you have the <fcntl.h> header file. */ | |
|
14 | #define HAVE_FCNTL_H 1 | |
|
15 | ||
|
16 | /* Define to 1 if you have the <inttypes.h> header file. */ | |
|
17 | #define HAVE_INTTYPES_H 1 | |
|
18 | ||
|
19 | /* Define to 1 if you have the <memory.h> header file. */ | |
|
20 | #define HAVE_MEMORY_H 1 | |
|
21 | ||
|
22 | /* Define to 1 if you have the <stdint.h> header file. */ | |
|
23 | #define HAVE_STDINT_H 1 | |
|
24 | ||
|
25 | /* Define to 1 if you have the <stdio.h> header file. */ | |
|
26 | #define HAVE_STDIO_H 1 | |
|
27 | ||
|
28 | /* Define to 1 if you have the <stdlib.h> header file. */ | |
|
29 | #define HAVE_STDLIB_H 1 | |
|
30 | ||
|
31 | /* Define to 1 if you have the <strings.h> header file. */ | |
|
32 | #define HAVE_STRINGS_H 1 | |
|
33 | ||
|
34 | /* Define to 1 if you have the <string.h> header file. */ | |
|
35 | #define HAVE_STRING_H 1 | |
|
36 | ||
|
37 | /* Define to 1 if you have the <sys/stat.h> header file. */ | |
|
38 | #define HAVE_SYS_STAT_H 1 | |
|
39 | ||
|
40 | /* Define to 1 if you have the <sys/types.h> header file. */ | |
|
41 | #define HAVE_SYS_TYPES_H 1 | |
|
42 | ||
|
43 | /* Define to 1 if you have the <termios.h> header file. */ | |
|
44 | /* #undef HAVE_TERMIOS_H */ | |
|
45 | ||
|
46 | /* Define to 1 if you have the <termio.h> header file. */ | |
|
47 | /* #undef HAVE_TERMIO_H */ | |
|
48 | ||
|
49 | /* Define to 1 if you have the <unistd.h> header file. */ | |
|
50 | #define HAVE_UNISTD_H 1 | |
|
51 | ||
|
52 | /* Define to 1 if you have the <windows.h> header file. */ | |
|
53 | #define HAVE_WINDOWS_H 1 | |
|
54 | ||
|
55 | /* Define to the sub-directory in which libtool stores uninstalled libraries. | |
|
56 | */ | |
|
57 | #define LT_OBJDIR ".libs/" | |
|
58 | ||
|
59 | /* Name of package */ | |
|
60 | #define PACKAGE "rs232" | |
|
61 | ||
|
62 | /* Define to the address where bug reports for this package should be sent. */ | |
|
63 | #define PACKAGE_BUGREPORT "alexis.jeandet@lpp.polytechnique.fr" | |
|
64 | ||
|
65 | /* Define to the full name of this package. */ | |
|
66 | #define PACKAGE_NAME "librs232" | |
|
67 | ||
|
68 | /* Define to the full name and version of this package. */ | |
|
69 | #define PACKAGE_STRING "librs232 2.1.0" | |
|
70 | ||
|
71 | /* Define to the one symbol short name of this package. */ | |
|
72 | #define PACKAGE_TARNAME "rs232" | |
|
73 | ||
|
74 | /* Define to the home page for this package. */ | |
|
75 | #define PACKAGE_URL "http://www.lpp.fr" | |
|
76 | ||
|
77 | /* Define to the version of this package. */ | |
|
78 | #define PACKAGE_VERSION "2.1.0" | |
|
79 | ||
|
80 | /* Define to 1 if you have the ANSI C header files. */ | |
|
81 | #define STDC_HEADERS 1 | |
|
82 | ||
|
83 | /* Version number of package */ | |
|
84 | #define VERSION "2.1.0" | |
|
85 | ||
|
86 | /* Define to empty if `const' does not conform to ANSI C. */ | |
|
87 | /* #undef const */ |
@@ -0,0 +1,74 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ahbdevicelist.h" | |
|
23 | ||
|
24 | ||
|
25 | ||
|
26 | ahbdevicelist::ahbdevicelist(QWidget *parent):QTableWidget(parent) | |
|
27 | { | |
|
28 | this->setColumnCount(7); | |
|
29 | this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID")); | |
|
30 | } | |
|
31 | ||
|
32 | void ahbdevicelist::clearAHBdevicesList() | |
|
33 | { | |
|
34 | this->clear(); | |
|
35 | this->setRowCount(0); | |
|
36 | this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID")); | |
|
37 | } | |
|
38 | ||
|
39 | void ahbdevicelist::addAHBdevice(ahbdeviceInfo* device) | |
|
40 | { | |
|
41 | if(this->rowCount()==0) | |
|
42 | { | |
|
43 | this->setRowCount(1); | |
|
44 | } | |
|
45 | else | |
|
46 | { | |
|
47 | this->insertRow(this->rowCount()); | |
|
48 | } | |
|
49 | ||
|
50 | this->ahbdevices.append(device); | |
|
51 | QTableWidgetItem *newItem = new QTableWidgetItem(*device->deviceName); | |
|
52 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
53 | this->setItem(this->rowCount()-1, 0, newItem); | |
|
54 | ||
|
55 | for(int i=0;i<4;i++) | |
|
56 | { | |
|
57 | if(device->BAR[i].size!=0) | |
|
58 | { | |
|
59 | newItem = new QTableWidgetItem("0x" + QString::number(device->BAR[i].address, 16)+" -> 0x"+ QString::number(device->BAR[i].address + device->BAR[i].size-1, 16)+" size = "+device->barAdressSize(i)); | |
|
60 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
61 | this->setItem(this->rowCount()-1, i+1, newItem); | |
|
62 | } | |
|
63 | ||
|
64 | } | |
|
65 | ||
|
66 | newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16)); | |
|
67 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
68 | this->setItem(this->rowCount()-1, 5, newItem); | |
|
69 | newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16)); | |
|
70 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
71 | this->setItem(this->rowCount()-1, 6, newItem); | |
|
72 | this->resizeColumnsToContents(); | |
|
73 | ||
|
74 | } |
@@ -0,0 +1,104 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AHBDEVICELIST_H | |
|
23 | #define AHBDEVICELIST_H | |
|
24 | #include <QTableWidget> | |
|
25 | #include <QString> | |
|
26 | #include <QList> | |
|
27 | ||
|
28 | typedef struct | |
|
29 | { | |
|
30 | unsigned int address; | |
|
31 | unsigned int size; | |
|
32 | unsigned char type; | |
|
33 | bool prefectchable; | |
|
34 | bool cacheable; | |
|
35 | ||
|
36 | }AHBbarreg; | |
|
37 | ||
|
38 | class ahbdeviceInfo | |
|
39 | { | |
|
40 | public: | |
|
41 | ahbdeviceInfo() | |
|
42 | { | |
|
43 | } | |
|
44 | ||
|
45 | ahbdeviceInfo(const QString deviceName,AHBbarreg BAR0,AHBbarreg BAR1, AHBbarreg BAR2,AHBbarreg BAR3,int VID,int PID) | |
|
46 | { | |
|
47 | this->deviceName = new QString(deviceName); | |
|
48 | this->BAR[0]=BAR0; | |
|
49 | this->BAR[1]=BAR1; | |
|
50 | this->BAR[2]=BAR2; | |
|
51 | this->BAR[3]=BAR3; | |
|
52 | this->VID = VID; | |
|
53 | this->PID = PID; | |
|
54 | } | |
|
55 | QString barAdressSize(int barIndex) | |
|
56 | { | |
|
57 | int k=0; | |
|
58 | unsigned int size=this->BAR[barIndex].size; | |
|
59 | while(size>=1024){size=size>>10;k++;} | |
|
60 | switch(k) | |
|
61 | { | |
|
62 | case 0: | |
|
63 | return (QString::number(size, 10) + "B"); | |
|
64 | break; | |
|
65 | case 1: | |
|
66 | return (QString::number(size, 10) + "kB"); | |
|
67 | break; | |
|
68 | case 2: | |
|
69 | return (QString::number(size, 10) + "MB"); | |
|
70 | break; | |
|
71 | case 3: | |
|
72 | return (QString::number(size, 10) + "GB"); | |
|
73 | break; | |
|
74 | case 4: | |
|
75 | return (QString::number(size, 10) + "TB"); | |
|
76 | break; | |
|
77 | default: | |
|
78 | return (QString::number(this->BAR[barIndex].size, 10) + "B"); | |
|
79 | break; | |
|
80 | } | |
|
81 | } | |
|
82 | QString* deviceName; | |
|
83 | AHBbarreg BAR[4]; | |
|
84 | int VID; | |
|
85 | int PID; | |
|
86 | }; | |
|
87 | ||
|
88 | class ahbdevicelist: public QTableWidget | |
|
89 | { | |
|
90 | Q_OBJECT | |
|
91 | public: | |
|
92 | explicit ahbdevicelist(QWidget * parent = 0); | |
|
93 | ||
|
94 | public slots: | |
|
95 | void addAHBdevice(ahbdeviceInfo* device); | |
|
96 | void clearAHBdevicesList(); | |
|
97 | ||
|
98 | private: | |
|
99 | QList<ahbdeviceInfo*> ahbdevices; | |
|
100 | ||
|
101 | ||
|
102 | }; | |
|
103 | ||
|
104 | #endif // AHBDEVICELIST_H |
@@ -0,0 +1,90 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ahbpluginui.h" | |
|
23 | #include <socexplorerengine.h> | |
|
24 | ||
|
25 | ahbPluginUi::ahbPluginUi(socexplorerplugin *plugin, QWidget *parent) : | |
|
26 | QWidget(parent) | |
|
27 | { | |
|
28 | this->mainlayout = new QHBoxLayout; | |
|
29 | this->scanBp = new QPushButton(tr("Scan AHB")); | |
|
30 | this->deviceslst = new ahbdevicelist; | |
|
31 | this->mainlayout->addWidget(this->deviceslst); | |
|
32 | this->mainlayout->addWidget(this->scanBp); | |
|
33 | this->setLayout(this->mainlayout); | |
|
34 | this->_plugin = plugin; | |
|
35 | connect(this,SIGNAL(addAHBdevice(ahbdeviceInfo*)),this->deviceslst,SLOT(addAHBdevice(ahbdeviceInfo*))); | |
|
36 | connect(this,SIGNAL(clearAHBdevicesList()),this->deviceslst,SLOT(clearAHBdevicesList())); | |
|
37 | connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAHB())); | |
|
38 | } | |
|
39 | ||
|
40 | ||
|
41 | ||
|
42 | ahbdeviceInfo* ahbPluginUi::extractInfos(int *pnpregs) | |
|
43 | { | |
|
44 | AHBbarreg BAR[4]; | |
|
45 | ||
|
46 | int VID; | |
|
47 | int PID; | |
|
48 | for(int i=0;i<4;i++) | |
|
49 | { | |
|
50 | BAR[i].address = pnpregs[i+4] & 0xfff00000; | |
|
51 | BAR[i].size = (pnpregs[i+4] & 0x0000fff0)<<16; | |
|
52 | if(BAR[i].size!=0) | |
|
53 | BAR[i].size = (((-1^BAR[i].size)|BAR[i].address)-BAR[i].address)+1; | |
|
54 | BAR[i].cacheable = (bool)((pnpregs[i+4]&0x00010000)>>16); | |
|
55 | BAR[i].prefectchable = (bool)((pnpregs[i+4]&0x00020000)>>17); | |
|
56 | BAR[i].type = (unsigned char)(pnpregs[i+4]&0xf); | |
|
57 | } | |
|
58 | ||
|
59 | VID = (pnpregs[0]>>24)&0xff; | |
|
60 | PID = (pnpregs[0]>>12)&0xfff; | |
|
61 | QString devname = SocExplorerEngine::getDevName(VID,PID); | |
|
62 | return new ahbdeviceInfo(devname,BAR[0],BAR[1],BAR[2],BAR[3],VID,PID); | |
|
63 | } | |
|
64 | ||
|
65 | ||
|
66 | void ahbPluginUi::scanAHB() | |
|
67 | { | |
|
68 | unsigned int size = AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START; | |
|
69 | int j=0; | |
|
70 | unsigned long long i = AHB_PLUGNPLAY_MASTER_START; | |
|
71 | int pnpregs[AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START]; | |
|
72 | emit this->clearAHBdevicesList(); | |
|
73 | if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size) | |
|
74 | { | |
|
75 | while(i<AHB_PLUGNPLAY_SLAVE_STOP) | |
|
76 | { | |
|
77 | if(pnpregs[j]!=0) | |
|
78 | { | |
|
79 | ahbdeviceInfo* devinfo=this->extractInfos(pnpregs+j); | |
|
80 | if(!devinfo->deviceName->compare("DSU3")) | |
|
81 | SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[0].address,*devinfo->deviceName); | |
|
82 | emit this->addAHBdevice(devinfo); | |
|
83 | } | |
|
84 | i+=32; | |
|
85 | j+=8; | |
|
86 | } | |
|
87 | } | |
|
88 | } | |
|
89 | ||
|
90 |
@@ -0,0 +1,59 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AHBPLUGINUI_H | |
|
23 | #define AHBPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QHBoxLayout> | |
|
27 | #include <QPushButton> | |
|
28 | #include "ahbdevicelist.h" | |
|
29 | #include <socexplorerplugin.h> | |
|
30 | #define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000)) | |
|
31 | #define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800)) | |
|
32 | #define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800)) | |
|
33 | ||
|
34 | #define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC)) | |
|
35 | ||
|
36 | ||
|
37 | class ahbPluginUi : public QWidget | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | public: | |
|
41 | explicit ahbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0); | |
|
42 | ahbdeviceInfo* extractInfos(int* pnpregs); | |
|
43 | public slots: | |
|
44 | void scanAHB(); | |
|
45 | signals: | |
|
46 | void addAHBdevice(ahbdeviceInfo* device); | |
|
47 | void clearAHBdevicesList(); | |
|
48 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
49 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
50 | private: | |
|
51 | QHBoxLayout* mainlayout; | |
|
52 | QPushButton* scanBp; | |
|
53 | ahbdevicelist* deviceslst; | |
|
54 | socexplorerplugin* _plugin; | |
|
55 | ||
|
56 | ||
|
57 | }; | |
|
58 | ||
|
59 | #endif // AHBPLUGINUI_H |
@@ -0,0 +1,74 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "apbdevicelist.h" | |
|
23 | ||
|
24 | ||
|
25 | ||
|
26 | apbdevicelist::apbdevicelist(QWidget *parent):QTableWidget(parent) | |
|
27 | { | |
|
28 | this->setColumnCount(4); | |
|
29 | this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("Vendor ID")<<tr("Product ID")); | |
|
30 | } | |
|
31 | ||
|
32 | void apbdevicelist::clearAPBdevicesList() | |
|
33 | { | |
|
34 | this->clear(); | |
|
35 | this->setRowCount(0); | |
|
36 | this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("Vendor ID")<<tr("Product ID")); | |
|
37 | } | |
|
38 | ||
|
39 | void apbdevicelist::addAPBdevice(apbdeviceInfo* device) | |
|
40 | { | |
|
41 | if(this->rowCount()==0) | |
|
42 | { | |
|
43 | this->setRowCount(1); | |
|
44 | } | |
|
45 | else | |
|
46 | { | |
|
47 | this->insertRow(this->rowCount()); | |
|
48 | } | |
|
49 | ||
|
50 | this->apbdevices.append(device); | |
|
51 | QTableWidgetItem *newItem = new QTableWidgetItem(device->deviceName); | |
|
52 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
53 | this->setItem(this->rowCount()-1, 0, newItem); | |
|
54 | ||
|
55 | for(int i=0;i<1;i++) | |
|
56 | { | |
|
57 | if(device->BAR[i].size!=0) | |
|
58 | { | |
|
59 | newItem = new QTableWidgetItem("0x" + QString::number(device->BAR[i].address, 16)+" -> 0x"+ QString::number(device->BAR[i].address + device->BAR[i].size-1, 16)+" size = "+device->barAdressSize(i)); | |
|
60 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
61 | this->setItem(this->rowCount()-1, i+1, newItem); | |
|
62 | } | |
|
63 | ||
|
64 | } | |
|
65 | ||
|
66 | newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16)); | |
|
67 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
68 | this->setItem(this->rowCount()-1, 2, newItem); | |
|
69 | newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16)); | |
|
70 | newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); | |
|
71 | this->setItem(this->rowCount()-1, 3, newItem); | |
|
72 | this->resizeColumnsToContents(); | |
|
73 | ||
|
74 | } |
@@ -0,0 +1,99 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef APBDEVICELIST_H | |
|
23 | #define APBDEVICELIST_H | |
|
24 | #include <QTableWidget> | |
|
25 | #include <QString> | |
|
26 | #include <QList> | |
|
27 | ||
|
28 | typedef struct | |
|
29 | { | |
|
30 | unsigned int address; | |
|
31 | unsigned int size; | |
|
32 | unsigned char type; | |
|
33 | ||
|
34 | }APBbarreg; | |
|
35 | ||
|
36 | class apbdeviceInfo | |
|
37 | { | |
|
38 | public: | |
|
39 | apbdeviceInfo() | |
|
40 | { | |
|
41 | } | |
|
42 | ||
|
43 | apbdeviceInfo(const QString deviceName,APBbarreg BAR0,int VID,int PID) | |
|
44 | { | |
|
45 | this->deviceName = deviceName; | |
|
46 | this->BAR[0]=BAR0; | |
|
47 | this->VID = VID; | |
|
48 | this->PID = PID; | |
|
49 | } | |
|
50 | QString barAdressSize(int barIndex) | |
|
51 | { | |
|
52 | int k=0; | |
|
53 | unsigned int size=this->BAR[barIndex].size; | |
|
54 | while(size>=1024){size=size>>10;k++;} | |
|
55 | switch(k) | |
|
56 | { | |
|
57 | case 0: | |
|
58 | return (QString::number(size, 10) + "B"); | |
|
59 | break; | |
|
60 | case 1: | |
|
61 | return (QString::number(size, 10) + "kB"); | |
|
62 | break; | |
|
63 | case 2: | |
|
64 | return (QString::number(size, 10) + "MB"); | |
|
65 | break; | |
|
66 | case 3: | |
|
67 | return (QString::number(size, 10) + "GB"); | |
|
68 | break; | |
|
69 | case 4: | |
|
70 | return (QString::number(size, 10) + "TB"); | |
|
71 | break; | |
|
72 | default: | |
|
73 | return (QString::number(this->BAR[barIndex].size, 10) + "B"); | |
|
74 | break; | |
|
75 | } | |
|
76 | } | |
|
77 | QString deviceName; | |
|
78 | APBbarreg BAR[1]; | |
|
79 | int VID; | |
|
80 | int PID; | |
|
81 | }; | |
|
82 | ||
|
83 | class apbdevicelist: public QTableWidget | |
|
84 | { | |
|
85 | Q_OBJECT | |
|
86 | public: | |
|
87 | explicit apbdevicelist(QWidget * parent = 0); | |
|
88 | ||
|
89 | public slots: | |
|
90 | void addAPBdevice(apbdeviceInfo* device); | |
|
91 | void clearAPBdevicesList(); | |
|
92 | ||
|
93 | private: | |
|
94 | QList<apbdeviceInfo*> apbdevices; | |
|
95 | ||
|
96 | ||
|
97 | }; | |
|
98 | ||
|
99 | #endif // APBDEVICELIST_H |
@@ -0,0 +1,99 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "apbpluginui.h" | |
|
23 | #include <stdint.h> | |
|
24 | #include <socexplorerengine.h> | |
|
25 | ||
|
26 | apbPluginUi::apbPluginUi(socexplorerplugin *plugin, QWidget *parent) : | |
|
27 | QWidget(parent) | |
|
28 | { | |
|
29 | this->setWindowTitle(tr("APB Driver")); | |
|
30 | this->mainlayout = new QHBoxLayout; | |
|
31 | this->scanBp = new QPushButton(tr("Scan APB")); | |
|
32 | this->deviceslst = new apbdevicelist; | |
|
33 | this->mainlayout->addWidget(this->deviceslst); | |
|
34 | this->mainlayout->addWidget(this->scanBp); | |
|
35 | this->setLayout(this->mainlayout); | |
|
36 | this->_plugin = plugin; | |
|
37 | connect(this,SIGNAL(addAPBdevice(apbdeviceInfo*)),this->deviceslst,SLOT(addAPBdevice(apbdeviceInfo*))); | |
|
38 | connect(this,SIGNAL(clearAPBdevicesList()),this->deviceslst,SLOT(clearAPBdevicesList())); | |
|
39 | connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAPB())); | |
|
40 | } | |
|
41 | ||
|
42 | void apbPluginUi::lockScanBp() | |
|
43 | { | |
|
44 | this->scanBp->setEnabled(false); | |
|
45 | } | |
|
46 | ||
|
47 | ||
|
48 | void apbPluginUi::unlockScanBp() | |
|
49 | { | |
|
50 | this->scanBp->setEnabled(true); | |
|
51 | } | |
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | apbdeviceInfo* apbPluginUi::extractInfos(int *pnpregs) | |
|
56 | { | |
|
57 | APBbarreg BAR[1]; | |
|
58 | ||
|
59 | int VID; | |
|
60 | int PID; | |
|
61 | for(int i=0;i<1;i++) | |
|
62 | { | |
|
63 | BAR[i].address = ((uint32_t)(pnpregs[i+1] & 0xfff00000)>>12)+ APB_BUS_START; | |
|
64 | BAR[i].size = ((pnpregs[i+1] & 0x00000ff0)>>4 )+1; | |
|
65 | BAR[i].type = (unsigned char)(pnpregs[i+1]&0xf); | |
|
66 | } | |
|
67 | ||
|
68 | VID = (pnpregs[0]>>24)&0xff; | |
|
69 | PID = (pnpregs[0]>>12)&0xfff; | |
|
70 | QString devname = SocExplorerEngine::getDevName(VID,PID); | |
|
71 | return new apbdeviceInfo(devname,BAR[0],VID,PID); | |
|
72 | } | |
|
73 | ||
|
74 | void apbPluginUi::scanAPB() | |
|
75 | { | |
|
76 | this->lockScanBp(); | |
|
77 | unsigned int size = APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START; | |
|
78 | int j=0; | |
|
79 | unsigned long long i = APB_PLUGNPLAY_START; | |
|
80 | int pnpregs[APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START]; | |
|
81 | emit this->clearAPBdevicesList(); | |
|
82 | if(this->_plugin->Read((unsigned int*)pnpregs,size/4,(unsigned int)APB_PLUGNPLAY_START)==(size/4)) | |
|
83 | { | |
|
84 | while(i<APB_PLUGNPLAY_STOP) | |
|
85 | { | |
|
86 | if(pnpregs[j]!=0) | |
|
87 | { | |
|
88 | apbdeviceInfo* devinfos=this->extractInfos(pnpregs+j); | |
|
89 | SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName); | |
|
90 | emit this->addAPBdevice(devinfos); | |
|
91 | } | |
|
92 | i+=8; | |
|
93 | j+=2; | |
|
94 | if(pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break; | |
|
95 | } | |
|
96 | } | |
|
97 | this->unlockScanBp(); | |
|
98 | } | |
|
99 |
@@ -0,0 +1,60 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef APBPLUGINUI_H | |
|
23 | #define APBPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QHBoxLayout> | |
|
27 | #include <QPushButton> | |
|
28 | #include "apbdevicelist.h" | |
|
29 | #include <socexplorerplugin.h> | |
|
30 | ||
|
31 | #define APB_BUS_START ((unsigned int)(0x80000000)) | |
|
32 | #define APB_PLUGNPLAY_START ((unsigned int)(0x800FF000)) | |
|
33 | ||
|
34 | #define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FF000+(512*8))) | |
|
35 | ||
|
36 | ||
|
37 | class apbPluginUi : public QWidget | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | public: | |
|
41 | explicit apbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0); | |
|
42 | void lockScanBp(); | |
|
43 | void unlockScanBp(); | |
|
44 | apbdeviceInfo* extractInfos(int* pnpregs); | |
|
45 | ||
|
46 | signals: | |
|
47 | void addAPBdevice(apbdeviceInfo* device); | |
|
48 | void clearAPBdevicesList(); | |
|
49 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
50 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
51 | public slots: | |
|
52 | void scanAPB(); | |
|
53 | private: | |
|
54 | QHBoxLayout* mainlayout; | |
|
55 | QPushButton* scanBp; | |
|
56 | apbdevicelist* deviceslst; | |
|
57 | socexplorerplugin* _plugin; | |
|
58 | }; | |
|
59 | ||
|
60 | #endif // APBPLUGINUI_H |
@@ -0,0 +1,93 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ambaplugin.h" | |
|
23 | ||
|
24 | ||
|
25 | ambaplugin::ambaplugin(QWidget *parent):socexplorerplugin(parent,true) | |
|
26 | { | |
|
27 | this->UI = new ambaPluginUI(this); | |
|
28 | this->setWindowTitle(tr("AMBA Driver")); | |
|
29 | this->setWidget((QWidget*)this->UI); | |
|
30 | connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); | |
|
31 | connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); | |
|
32 | connect(this,SIGNAL(activateSig(bool)),this,SLOT(activatePlugin(bool))); | |
|
33 | } | |
|
34 | ||
|
35 | ||
|
36 | ambaplugin::~ambaplugin() | |
|
37 | { | |
|
38 | ||
|
39 | } | |
|
40 | ||
|
41 | ||
|
42 | void ambaplugin::closeMe() | |
|
43 | { | |
|
44 | emit this->closePlugin(this); | |
|
45 | } | |
|
46 | ||
|
47 | void ambaplugin::postInstantiationTrigger() | |
|
48 | { | |
|
49 | if(this->parent->isConnected()) | |
|
50 | { | |
|
51 | this->UI->scanAll(); | |
|
52 | } | |
|
53 | } | |
|
54 | ||
|
55 | void ambaplugin::activatePlugin(bool flag) | |
|
56 | { | |
|
57 | if(flag) | |
|
58 | { | |
|
59 | this->UI->scanAll(); | |
|
60 | } | |
|
61 | } | |
|
62 | ||
|
63 | int ambaplugin::registermenu(QMainWindow *menuHolder) | |
|
64 | { | |
|
65 | this->menu = menuHolder->menuBar()->addMenu(tr("&ambaplugin")); | |
|
66 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
|
67 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
|
68 | return 1; | |
|
69 | } | |
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | unsigned int ambaplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
74 | { | |
|
75 | if(parent!=NULL) | |
|
76 | return parent->Read(Value,count,address); | |
|
77 | return 0; | |
|
78 | } | |
|
79 | ||
|
80 | unsigned int ambaplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
|
81 | { | |
|
82 | if(parent!=NULL) | |
|
83 | return parent->Write(Value,count,address); | |
|
84 | return 0; | |
|
85 | } | |
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 |
@@ -0,0 +1,56 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef ambaplugin_H | |
|
23 | #define ambaplugin_H | |
|
24 | #include <QMenuBar> | |
|
25 | #include <QMenu> | |
|
26 | #include <QAction> | |
|
27 | #include <QLayout> | |
|
28 | #include "ambapluginui.h" | |
|
29 | #include <socexplorerplugin.h> | |
|
30 | ||
|
31 | ||
|
32 | ||
|
33 | class ambaplugin : public socexplorerplugin | |
|
34 | { | |
|
35 | Q_OBJECT | |
|
36 | public: | |
|
37 | explicit ambaplugin(QWidget *parent = 0); | |
|
38 | ~ambaplugin(); | |
|
39 | int registermenu(QMainWindow *menuHolder); | |
|
40 | int VID(){return driver_VID;} | |
|
41 | int PID(){return driver_PID;} | |
|
42 | ||
|
43 | public slots: | |
|
44 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
45 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
46 | void closeMe(); | |
|
47 | void postInstantiationTrigger(); | |
|
48 | void activatePlugin(bool flag); | |
|
49 | signals: | |
|
50 | ||
|
51 | private: | |
|
52 | ambaPluginUI* UI; | |
|
53 | }; | |
|
54 | ||
|
55 | #endif // ambaplugin_H | |
|
56 |
@@ -0,0 +1,68 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | CONFIG += dll | |
|
8 | CONFIG -= static | |
|
9 | CONFIG(debug, debug|release) { | |
|
10 | DEBUG_EXT = _d | |
|
11 | } else { | |
|
12 | DEBUG_EXT = | |
|
13 | } | |
|
14 | TARGET = ambaplugin$${DEBUG_EXT} | |
|
15 | DEFINES += PLUGIN=ambaplugin | |
|
16 | DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\" | |
|
17 | DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\" | |
|
18 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
|
19 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
|
20 | DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\" | |
|
21 | DEFINES += driver_can_be_root=0 | |
|
22 | DEFINES += driver_can_be_child=1 | |
|
23 | DEFINES += driver_VID=0 | |
|
24 | DEFINES += driver_PID=0 | |
|
25 | ||
|
26 | INCLUDEPATH += \ | |
|
27 | $${PWD} | |
|
28 | ||
|
29 | HEADERS += \ | |
|
30 | ambaplugin.h \ | |
|
31 | AHB/ahbpluginui.h \ | |
|
32 | AHB/ahbdevicelist.h \ | |
|
33 | APB/apbpluginui.h \ | |
|
34 | APB/apbdevicelist.h \ | |
|
35 | ambapluginui.h | |
|
36 | ||
|
37 | ||
|
38 | SOURCES += \ | |
|
39 | ambaplugin.cpp \ | |
|
40 | AHB/ahbpluginui.cpp \ | |
|
41 | AHB/ahbdevicelist.cpp \ | |
|
42 | APB/apbpluginui.cpp \ | |
|
43 | APB/apbdevicelist.cpp \ | |
|
44 | ambapluginui.cpp | |
|
45 | ||
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 |
@@ -0,0 +1,43 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "ambapluginui.h" | |
|
23 | ||
|
24 | ambaPluginUI::ambaPluginUI(socexplorerplugin *plugin, QWidget *parent) : | |
|
25 | QWidget(parent) | |
|
26 | { | |
|
27 | this->mainLayout=new QGridLayout(); | |
|
28 | this->ahbPlugin=new ahbPluginUi(plugin); | |
|
29 | this->apbPlugin=new apbPluginUi(plugin); | |
|
30 | this->mainLayout->addWidget(this->ahbPlugin,0,0,1,-1); | |
|
31 | this->mainLayout->addWidget(this->apbPlugin,1,0,1,-1); | |
|
32 | this->setLayout(this->mainLayout); | |
|
33 | connect(this->ahbPlugin,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
34 | connect(this->ahbPlugin,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
35 | connect(this->apbPlugin,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
36 | connect(this->apbPlugin,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
37 | } | |
|
38 | ||
|
39 | void ambaPluginUI::scanAll() | |
|
40 | { | |
|
41 | this->ahbPlugin->scanAHB(); | |
|
42 | this->apbPlugin->scanAPB(); | |
|
43 | } |
@@ -0,0 +1,49 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AMBAPLUGINUI_H | |
|
23 | #define AMBAPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QVBoxLayout> | |
|
27 | #include <QGridLayout> | |
|
28 | #include <QPushButton> | |
|
29 | #include "AHB/ahbpluginui.h" | |
|
30 | #include "APB/apbpluginui.h" | |
|
31 | ||
|
32 | class ambaPluginUI : public QWidget | |
|
33 | { | |
|
34 | Q_OBJECT | |
|
35 | public: | |
|
36 | explicit ambaPluginUI(socexplorerplugin* plugin,QWidget *parent = 0); | |
|
37 | ||
|
38 | signals: | |
|
39 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
40 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
41 | public slots: | |
|
42 | void scanAll(); | |
|
43 | private: | |
|
44 | QGridLayout* mainLayout; | |
|
45 | ahbPluginUi* ahbPlugin; | |
|
46 | apbPluginUi* apbPlugin; | |
|
47 | }; | |
|
48 | ||
|
49 | #endif // AMBAPLUGINUI_H |
@@ -0,0 +1,226 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "dsu3plugin.h" | |
|
23 | #include <QFileDialog> | |
|
24 | #include <QDir> | |
|
25 | #include "dsu3pluginpywrapper.h" | |
|
26 | #include <socexplorerengine.h> | |
|
27 | ||
|
28 | dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) | |
|
29 | { | |
|
30 | this->UI = new dsu3pluginui(); | |
|
31 | this->setWindowTitle(tr("DSU3 Driver")); | |
|
32 | this->setWidget((QWidget*)this->UI); | |
|
33 | this->elfparserInst = new elfparser(); | |
|
34 | this->pyObject = new dsu3pluginPywrapper(this); | |
|
35 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString))); | |
|
36 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget())); | |
|
37 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run())); | |
|
38 | connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); | |
|
39 | connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); | |
|
40 | connect(this->UI,SIGNAL(run()),this,SLOT(run())); | |
|
41 | connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); | |
|
42 | } | |
|
43 | ||
|
44 | ||
|
45 | dsu3plugin::~dsu3plugin() | |
|
46 | { | |
|
47 | ||
|
48 | } | |
|
49 | ||
|
50 | ||
|
51 | void dsu3plugin::openFile() | |
|
52 | { | |
|
53 | QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); | |
|
54 | if(filename!="") | |
|
55 | { | |
|
56 | this->openFile(filename); | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
60 | void dsu3plugin::openFile(QString fileName) | |
|
61 | { | |
|
62 | this->elfparserInst->setFilename(fileName); | |
|
63 | emit this->updateInfo(this->elfparserInst); | |
|
64 | } | |
|
65 | ||
|
66 | bool dsu3plugin::configureTarget() | |
|
67 | { | |
|
68 | if(parent==NULL) | |
|
69 | return false; | |
|
70 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
71 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
72 | DSUBASEADDRESS = 0x90000000; | |
|
73 | unsigned int MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x04 , 0x00F,0); | |
|
74 | if(MCTRLBASEADDRESS == (unsigned int)-1) | |
|
75 | return false; | |
|
76 | ||
|
77 | //Force a debug break | |
|
78 | WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS); | |
|
79 | WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20); | |
|
80 | //Clear time tag counter | |
|
81 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8); | |
|
82 | ||
|
83 | //Clear ASR registers | |
|
84 | WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
|
85 | WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024); | |
|
86 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
|
87 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48); | |
|
88 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C); | |
|
89 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); | |
|
94 | ||
|
95 | ||
|
96 | WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
|
97 | WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); | |
|
98 | ||
|
99 | unsigned int buff=0; | |
|
100 | // for(int i=0;i<1567;i++) | |
|
101 | // { | |
|
102 | // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i)); | |
|
103 | // } | |
|
104 | memSet(DSUBASEADDRESS+0x300000,0,1567); | |
|
105 | WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); | |
|
106 | 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); | |
|
107 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); | |
|
108 | ||
|
109 | //Disable interrupts | |
|
110 | unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0); | |
|
111 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) | |
|
112 | return false; | |
|
113 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); | |
|
114 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); | |
|
115 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); | |
|
116 | ||
|
117 | //Set up timer | |
|
118 | unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0); | |
|
119 | if(APBTIMERBASEADD == (unsigned int)-1) | |
|
120 | return false; | |
|
121 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); | |
|
122 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); | |
|
123 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); | |
|
124 | return true; | |
|
125 | } | |
|
126 | ||
|
127 | bool dsu3plugin::flashTarget() | |
|
128 | { | |
|
129 | configureTarget(); | |
|
130 | ||
|
131 | /*Write .text*/ | |
|
132 | this->writeSection(".text"); | |
|
133 | /*Write .data*/ | |
|
134 | this->writeSection(".data"); | |
|
135 | return true; | |
|
136 | } | |
|
137 | ||
|
138 | void dsu3plugin::run() | |
|
139 | { | |
|
140 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
141 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
142 | DSUBASEADDRESS = 0x90000000; | |
|
143 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); | |
|
144 | } | |
|
145 | ||
|
146 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) | |
|
147 | { | |
|
148 | unsigned int* buff; | |
|
149 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); | |
|
150 | for(int i=0;i<Values.count();i++) | |
|
151 | { | |
|
152 | buff[i]=Values.at(i); | |
|
153 | } | |
|
154 | parent->Write(buff,(unsigned int)Values.count(),address); | |
|
155 | free(buff); | |
|
156 | } | |
|
157 | ||
|
158 | void dsu3plugin::writeSection(int index) | |
|
159 | { | |
|
160 | char* buffch=NULL; | |
|
161 | unsigned int* buff; | |
|
162 | int size = this->elfparserInst->getSectionDatasz(index); | |
|
163 | int sizeInt = size/4; | |
|
164 | if(parent==NULL) | |
|
165 | return; | |
|
166 | this->elfparserInst->getSectionData(index,&buffch); | |
|
167 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); | |
|
168 | for(int i=0;i<sizeInt;i++) | |
|
169 | { | |
|
170 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); | |
|
171 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1])); | |
|
172 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2])); | |
|
173 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3])); | |
|
174 | } | |
|
175 | if(size%4) | |
|
176 | { | |
|
177 | buff[sizeInt]=0; | |
|
178 | for(int i=(size%4);i>0;i--) | |
|
179 | { | |
|
180 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); | |
|
181 | } | |
|
182 | sizeInt++; | |
|
183 | } | |
|
184 | parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index)); | |
|
185 | free(buff); | |
|
186 | } | |
|
187 | ||
|
188 | void dsu3plugin::writeSection(const QString &name) | |
|
189 | { | |
|
190 | for(int i=0;i<this->elfparserInst->getSectioncount();i++) | |
|
191 | { | |
|
192 | if(!this->elfparserInst->getSectionName(i).compare(name)) | |
|
193 | { | |
|
194 | printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i)); | |
|
195 | writeSection(i); | |
|
196 | } | |
|
197 | } | |
|
198 | } | |
|
199 | ||
|
200 | ||
|
201 | unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) | |
|
202 | { | |
|
203 | if(parent!=NULL) | |
|
204 | return parent->Write(Value,count,address); | |
|
205 | return 0; | |
|
206 | } | |
|
207 | ||
|
208 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) | |
|
209 | { | |
|
210 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
|
211 | if(buffer!=NULL) | |
|
212 | { | |
|
213 | memset((void*)buffer,value,count*sizeof(unsigned int)); | |
|
214 | parent->Write(buffer,count,address); | |
|
215 | free(buffer ); | |
|
216 | return true; | |
|
217 | } | |
|
218 | return false; | |
|
219 | } | |
|
220 | ||
|
221 | unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address) | |
|
222 | { | |
|
223 | if(parent!=NULL) | |
|
224 | return parent->Read(Value,count,address); | |
|
225 | return 0; | |
|
226 | } |
@@ -0,0 +1,61 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef DSU3PLUGIN_H | |
|
23 | #define DSU3PLUGIN_H | |
|
24 | #include "dsu3pluginui.h" | |
|
25 | #include <QMenuBar> | |
|
26 | #include <QMenu> | |
|
27 | #include <QAction> | |
|
28 | #include <QMainWindow> | |
|
29 | #include <QList> | |
|
30 | #include "elfparser.h" | |
|
31 | #include <socexplorerplugin.h> | |
|
32 | #include <socexplorerengine.h> | |
|
33 | ||
|
34 | typedef QList<unsigned int> uIntlist; | |
|
35 | ||
|
36 | class dsu3plugin : public socexplorerplugin | |
|
37 | { | |
|
38 | Q_OBJECT | |
|
39 | public: | |
|
40 | explicit dsu3plugin(QWidget *parent = 0); | |
|
41 | ~dsu3plugin(); | |
|
42 | bool memSet(unsigned int address, int value, unsigned int count); | |
|
43 | public slots: | |
|
44 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
45 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
46 | void openFile(); | |
|
47 | void openFile(QString fileName); | |
|
48 | bool configureTarget(); | |
|
49 | bool flashTarget(); | |
|
50 | void run(); | |
|
51 | signals: | |
|
52 | void updateInfo(elfparser* parser); | |
|
53 | private: | |
|
54 | void WriteRegs(uIntlist Values, unsigned int address); | |
|
55 | void writeSection(int index); | |
|
56 | void writeSection(const QString& name); | |
|
57 | dsu3pluginui* UI; | |
|
58 | elfparser* elfparserInst; | |
|
59 | }; | |
|
60 | ||
|
61 | #endif // DSU3PLUGIN_H |
@@ -0,0 +1,75 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | ||
|
8 | TEMPLATE = lib | |
|
9 | ||
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | ||
|
16 | QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign | |
|
17 | QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign | |
|
18 | ||
|
19 | ||
|
20 | TARGET = dsu3plugin$${DEBUG_EXT} | |
|
21 | ||
|
22 | DEFINES += PLUGIN=dsu3plugin | |
|
23 | DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" | |
|
24 | DEFINES += driver_Name="\"\\\"dsu3plugin"\\\"\" | |
|
25 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
|
26 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
|
27 | DEFINES += driver_Description="\"\\\"DSU driver, works with GAISLER's DSU3 unit."\\\"\" | |
|
28 | DEFINES += driver_can_be_root=0 | |
|
29 | DEFINES += driver_can_be_child=1 | |
|
30 | DEFINES += driver_VID=0x00 | |
|
31 | DEFINES += driver_PID=0x00 | |
|
32 | ||
|
33 | ||
|
34 | INCLUDEPATH += \ | |
|
35 | $${PWD} | |
|
36 | ||
|
37 | ||
|
38 | ||
|
39 | HEADERS += \ | |
|
40 | dsu3plugin.h \ | |
|
41 | dsu3pluginui.h \ | |
|
42 | dsu3pluginpywrapper.h | |
|
43 | ||
|
44 | SOURCES += \ | |
|
45 | dsu3plugin.cpp \ | |
|
46 | dsu3pluginui.cpp \ | |
|
47 | dsu3pluginpywrapper.cpp | |
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | ||
|
75 |
@@ -0,0 +1,6 | |||
|
1 | #include "dsu3pluginpywrapper.h" | |
|
2 | ||
|
3 | dsu3pluginPywrapper::dsu3pluginPywrapper(socexplorerplugin *parent) : | |
|
4 | genericPySysdriver(parent) | |
|
5 | { | |
|
6 | } |
@@ -0,0 +1,19 | |||
|
1 | #ifndef DSU3PLUGINPYWRAPPER_H | |
|
2 | #define DSU3PLUGINPYWRAPPER_H | |
|
3 | #include <genericPySysdriver.h> | |
|
4 | ||
|
5 | class dsu3pluginPywrapper : public genericPySysdriver | |
|
6 | { | |
|
7 | Q_OBJECT | |
|
8 | public: | |
|
9 | explicit dsu3pluginPywrapper(socexplorerplugin *parent = 0); | |
|
10 | ||
|
11 | signals: | |
|
12 | bool openFile(QString fileName); | |
|
13 | bool loadFile(); | |
|
14 | bool run(); | |
|
15 | public slots: | |
|
16 | ||
|
17 | }; | |
|
18 | ||
|
19 | #endif // DSU3PLUGINPYWRAPPER_H |
@@ -0,0 +1,54 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2013, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include <dsu3pluginui.h> | |
|
24 | ||
|
25 | dsu3pluginui::dsu3pluginui(QWidget *parent) | |
|
26 | :QWidget(parent) | |
|
27 | { | |
|
28 | this->openFileQpb = new QPushButton(tr("Open File")); | |
|
29 | this->flashTargetQpb = new QPushButton(tr("Flash Target")); | |
|
30 | this->runQpb = new QPushButton(tr("Run")); | |
|
31 | this->mainLayout = new QGridLayout(); | |
|
32 | this->elfInfoWdgtInst = new elfInfoWdgt; | |
|
33 | this->mainLayout->addWidget(this->openFileQpb,0,0,1,1); | |
|
34 | this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1); | |
|
35 | this->mainLayout->addWidget(this->runQpb,0,2,1,1); | |
|
36 | this->mainLayout->addWidget(this->elfInfoWdgtInst,1,0,1,-1); | |
|
37 | this->setLayout(this->mainLayout); | |
|
38 | connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile())); | |
|
39 | connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget())); | |
|
40 | connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run())); | |
|
41 | connect(this,SIGNAL(updateInfo(elfparser*)),this->elfInfoWdgtInst,SLOT(updateInfo(elfparser*))); | |
|
42 | ||
|
43 | } | |
|
44 | ||
|
45 | ||
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 |
@@ -0,0 +1,58 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef DSU3PLUGINUI_H | |
|
23 | #define DSU3PLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QHBoxLayout> | |
|
27 | #include <QPushButton> | |
|
28 | #include <qhexedit.h> | |
|
29 | #include <QSplitter> | |
|
30 | #include <QVBoxLayout> | |
|
31 | #include <QGridLayout> | |
|
32 | #include "elfinfowdgt.h" | |
|
33 | ||
|
34 | class dsu3pluginui : public QWidget | |
|
35 | { | |
|
36 | Q_OBJECT | |
|
37 | public: | |
|
38 | explicit dsu3pluginui(QWidget *parent = 0); | |
|
39 | ||
|
40 | public slots: | |
|
41 | ||
|
42 | signals: | |
|
43 | void openFile(); | |
|
44 | void updateInfo(elfparser* parser); | |
|
45 | bool flashTarget(); | |
|
46 | void run(); | |
|
47 | private: | |
|
48 | QGridLayout* mainLayout; | |
|
49 | QPushButton* openFileQpb; | |
|
50 | QPushButton* flashTargetQpb; | |
|
51 | QPushButton* runQpb; | |
|
52 | elfInfoWdgt* elfInfoWdgtInst; | |
|
53 | ||
|
54 | }; | |
|
55 | ||
|
56 | #endif // DSU3PLUGINUI_H | |
|
57 | ||
|
58 |
@@ -0,0 +1,62 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "genericrwplugin.h" | |
|
23 | #include "genericrwpluginpywrapper.h" | |
|
24 | genericrwplugin::genericrwplugin(QWidget *parent):socexplorerplugin(parent,false) | |
|
25 | { | |
|
26 | this->UI = new genericrwpluginUi(); | |
|
27 | this->setWindowTitle(tr("Generic Driver")); | |
|
28 | this->setWidget((QWidget*)this->UI); | |
|
29 | connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); | |
|
30 | connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); | |
|
31 | this->pyObject = new genericRWpluginPyWrapper(this); | |
|
32 | //QObject::connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); | |
|
33 | //QObject::connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); | |
|
34 | QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(refresh()),this->UI,SIGNAL(refresh())); | |
|
35 | QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setAddress(quint32)),this->UI,SIGNAL(setAddress(quint32))); | |
|
36 | QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setLength(quint32)),this->UI,SIGNAL(setLength(quint32))); | |
|
37 | } | |
|
38 | ||
|
39 | genericrwplugin::~genericrwplugin() | |
|
40 | {} | |
|
41 | ||
|
42 | int genericrwplugin::registermenu(QMainWindow *menuHolder) | |
|
43 | { | |
|
44 | this->menu = menuHolder->menuBar()->addMenu(tr("&Generic RW Driver")); | |
|
45 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
|
46 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
|
47 | return 1; | |
|
48 | } | |
|
49 | ||
|
50 | unsigned int genericrwplugin::Write(unsigned int *Value,unsigned int count,unsigned int address) | |
|
51 | { | |
|
52 | if(parent!=NULL) | |
|
53 | return parent->Write(Value,count,address); | |
|
54 | return 0; | |
|
55 | } | |
|
56 | ||
|
57 | unsigned int genericrwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
58 | { | |
|
59 | if(parent!=NULL) | |
|
60 | return parent->Read(Value,count,address); | |
|
61 | return 0; | |
|
62 | } |
@@ -0,0 +1,56 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef GENERICRWPLUGIN_H | |
|
23 | #define GENERICRWPLUGIN_H | |
|
24 | #include "genericrwpluginui.h" | |
|
25 | #include <QMenuBar> | |
|
26 | #include <QMenu> | |
|
27 | #include <QAction> | |
|
28 | #include <QMainWindow> | |
|
29 | ||
|
30 | ||
|
31 | ||
|
32 | #include <socexplorerplugin.h> | |
|
33 | ||
|
34 | #define AHB_PLUGNPLAY_MASTER_START 0xFFFFF000 | |
|
35 | #define AHB_PLUGNPLAY_MASTER_STOP 0xFFFFF800 | |
|
36 | #define AHB_PLUGNPLAY_SLAVE_START 0xFFFFF800 | |
|
37 | #define AHB_PLUGNPLAY_SLAVE_STOP 0xFFFFFFFC | |
|
38 | ||
|
39 | ||
|
40 | class genericrwplugin : public socexplorerplugin | |
|
41 | { | |
|
42 | Q_OBJECT | |
|
43 | public: | |
|
44 | explicit genericrwplugin(QWidget *parent = 0); | |
|
45 | ~genericrwplugin(); | |
|
46 | int registermenu(QMainWindow *menuHolder); | |
|
47 | public slots: | |
|
48 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
49 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
50 | signals: | |
|
51 | ||
|
52 | private: | |
|
53 | genericrwpluginUi* UI; | |
|
54 | }; | |
|
55 | ||
|
56 | #endif // GENERICRWPLUGIN_H |
@@ -0,0 +1,59 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | CONFIG += dll | |
|
8 | CONFIG -= static | |
|
9 | ||
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | TARGET = genericrwplugin$${DEBUG_EXT} | |
|
16 | DEFINES += PLUGIN=genericrwplugin | |
|
17 | DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\" | |
|
18 | DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\" | |
|
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
|
20 | DEFINES += driver_Version="\"\\\"1.1.0"\\\"\" | |
|
21 | DEFINES += driver_Description="\"\\\"Generic plugin, gives you R/W access to any memory area."\\\"\" | |
|
22 | DEFINES += driver_can_be_root=0 | |
|
23 | DEFINES += driver_can_be_child=1 | |
|
24 | DEFINES += driver_VID=0 | |
|
25 | DEFINES += driver_PID=0 | |
|
26 | ||
|
27 | ||
|
28 | INCLUDEPATH += \ | |
|
29 | $${PWD} | |
|
30 | ||
|
31 | #LIBS +=-llppmoncommon$${DEBUG_EXT} | |
|
32 | ||
|
33 | HEADERS += \ | |
|
34 | genericrwplugin.h \ | |
|
35 | genericrwpluginui.h \ | |
|
36 | rw_task.h \ | |
|
37 | tasklist.h \ | |
|
38 | taskeditor.h \ | |
|
39 | memeditor.h \ | |
|
40 | genericrwpluginpywrapper.h | |
|
41 | ||
|
42 | SOURCES += \ | |
|
43 | genericrwplugin.cpp \ | |
|
44 | genericrwpluginui.cpp \ | |
|
45 | rw_task.cpp \ | |
|
46 | tasklist.cpp \ | |
|
47 | taskeditor.cpp \ | |
|
48 | memeditor.cpp \ | |
|
49 | genericrwpluginpywrapper.cpp | |
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 |
@@ -0,0 +1,27 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2014, Laboratory of Plasmas Physic - 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 "genericrwpluginpywrapper.h" | |
|
23 | ||
|
24 | genericRWpluginPyWrapper::genericRWpluginPyWrapper(socexplorerplugin *parent) : | |
|
25 | genericPySysdriver(parent) | |
|
26 | { | |
|
27 | } |
@@ -0,0 +1,40 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2014, Laboratory of Plasmas Physic - 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 | #ifndef GENERICRWPLUGINPYWRAPPER_H | |
|
23 | #define GENERICRWPLUGINPYWRAPPER_H | |
|
24 | #include <genericPySysdriver.h> | |
|
25 | class genericRWpluginPyWrapper : public genericPySysdriver | |
|
26 | { | |
|
27 | Q_OBJECT | |
|
28 | public: | |
|
29 | explicit genericRWpluginPyWrapper(socexplorerplugin *parent = 0); | |
|
30 | ||
|
31 | signals: | |
|
32 | void refresh(); | |
|
33 | void setAddress(quint32 address); | |
|
34 | void setLength(quint32 length); | |
|
35 | ||
|
36 | public slots: | |
|
37 | ||
|
38 | }; | |
|
39 | ||
|
40 | #endif // GENERICRWPLUGINPYWRAPPER_H |
@@ -0,0 +1,41 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "genericrwplugin.h" | |
|
23 | ||
|
24 | genericrwpluginUi::genericrwpluginUi(QWidget *parent) : | |
|
25 | QWidget(parent) | |
|
26 | { | |
|
27 | ||
|
28 | this->mainlayout = new QHBoxLayout; | |
|
29 | this->tabWdgt = new QTabWidget; | |
|
30 | this->mainlayout->addWidget(this->tabWdgt); | |
|
31 | this->memEditorWdgt = new memEditor; | |
|
32 | this->tabWdgt->addTab(this->memEditorWdgt,tr("Memory editor")); | |
|
33 | this->setLayout(this->mainlayout); | |
|
34 | connect(this->memEditorWdgt,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
35 | connect(this->memEditorWdgt,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
36 | connect(this,SIGNAL(refresh()),this->memEditorWdgt,SLOT(readMemSlt())); | |
|
37 | connect(this,SIGNAL(setAddress(quint32)),this->memEditorWdgt,SLOT(setAddress(quint32))); | |
|
38 | connect(this,SIGNAL(setLength(quint32)),this->memEditorWdgt,SLOT(setLength(quint32))); | |
|
39 | ||
|
40 | } | |
|
41 |
@@ -0,0 +1,55 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef AHBPLUGINUI_H | |
|
23 | #define AHBPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QHBoxLayout> | |
|
27 | #include <QTabWidget> | |
|
28 | #include <QPushButton> | |
|
29 | #include "tasklist.h" | |
|
30 | #include "memeditor.h" | |
|
31 | #include <QSplitter> | |
|
32 | ||
|
33 | ||
|
34 | class genericrwpluginUi : public QWidget | |
|
35 | { | |
|
36 | Q_OBJECT | |
|
37 | public: | |
|
38 | explicit genericrwpluginUi(QWidget *parent = 0); | |
|
39 | ||
|
40 | signals: | |
|
41 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
42 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
43 | void refresh(); | |
|
44 | void setAddress(quint32 address); | |
|
45 | void setLength(quint32 length); | |
|
46 | ||
|
47 | private: | |
|
48 | QSplitter* verticalSpliter; | |
|
49 | QHBoxLayout* mainlayout; | |
|
50 | QTabWidget* tabWdgt; | |
|
51 | memEditor* memEditorWdgt; | |
|
52 | ||
|
53 | }; | |
|
54 | ||
|
55 | #endif // AHBPLUGINUI_H |
@@ -0,0 +1,98 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "memeditor.h" | |
|
23 | #include "malloc.h" | |
|
24 | ||
|
25 | memEditor::memEditor(QWidget *parent) : | |
|
26 | QWidget(parent) | |
|
27 | { | |
|
28 | this->verticalSpliter = new QSplitter; | |
|
29 | this->ctrlWidget = new QWidget; | |
|
30 | this->verticalSpliter->setOrientation(Qt::Horizontal); | |
|
31 | this->mainLayout = new QHBoxLayout; | |
|
32 | this->ctrlLayout = new QVBoxLayout; | |
|
33 | this->hexEditor = new QHexEdit; | |
|
34 | this->addressSpnBx = new QHexSpinBox; | |
|
35 | this->SizeWidget = new MemSizeWdgt(256); | |
|
36 | this->readMemQPb = new QPushButton(tr("Read Mem")); | |
|
37 | this->writeMemQPb = new QPushButton(tr("Write Mem")); | |
|
38 | this->ctrlLayout->addWidget(this->addressSpnBx); | |
|
39 | this->ctrlLayout->addWidget(this->SizeWidget); | |
|
40 | this->ctrlLayout->addWidget(this->readMemQPb); | |
|
41 | this->ctrlLayout->addWidget(this->writeMemQPb); | |
|
42 | this->ctrlWidget->setLayout(this->ctrlLayout); | |
|
43 | this->verticalSpliter->addWidget(this->hexEditor); | |
|
44 | this->verticalSpliter->addWidget(this->ctrlWidget); | |
|
45 | this->mainLayout->addWidget(this->verticalSpliter); | |
|
46 | this->setLayout(this->mainLayout); | |
|
47 | connect(this->readMemQPb,SIGNAL(clicked()),this,SLOT(readMemSlt())); | |
|
48 | connect(this->writeMemQPb,SIGNAL(clicked()),this,SLOT(writeMemSlt())); | |
|
49 | this->SizeWidget->setMaximum(16384); | |
|
50 | } | |
|
51 | ||
|
52 | void memEditor::writeMemSlt() | |
|
53 | { | |
|
54 | ||
|
55 | QByteArray data = this->hexEditor->data(); | |
|
56 | unsigned int length = data.length()/4; | |
|
57 | unsigned int* buffer=(unsigned int*)malloc(length*sizeof(int)); | |
|
58 | unsigned int address = this->hexEditor->addressOffset(); | |
|
59 | for(int i=0;(unsigned int)i<length;i++) | |
|
60 | { | |
|
61 | buffer[i]=((data[4*i]<<24)&0xFF000000)+((data[(4*i)+1]<<16)&0x00FF0000)+((data[(4*i)+2]<<8)&0x0000FF00)+(data[(4*i)+3]&0x000000FF); | |
|
62 | } | |
|
63 | emit this->WriteSig(buffer,length,address); | |
|
64 | free(buffer); | |
|
65 | } | |
|
66 | ||
|
67 | void memEditor::setAddress(quint32 address) | |
|
68 | { | |
|
69 | this->addressSpnBx->setValue(address); | |
|
70 | } | |
|
71 | ||
|
72 | void memEditor::setLength(quint32 length) | |
|
73 | { | |
|
74 | this->SizeWidget->setSizeValue(length); | |
|
75 | } | |
|
76 | ||
|
77 | void memEditor::readMemSlt() | |
|
78 | { | |
|
79 | this->SizeWidget->updateSizeValue(); | |
|
80 | unsigned int size = this->SizeWidget->getsize()/4; | |
|
81 | unsigned int buffer[16384]; | |
|
82 | unsigned char buffChar[16384*4]; | |
|
83 | unsigned int address = this->addressSpnBx->value(); | |
|
84 | if((emit this->ReadSig(buffer,size,address&(-4)))==size) | |
|
85 | { | |
|
86 | for(int i=0;(unsigned int)i<size;i++) | |
|
87 | { | |
|
88 | buffChar[4*i]=(buffer[i]>>24)&0xFF; | |
|
89 | buffChar[(4*i)+1]=(buffer[i]>>16)&0xFF; | |
|
90 | buffChar[(4*i)+2]=(buffer[i]>>8)&0xFF; | |
|
91 | buffChar[(4*i)+3]=(buffer[i])&0xFF; | |
|
92 | } | |
|
93 | QByteArray data = QByteArray((char*)buffChar,size*4); | |
|
94 | this->hexEditor->setData(data); | |
|
95 | this->hexEditor->setAddressOffset(address&(-4)); | |
|
96 | this->addressSpnBx->setValue(address&(-4)); | |
|
97 | } | |
|
98 | } |
@@ -0,0 +1,62 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef MEMEDITOR_H | |
|
23 | #define MEMEDITOR_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QVBoxLayout> | |
|
27 | #include <QHBoxLayout> | |
|
28 | #include <QPushButton> | |
|
29 | #include <QByteArray> | |
|
30 | #include <QSplitter> | |
|
31 | #include <qhexedit.h> | |
|
32 | #include <qhexspinbox.h> | |
|
33 | #include <memsizewdgt.h> | |
|
34 | ||
|
35 | class memEditor : public QWidget | |
|
36 | { | |
|
37 | Q_OBJECT | |
|
38 | public: | |
|
39 | explicit memEditor(QWidget *parent = 0); | |
|
40 | ||
|
41 | signals: | |
|
42 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
43 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
44 | ||
|
45 | public slots: | |
|
46 | void readMemSlt(); | |
|
47 | void writeMemSlt(); | |
|
48 | void setAddress(quint32 address); | |
|
49 | void setLength(quint32 length); | |
|
50 | private: | |
|
51 | QWidget* ctrlWidget; | |
|
52 | QSplitter* verticalSpliter; | |
|
53 | QHBoxLayout* mainLayout; | |
|
54 | QVBoxLayout* ctrlLayout; | |
|
55 | QHexEdit* hexEditor; | |
|
56 | QHexSpinBox* addressSpnBx; | |
|
57 | QPushButton* readMemQPb; | |
|
58 | QPushButton* writeMemQPb; | |
|
59 | MemSizeWdgt* SizeWidget; | |
|
60 | }; | |
|
61 | ||
|
62 | #endif // MEMEDITOR_H |
@@ -0,0 +1,26 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "rw_task.h" | |
|
23 | ||
|
24 | RW_Task::RW_Task() | |
|
25 | { | |
|
26 | } |
@@ -0,0 +1,43 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef RW_TASK_H | |
|
23 | #define RW_TASK_H | |
|
24 | #include <QString> | |
|
25 | ||
|
26 | ||
|
27 | typedef enum {readTask,writeTask}taskTypeT; | |
|
28 | ||
|
29 | class RW_Task | |
|
30 | { | |
|
31 | public: | |
|
32 | RW_Task(); | |
|
33 | taskTypeT taskType; | |
|
34 | ||
|
35 | private: | |
|
36 | QString dataStr; | |
|
37 | unsigned int* data; | |
|
38 | unsigned int length; | |
|
39 | unsigned int address; | |
|
40 | ||
|
41 | }; | |
|
42 | ||
|
43 | #endif // RW_TASK_H |
@@ -0,0 +1,27 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "taskeditor.h" | |
|
23 | ||
|
24 | taskEditor::taskEditor(QWidget *parent) : | |
|
25 | QWidget(parent) | |
|
26 | { | |
|
27 | } |
@@ -0,0 +1,39 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef TASKEDITOR_H | |
|
23 | #define TASKEDITOR_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | ||
|
27 | class taskEditor : public QWidget | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | public: | |
|
31 | explicit taskEditor(QWidget *parent = 0); | |
|
32 | ||
|
33 | signals: | |
|
34 | ||
|
35 | public slots: | |
|
36 | ||
|
37 | }; | |
|
38 | ||
|
39 | #endif // TASKEDITOR_H |
@@ -0,0 +1,28 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include "tasklist.h" | |
|
24 | ||
|
25 | tasklist::tasklist(QWidget *parent) : | |
|
26 | QTableWidget(parent) | |
|
27 | { | |
|
28 | } |
@@ -0,0 +1,40 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef TASKLIST_H | |
|
23 | #define TASKLIST_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QTableWidget> | |
|
27 | ||
|
28 | class tasklist : public QTableWidget | |
|
29 | { | |
|
30 | Q_OBJECT | |
|
31 | public: | |
|
32 | explicit tasklist(QWidget *parent = 0); | |
|
33 | ||
|
34 | signals: | |
|
35 | ||
|
36 | public slots: | |
|
37 | ||
|
38 | }; | |
|
39 | ||
|
40 | #endif // TASKLIST_H |
@@ -0,0 +1,61 | |||
|
1 | #include "genericmemoryspacecheck.h" | |
|
2 | ||
|
3 | genericmemoryspacecheck::genericmemoryspacecheck( const QString Name, unsigned int baseAddress, unsigned int size,QWidget *parent): | |
|
4 | QWidget(parent) | |
|
5 | { | |
|
6 | this->mainLayout = new QVBoxLayout; | |
|
7 | this->secondLayout = new QHBoxLayout; | |
|
8 | this->MemoryName = new QLabel(Name); | |
|
9 | this->AddrQHspBx = new QHexSpinBox; | |
|
10 | this->AddrQHspBx->setValue(baseAddress); | |
|
11 | this->MemSize=new MemSizeWdgt(size); | |
|
12 | this->LaunchtestQPB = new QPushButton(tr("Start Test")); | |
|
13 | this->result = new QLabel(tr("Test result: Start test")); | |
|
14 | this->mainLayout->addWidget(this->MemoryName); | |
|
15 | this->secondLayout->addWidget(this->AddrQHspBx); | |
|
16 | this->secondLayout->addWidget(this->MemSize); | |
|
17 | this->secondLayout->addWidget(this->LaunchtestQPB); | |
|
18 | this->mainLayout->addLayout(this->secondLayout); | |
|
19 | this->mainLayout->addWidget(this->result); | |
|
20 | this->setLayout(this->mainLayout); | |
|
21 | connect(this->LaunchtestQPB,SIGNAL(clicked()),this,SLOT(launchTestSlt())); | |
|
22 | } | |
|
23 | ||
|
24 | ||
|
25 | bool genericmemoryspacecheck::launchTest(genericmemoryspacecheck* instance,unsigned int baseAddress,unsigned int size) | |
|
26 | { | |
|
27 | unsigned int* dataLocal = (unsigned int*)malloc(size); | |
|
28 | unsigned int* dataOnBoard = (unsigned int*)malloc(size); | |
|
29 | bool res=true; | |
|
30 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
31 | { | |
|
32 | dataLocal[i]= (0xFFFF&rand())+(rand()<<16); | |
|
33 | } | |
|
34 | emit instance->WriteSig(dataLocal,size>>2,baseAddress); | |
|
35 | emit instance->ReadSig(dataOnBoard,size>>2,baseAddress); | |
|
36 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
37 | { | |
|
38 | if(dataLocal[i]!=dataOnBoard[i]) | |
|
39 | res=false; | |
|
40 | } | |
|
41 | ||
|
42 | free(dataLocal); | |
|
43 | free(dataOnBoard); | |
|
44 | return res; | |
|
45 | } | |
|
46 | ||
|
47 | ||
|
48 | void genericmemoryspacecheck::launchTestSlt() | |
|
49 | { | |
|
50 | this->result->setText(tr("Test result: Pending")); | |
|
51 | if(this->launchTest(this,this->AddrQHspBx->value(),this->MemSize->getsize())) | |
|
52 | this->result->setText(tr("Test result: Success")); | |
|
53 | else | |
|
54 | this->result->setText(tr("Test result: failed")); | |
|
55 | } | |
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 |
@@ -0,0 +1,36 | |||
|
1 | #ifndef GENERICMEMORYSPACECHECK_H | |
|
2 | #define GENERICMEMORYSPACECHECK_H | |
|
3 | ||
|
4 | #include <QWidget> | |
|
5 | #include <qhexspinbox.h> | |
|
6 | #include <memsizewdgt.h> | |
|
7 | #include <QHBoxLayout> | |
|
8 | #include <QVBoxLayout> | |
|
9 | #include <QPushButton> | |
|
10 | #include <QLabel> | |
|
11 | ||
|
12 | ||
|
13 | class genericmemoryspacecheck : public QWidget | |
|
14 | { | |
|
15 | Q_OBJECT | |
|
16 | public: | |
|
17 | explicit genericmemoryspacecheck(const QString Name,unsigned int baseAddress,unsigned int size,QWidget *parent = 0); | |
|
18 | static bool launchTest(genericmemoryspacecheck* instance,unsigned int baseAddress,unsigned int size); | |
|
19 | ||
|
20 | signals: | |
|
21 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
22 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
23 | public slots: | |
|
24 | void launchTestSlt(); | |
|
25 | private: | |
|
26 | QVBoxLayout* mainLayout; | |
|
27 | QHBoxLayout* secondLayout; | |
|
28 | QLabel* MemoryName; | |
|
29 | QHexSpinBox* AddrQHspBx; | |
|
30 | MemSizeWdgt* MemSize; | |
|
31 | QPushButton* LaunchtestQPB; | |
|
32 | QLabel* result; | |
|
33 | ||
|
34 | }; | |
|
35 | ||
|
36 | #endif // GENERICMEMORYSPACECHECK_H |
@@ -0,0 +1,86 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "memctrlrplugin.h" | |
|
23 | #include "memctrlrpywrapper.h" | |
|
24 | ||
|
25 | memctrlrplugin::memctrlrplugin(QWidget *parent):socexplorerplugin(parent,false) | |
|
26 | { | |
|
27 | this->UI = new memctrlrPluginUi(); | |
|
28 | this->setWindowTitle(tr("Memctrlr Driver")); | |
|
29 | this->setWidget((QWidget*)this->UI); | |
|
30 | connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); | |
|
31 | connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); | |
|
32 | this->pyObject = new memctrlrPyWrapper(this); | |
|
33 | connect(this->pyObject,SIGNAL(launchTest(uint,uint)),this,SLOT(launchTest(uint,uint))); | |
|
34 | } | |
|
35 | ||
|
36 | memctrlrplugin::~memctrlrplugin() | |
|
37 | {} | |
|
38 | ||
|
39 | int memctrlrplugin::registermenu(QMainWindow *menuHolder) | |
|
40 | { | |
|
41 | this->menu = menuHolder->menuBar()->addMenu(tr("&Memory Controler")); | |
|
42 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
|
43 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
|
44 | return 1; | |
|
45 | } | |
|
46 | ||
|
47 | unsigned int memctrlrplugin::Write(unsigned int *Value,unsigned int count,unsigned int address) | |
|
48 | { | |
|
49 | if(parent) | |
|
50 | return parent->Write(Value,count,address); | |
|
51 | return 0; | |
|
52 | } | |
|
53 | ||
|
54 | unsigned int memctrlrplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
55 | { | |
|
56 | if(parent) | |
|
57 | return parent->Read(Value,count,address); | |
|
58 | return 0; | |
|
59 | } | |
|
60 | ||
|
61 | ||
|
62 | bool memctrlrplugin::launchTest(unsigned int baseAddress,unsigned int size) | |
|
63 | { | |
|
64 | if(parent==NULL)return false; | |
|
65 | unsigned int* dataLocal = (unsigned int*)malloc(size); | |
|
66 | unsigned int* dataOnBoard = (unsigned int*)malloc(size); | |
|
67 | bool res=true; | |
|
68 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
69 | { | |
|
70 | dataLocal[i]= (0xFFFF&rand())+(rand()<<16); | |
|
71 | } | |
|
72 | parent->Write(dataLocal,size>>2,baseAddress); | |
|
73 | parent->Read(dataOnBoard,size>>2,baseAddress); | |
|
74 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
75 | { | |
|
76 | if(dataLocal[i]!=dataOnBoard[i]) | |
|
77 | res=false; | |
|
78 | } | |
|
79 | ||
|
80 | free(dataLocal); | |
|
81 | free(dataOnBoard); | |
|
82 | return res; | |
|
83 | } | |
|
84 | ||
|
85 | ||
|
86 |
@@ -0,0 +1,50 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef MEMCTRLRPLUGIN_H | |
|
23 | #define MEMCTRLRPLUGIN_H | |
|
24 | #include "memctrlrpluginui.h" | |
|
25 | #include <QMenuBar> | |
|
26 | #include <QMenu> | |
|
27 | #include <QAction> | |
|
28 | #include <QMainWindow> | |
|
29 | ||
|
30 | ||
|
31 | #include <socexplorerplugin.h> | |
|
32 | ||
|
33 | class memctrlrplugin : public socexplorerplugin | |
|
34 | { | |
|
35 | Q_OBJECT | |
|
36 | public: | |
|
37 | explicit memctrlrplugin(QWidget *parent = 0); | |
|
38 | ~memctrlrplugin(); | |
|
39 | int registermenu(QMainWindow *menuHolder); | |
|
40 | public slots: | |
|
41 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
42 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
43 | bool launchTest(unsigned int baseAddress,unsigned int size); | |
|
44 | signals: | |
|
45 | ||
|
46 | private: | |
|
47 | memctrlrPluginUi* UI; | |
|
48 | }; | |
|
49 | ||
|
50 | #endif // MEMCTRLRPLUGIN_H |
@@ -0,0 +1,73 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | CONFIG += dll | |
|
8 | CONFIG -= static | |
|
9 | ||
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | ||
|
16 | TARGET = memctrlrplugin$${DEBUG_EXT} | |
|
17 | DEFINES += PLUGIN=memctrlrplugin | |
|
18 | DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" | |
|
19 | DEFINES += driver_Name="\"\\\"MemControler"\\\"\" | |
|
20 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
|
21 | DEFINES += driver_Version="\"\\\"1.0.1"\\\"\" | |
|
22 | DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\" | |
|
23 | DEFINES += driver_can_be_root=0 | |
|
24 | DEFINES += driver_can_be_child=1 | |
|
25 | DEFINES += driver_VID=0x04 | |
|
26 | DEFINES += driver_PID=0x0f | |
|
27 | ||
|
28 | #LIBS +=-llppmoncommon | |
|
29 | ||
|
30 | INCLUDEPATH += \ | |
|
31 | $${PWD} | |
|
32 | ||
|
33 | HEADERS += \ | |
|
34 | memctrlrplugin.h \ | |
|
35 | memctrlrpluginui.h \ | |
|
36 | memorycheck.h \ | |
|
37 | genericmemoryspacecheck.h \ | |
|
38 | memctrlrpywrapper.h | |
|
39 | ||
|
40 | SOURCES += \ | |
|
41 | memctrlrplugin.cpp \ | |
|
42 | memctrlrpluginui.cpp \ | |
|
43 | memorycheck.cpp \ | |
|
44 | genericmemoryspacecheck.cpp \ | |
|
45 | memctrlrpywrapper.cpp | |
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 |
@@ -0,0 +1,36 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #include "memctrlrpluginui.h" | |
|
23 | ||
|
24 | memctrlrPluginUi::memctrlrPluginUi(QWidget *parent) : | |
|
25 | QWidget(parent) | |
|
26 | { | |
|
27 | this->mainlayout = new QHBoxLayout; | |
|
28 | this->memorycheckWdgt = new memorycheck; | |
|
29 | this->tabWdgt = new QTabWidget; | |
|
30 | this->tabWdgt->addTab(this->memorycheckWdgt,QString(tr("Memory Check"))); | |
|
31 | this->mainlayout->addWidget(this->tabWdgt); | |
|
32 | this->setLayout(this->mainlayout); | |
|
33 | connect(this->memorycheckWdgt,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
34 | connect(this->memorycheckWdgt,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
35 | } | |
|
36 |
@@ -0,0 +1,49 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the LPPMON Software | |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef MEMCTRLRPLUGINUI_H | |
|
23 | #define MEMCTRLRPLUGINUI_H | |
|
24 | ||
|
25 | #include <QWidget> | |
|
26 | #include <QHBoxLayout> | |
|
27 | #include <QPushButton> | |
|
28 | #include <QTabWidget> | |
|
29 | #include "memorycheck.h" | |
|
30 | ||
|
31 | ||
|
32 | class memctrlrPluginUi : public QWidget | |
|
33 | { | |
|
34 | Q_OBJECT | |
|
35 | public: | |
|
36 | explicit memctrlrPluginUi(QWidget *parent = 0); | |
|
37 | ||
|
38 | signals: | |
|
39 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
40 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
41 | ||
|
42 | private: | |
|
43 | QHBoxLayout* mainlayout; | |
|
44 | QTabWidget* tabWdgt; | |
|
45 | memorycheck* memorycheckWdgt; | |
|
46 | ||
|
47 | }; | |
|
48 | ||
|
49 | #endif |
@@ -0,0 +1,6 | |||
|
1 | #include "memctrlrpywrapper.h" | |
|
2 | ||
|
3 | memctrlrPyWrapper::memctrlrPyWrapper(socexplorerplugin *parent) : | |
|
4 | genericPySysdriver(parent) | |
|
5 | { | |
|
6 | } |
@@ -0,0 +1,17 | |||
|
1 | #ifndef MEMCTRLRPYWRAPPER_H | |
|
2 | #define MEMCTRLRPYWRAPPER_H | |
|
3 | #include <genericPySysdriver.h> | |
|
4 | ||
|
5 | class memctrlrPyWrapper : public genericPySysdriver | |
|
6 | { | |
|
7 | Q_OBJECT | |
|
8 | public: | |
|
9 | explicit memctrlrPyWrapper(socexplorerplugin *parent = 0); | |
|
10 | ||
|
11 | signals: | |
|
12 | bool launchTest(unsigned int baseAddress,unsigned int size); | |
|
13 | public slots: | |
|
14 | ||
|
15 | }; | |
|
16 | ||
|
17 | #endif // MEMCTRLRPYWRAPPER_H |
@@ -0,0 +1,16 | |||
|
1 | #include "memorycheck.h" | |
|
2 | ||
|
3 | memorycheck::memorycheck(QWidget *parent) : | |
|
4 | QWidget(parent) | |
|
5 | { | |
|
6 | this->mainLayout = new QVBoxLayout; | |
|
7 | this->ROMcheck=new genericmemoryspacecheck(QString("ROM"),0,512*1024*1024); | |
|
8 | this->SRAMcheck =new genericmemoryspacecheck(QString("SRAM"),0x40000000,512*1024*1024); | |
|
9 | this->mainLayout->addWidget(this->ROMcheck); | |
|
10 | this->mainLayout->addWidget(this->SRAMcheck); | |
|
11 | this->setLayout(this->mainLayout); | |
|
12 | connect(this->ROMcheck,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
13 | connect(this->ROMcheck,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
14 | connect(this->SRAMcheck,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); | |
|
15 | connect(this->SRAMcheck,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); | |
|
16 | } |
@@ -0,0 +1,28 | |||
|
1 | #ifndef MEMORYCHECK_H | |
|
2 | #define MEMORYCHECK_H | |
|
3 | ||
|
4 | #include <QWidget> | |
|
5 | #include <qhexspinbox.h> | |
|
6 | #include "genericmemoryspacecheck.h" | |
|
7 | #include <QHBoxLayout> | |
|
8 | #include <QVBoxLayout> | |
|
9 | ||
|
10 | ||
|
11 | class memorycheck : public QWidget | |
|
12 | { | |
|
13 | Q_OBJECT | |
|
14 | public: | |
|
15 | explicit memorycheck(QWidget *parent = 0); | |
|
16 | ||
|
17 | signals: | |
|
18 | unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
19 | unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); | |
|
20 | public slots: | |
|
21 | private: | |
|
22 | QVBoxLayout* mainLayout; | |
|
23 | genericmemoryspacecheck* ROMcheck; | |
|
24 | genericmemoryspacecheck* SRAMcheck; | |
|
25 | ||
|
26 | }; | |
|
27 | ||
|
28 | #endif // MEMORYCHECK_H |
@@ -0,0 +1,29 | |||
|
1 | #include "abstractspwbridge.h" | |
|
2 | ||
|
3 | abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) | |
|
4 | :QObject((QObject*)parent) | |
|
5 | { | |
|
6 | this->plugin = parent; | |
|
7 | } | |
|
8 | ||
|
9 | QWidget *abstractSpwBridge::getGUI() | |
|
10 | { | |
|
11 | return this->p_GUI; | |
|
12 | } | |
|
13 | ||
|
14 | bool abstractSpwBridge::connectBridge() | |
|
15 | { | |
|
16 | return false; | |
|
17 | } | |
|
18 | ||
|
19 | bool abstractSpwBridge::disconnectBridge() | |
|
20 | { | |
|
21 | return false; | |
|
22 | } | |
|
23 | ||
|
24 | ||
|
25 | ||
|
26 | ||
|
27 | ||
|
28 | ||
|
29 |
@@ -0,0 +1,29 | |||
|
1 | #ifndef ABSTRACTSPWBRIDGE_H | |
|
2 | #define ABSTRACTSPWBRIDGE_H | |
|
3 | ||
|
4 | #include <QObject> | |
|
5 | #include <socexplorerplugin.h> | |
|
6 | #define RMAP_MAX_XFER_SIZE 3000 //slightly less than 16kBytes | |
|
7 | #include <spw.h> | |
|
8 | ||
|
9 | class abstractSpwBridge : public QObject | |
|
10 | { | |
|
11 | Q_OBJECT | |
|
12 | public: | |
|
13 | explicit abstractSpwBridge(socexplorerplugin *parent); | |
|
14 | QWidget *getGUI(); | |
|
15 | ||
|
16 | public slots: | |
|
17 | virtual bool connectBridge(); | |
|
18 | virtual bool disconnectBridge(); | |
|
19 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
|
20 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
|
21 | virtual int pushRMAPPacket(char* packet,int size)=0; | |
|
22 | protected: | |
|
23 | socexplorerplugin* plugin; | |
|
24 | QWidget* p_GUI; | |
|
25 | private: | |
|
26 | ||
|
27 | }; | |
|
28 | ||
|
29 | #endif // ABSTRACTSPWBRIDGE_H |
@@ -0,0 +1,192 | |||
|
1 | #ifndef SPW_H | |
|
2 | #define SPW_H | |
|
3 | #include <stdint.h> | |
|
4 | ||
|
5 | /* | |
|
6 | ███████╗██████╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗███╗ ███╗ ██████╗ ███╗ ██╗ | |
|
7 | ██╔════╝██╔══██╗██║ ██║ ██╔════╝██╔═══██╗████╗ ████║████╗ ████║██╔═══██╗████╗ ██║ | |
|
8 | ███████╗██████╔╝██║ █╗ ██║ ██║ ██║ ██║██╔████╔██║██╔████╔██║██║ ██║██╔██╗ ██║ | |
|
9 | ╚════██║██╔═══╝ ██║███╗██║ ██║ ██║ ██║██║╚██╔╝██║██║╚██╔╝██║██║ ██║██║╚██╗██║ | |
|
10 | ███████║██║ ╚███╔███╔╝ ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║╚██████╔╝██║ ╚████║ | |
|
11 | ╚══════╝╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ | |
|
12 | */ | |
|
13 | ||
|
14 | enum SPW_PROTOCOL_IDs{ | |
|
15 | SPW_PROTO_ID_EXTEND =0, | |
|
16 | SPW_PROTO_ID_RMAP = 1, | |
|
17 | SPW_PROTO_ID_CCSDS = 2, | |
|
18 | SPW_PROTO_ID_GOES_R = 238, | |
|
19 | SPW_PROTO_ID_STUP = 239 | |
|
20 | }; | |
|
21 | ||
|
22 | static const unsigned char SPW_CRCTable[] = { | |
|
23 | 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, | |
|
24 | 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, | |
|
25 | 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, | |
|
26 | 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67, | |
|
27 | 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d, | |
|
28 | 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43, | |
|
29 | 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51, | |
|
30 | 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f, | |
|
31 | 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05, | |
|
32 | 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b, | |
|
33 | 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19, | |
|
34 | 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17, | |
|
35 | 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d, | |
|
36 | 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33, | |
|
37 | 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21, | |
|
38 | 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f, | |
|
39 | 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95, | |
|
40 | 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b, | |
|
41 | 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89, | |
|
42 | 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87, | |
|
43 | 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad, | |
|
44 | 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3, | |
|
45 | 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1, | |
|
46 | 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf, | |
|
47 | 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5, | |
|
48 | 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb, | |
|
49 | 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9, | |
|
50 | 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7, | |
|
51 | 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd, | |
|
52 | 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3, | |
|
53 | 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1, | |
|
54 | 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf | |
|
55 | }; | |
|
56 | ||
|
57 | inline unsigned char _spw_CRC_(unsigned char INCR, unsigned char INBYTE) | |
|
58 | { | |
|
59 | return SPW_CRCTable[INCR ^ INBYTE]; | |
|
60 | } | |
|
61 | ||
|
62 | inline char spw_CRC(char* buffer, int size) | |
|
63 | { | |
|
64 | unsigned char CRC = 0; | |
|
65 | for(int i=0;i<size;i++) | |
|
66 | { | |
|
67 | CRC = _spw_CRC_(CRC,(unsigned char)buffer[i]); | |
|
68 | } | |
|
69 | return CRC; | |
|
70 | } | |
|
71 | ||
|
72 | /* | |
|
73 | ██████╗ ███╗ ███╗ █████╗ ██████╗ ██████╗ ██████╗ ██████╗ ████████╗ ██████╗ ██████╗ ██████╗ ██╗ | |
|
74 | ██╔══██╗████╗ ████║██╔══██╗██╔══██╗ ██╔══██╗██╔══██╗██╔═══██╗╚══██╔══╝██╔═══██╗██╔════╝██╔═══██╗██║ | |
|
75 | ██████╔╝██╔████╔██║███████║██████╔╝ ██████╔╝██████╔╝██║ ██║ ██║ ██║ ██║██║ ██║ ██║██║ | |
|
76 | ██╔══██╗██║╚██╔╝██║██╔══██║██╔═══╝ ██╔═══╝ ██╔══██╗██║ ██║ ██║ ██║ ██║██║ ██║ ██║██║ | |
|
77 | ██║ ██║██║ ╚═╝ ██║██║ ██║██║ ██║ ██║ ██║╚██████╔╝ ██║ ╚██████╔╝╚██████╗╚██████╔╝███████╗ | |
|
78 | ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ | |
|
79 | */ | |
|
80 | ||
|
81 | enum RMAP_CMD_CODE{ | |
|
82 | RMAP_CMD_CODE_invalid0, //0000 | |
|
83 | RMAP_CMD_CODE_invalid1, //0001 | |
|
84 | RMAP_CMD_CODE_read_Single, //0010 | |
|
85 | RMAP_CMD_CODE_read_Inc, //0011 | |
|
86 | RMAP_CMD_CODE_invalid2, //0100 | |
|
87 | RMAP_CMD_CODE_invalid3, //0101 | |
|
88 | RMAP_CMD_CODE_invalid4, //0110 | |
|
89 | RMAP_CMD_CODE_readModWri_Inc, //0111 | |
|
90 | RMAP_CMD_CODE_writeSingle_noVer_noRep, //1000 | |
|
91 | RMAP_CMD_CODE_writeInc_noVer_noRep, //1001 | |
|
92 | RMAP_CMD_CODE_writeSingle_noVer_Rep, //1010 | |
|
93 | RMAP_CMD_CODE_writeInc_noVer_Rep, //1011 | |
|
94 | RMAP_CMD_CODE_writeSingle_ver_noRep, //1100 | |
|
95 | RMAP_CMD_CODE_writeInc_ver_noRep, //1101 | |
|
96 | RMAP_CMD_CODE_writeSingle_ver_rep, //1110 | |
|
97 | RMAP_CMD_CODE_writeInc_ver_rep //1111 | |
|
98 | }; | |
|
99 | ||
|
100 | /* | |
|
101 | * Rmap read command header: | |
|
102 | * | |
|
103 | * | Destination Logical Address | Protocol identifier | Packet type | Destination key | | |
|
104 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
105 | * | Source Logical Address | Transaction identifier | Transaction identifier | Extended read address | | |
|
106 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
107 | * | Read address MSB | Read address | Read address | Read address LSB | | |
|
108 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
109 | * | Data length MSB | Data length | Data length LSB | CRC | | |
|
110 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
111 | * | |
|
112 | * Packet type field: | |
|
113 | * | |
|
114 | * | msb | |
|
115 | * | reserved = 0 | Comand = 1| Read = 0 | Read = 0 | Read = 1 | Increment/ | Source Path | Source Path | | |
|
116 | * | (Ack/NoAck) | No Inc. address | Address Length | Address Length | | |
|
117 | * | |
|
118 | */ | |
|
119 | #define RMAP_READ_HEADER_MIN_SZ 16 | |
|
120 | ||
|
121 | inline void RMAP_build_rx_request_header(char destinationLogicalAddress, char destKey,char sourceLogicalAddress,uint16_t transactionID,int readAddress,int length,char *buffer) | |
|
122 | { | |
|
123 | buffer[0] = destinationLogicalAddress; | |
|
124 | buffer[1] = SPW_PROTO_ID_RMAP; | |
|
125 | buffer[2] = 0b01001100; | |
|
126 | buffer[3] = destKey; | |
|
127 | buffer[4] = sourceLogicalAddress; | |
|
128 | buffer[5] = (char)(transactionID >> 8); | |
|
129 | buffer[6] = (char)(transactionID); | |
|
130 | buffer[7] = 0; | |
|
131 | buffer[8] = (char)(readAddress >> 24); | |
|
132 | buffer[9] = (char)(readAddress >> 16); | |
|
133 | buffer[10] = (char)(readAddress >> 8); | |
|
134 | buffer[11] = (char)(readAddress); | |
|
135 | buffer[12] = (char)(length >> 16); | |
|
136 | buffer[13] = (char)(length >> 8); | |
|
137 | buffer[14] = (char)(length); | |
|
138 | buffer[15] = (char)spw_CRC(buffer,15); | |
|
139 | } | |
|
140 | ||
|
141 | inline int RMAP_get_transactionID(char *packet) | |
|
142 | { | |
|
143 | return ((((unsigned int)packet[5])<<8) + ((unsigned int)packet[6])); | |
|
144 | } | |
|
145 | ||
|
146 | ||
|
147 | /* | |
|
148 | * Rmap Write command header: | |
|
149 | * | |
|
150 | * | Destination Logical Address | Protocol identifier | Packet type | Destination key | | |
|
151 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
152 | * | Source Logical Address | Transaction identifier | Transaction identifier | Extended write address | | |
|
153 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
154 | * | Write address MSB | Write address | Write address | Write address LSB | | |
|
155 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
156 | * | Data length MSB | Data length | Data length LSB | Header CRC | | |
|
157 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
158 | * | Data | (...) | Last data byte | Data CRC | | |
|
159 | * |-----------------------------|------------------------|------------------------|------------------------| | |
|
160 | * | |
|
161 | * Packet type field: | |
|
162 | * | |
|
163 | * | msb | |
|
164 | * | reserved = 0 | Comand = 1| Write = 1 | Verify data = 1 | Ack = 1 | Increment/ | Source Path | Source Path | | |
|
165 | * | Don't Verify data = 0 | No Ack = 0 | No Inc. address | Address Length | Address Length | | |
|
166 | * | |
|
167 | */ | |
|
168 | #define RMAP_WRITE_HEADER_MIN_SZ 16 | |
|
169 | #define RMAP_WRITE_PACKET_MIN_SZ(bytesCnt) (RMAP_WRITE_HEADER_MIN_SZ+bytesCnt+1) //header=16 + data + data CRC=1 | |
|
170 | ||
|
171 | inline void RMAP_build_tx_request_header(char destinationLogicalAddress, char destKey,char sourceLogicalAddress,uint16_t transactionID,int readAddress,int length,char *buffer) | |
|
172 | { | |
|
173 | buffer[0] = destinationLogicalAddress; | |
|
174 | buffer[1] = SPW_PROTO_ID_RMAP; | |
|
175 | buffer[2] = 0b01101100; | |
|
176 | buffer[3] = destKey; | |
|
177 | buffer[4] = sourceLogicalAddress; | |
|
178 | buffer[5] = (char)(transactionID >> 8); | |
|
179 | buffer[6] = (char)(transactionID); | |
|
180 | buffer[7] = 0; | |
|
181 | buffer[8] = (char)(readAddress >> 24); | |
|
182 | buffer[9] = (char)(readAddress >> 16); | |
|
183 | buffer[10] = (char)(readAddress >> 8); | |
|
184 | buffer[11] = (char)(readAddress); | |
|
185 | buffer[12] = (char)(length >> 16); | |
|
186 | buffer[13] = (char)(length >> 8); | |
|
187 | buffer[14] = (char)(length); | |
|
188 | buffer[15] = (char)spw_CRC(buffer,15); | |
|
189 | buffer[16+length] = (char)spw_CRC(buffer+16,length); | |
|
190 | } | |
|
191 | ||
|
192 | #endif // SPW_H |
@@ -0,0 +1,53 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -------------------------------------------------------------------------------*/ | |
|
3 | /*-- Author : Alexis Jeandet | |
|
4 | -- Mail : alexis.jeandet@member.fsf.org | |
|
5 | ----------------------------------------------------------------------------*/ | |
|
6 | #include "spwplugin.h" | |
|
7 | #include "stardundeespw_usb.h" | |
|
8 | ||
|
9 | ||
|
10 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) | |
|
11 | { | |
|
12 | Q_UNUSED(parent) | |
|
13 | this->bridge = new stardundeeSPW_USB(this); | |
|
14 | if(this->bridge->connectBridge()) | |
|
15 | { | |
|
16 | this->Connected = true; | |
|
17 | emit this->activateSig(true); | |
|
18 | } | |
|
19 | } | |
|
20 | ||
|
21 | ||
|
22 | spwplugin::~spwplugin() | |
|
23 | { | |
|
24 | ||
|
25 | } | |
|
26 | ||
|
27 | ||
|
28 | ||
|
29 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
|
30 | { | |
|
31 | if(Connected) | |
|
32 | { | |
|
33 | return bridge->Read(Value,count,address); | |
|
34 | } | |
|
35 | return 0; | |
|
36 | } | |
|
37 | ||
|
38 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
|
39 | { | |
|
40 | if(Connected) | |
|
41 | { | |
|
42 | return bridge->Write(Value,count,address); | |
|
43 | } | |
|
44 | return 0; | |
|
45 | } | |
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 |
@@ -0,0 +1,45 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -------------------------------------------------------------------------------*/ | |
|
3 | /*-- Author : Alexis Jeandet | |
|
4 | -- Mail : alexis.jeandet@member.fsf.org | |
|
5 | ----------------------------------------------------------------------------*/ | |
|
6 | #ifndef spwplugin_H | |
|
7 | #define spwplugin_H | |
|
8 | #include <QMenuBar> | |
|
9 | #include <QMenu> | |
|
10 | #include <QAction> | |
|
11 | #include <QLayout> | |
|
12 | ||
|
13 | #include <socexplorerplugin.h> | |
|
14 | #include <abstractspwbridge.h> | |
|
15 | ||
|
16 | ||
|
17 | class spwplugin : public socexplorerplugin | |
|
18 | { | |
|
19 | Q_OBJECT | |
|
20 | public: | |
|
21 | explicit spwplugin(QWidget *parent = 0); | |
|
22 | ~spwplugin(); | |
|
23 | /* You can implement the folowing function if you want to overwrite | |
|
24 | * their default behavior | |
|
25 | */ | |
|
26 | /* | |
|
27 | int registermenu(QMainWindow *menuHolder); | |
|
28 | int isConnected(); | |
|
29 | int connect(); | |
|
30 | int VID(){return driver_VID;} | |
|
31 | int PID(){return driver_PID;} | |
|
32 | */ | |
|
33 | ||
|
34 | public slots: | |
|
35 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
36 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
37 | signals: | |
|
38 | ||
|
39 | private: | |
|
40 | abstractSpwBridge* bridge; | |
|
41 | ||
|
42 | }; | |
|
43 | ||
|
44 | #endif // spwplugin_H | |
|
45 |
@@ -0,0 +1,69 | |||
|
1 | # | |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
|
3 | # | |
|
4 | #------------------------------------------------- | |
|
5 | ||
|
6 | CONFIG += socexplorerplugin | |
|
7 | win32:CONFIG += dll | |
|
8 | win32:CONFIG -= static | |
|
9 | CONFIG(debug, debug|release) { | |
|
10 | DEBUG_EXT = _d | |
|
11 | } else { | |
|
12 | DEBUG_EXT = | |
|
13 | } | |
|
14 | TARGET = spwplugin$${DEBUG_EXT} | |
|
15 | DEFINES += PLUGIN=spwplugin | |
|
16 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" | |
|
17 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" | |
|
18 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
|
19 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
|
20 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" | |
|
21 | DEFINES += driver_can_be_root=1 | |
|
22 | DEFINES += driver_can_be_child=0 | |
|
23 | DEFINES += driver_VID=0 | |
|
24 | DEFINES += driver_PID=0 | |
|
25 | ||
|
26 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ | |
|
27 | ||
|
28 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ | |
|
29 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so | |
|
30 | ||
|
31 | INCLUDEPATH += \ | |
|
32 | $${PWD} \ | |
|
33 | $$STARTDUNDEEPATH/inc \ | |
|
34 | ||
|
35 | HEADERS += \ | |
|
36 | spwplugin.h \ | |
|
37 | stardundeespw_usb.h \ | |
|
38 | abstractspwbridge.h \ | |
|
39 | spw.h | |
|
40 | ||
|
41 | ||
|
42 | SOURCES += \ | |
|
43 | spwplugin.cpp \ | |
|
44 | stardundeespw_usb.cpp \ | |
|
45 | abstractspwbridge.cpp | |
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | ||
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 |
@@ -0,0 +1,424 | |||
|
1 | #include "stardundeespw_usb.h" | |
|
2 | #include <socexplorerengine.h> | |
|
3 | #include <qhexedit.h> | |
|
4 | ||
|
5 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
|
6 | abstractSpwBridge(parent) | |
|
7 | { | |
|
8 | Q_UNUSED(parent) | |
|
9 | this->manager = new stardundeeSPW_USB_Manager(parent); | |
|
10 | this->manager->start(); | |
|
11 | } | |
|
12 | ||
|
13 | bool stardundeeSPW_USB::connectBridge() | |
|
14 | { | |
|
15 | return this->manager->connectBridge(); | |
|
16 | } | |
|
17 | ||
|
18 | bool stardundeeSPW_USB::disconnectBridge() | |
|
19 | { | |
|
20 | return this->manager->disconnectBridge(); | |
|
21 | } | |
|
22 | ||
|
23 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
|
24 | { | |
|
25 | return this->manager->sendPacket(packet,size); | |
|
26 | } | |
|
27 | ||
|
28 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
|
29 | { | |
|
30 | //Add transactionID! | |
|
31 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE)+1]; | |
|
32 | writeBuffer[0]=1;//Link number | |
|
33 | int transactionID = 0; | |
|
34 | int written=0; | |
|
35 | SocExplorerEngine::message(this->plugin,"Enter Write function"); | |
|
36 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
|
37 | for(;count>=RMAP_MAX_XFER_SIZE;count-=RMAP_MAX_XFER_SIZE) | |
|
38 | { | |
|
39 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
|
40 | { | |
|
41 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char) ((unsigned int) Value[written+i]>>24); | |
|
42 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char) ((unsigned int) Value[written+i]>>16); | |
|
43 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char) ((unsigned int) Value[written+i]>>8); | |
|
44 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char) ((unsigned int) Value[written+i]); | |
|
45 | } | |
|
46 | RMAP_build_tx_request_header(254,2,1,transactionID,address+written,RMAP_MAX_XFER_SIZE*4,writeBuffer+1); | |
|
47 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
|
48 | written+=RMAP_MAX_XFER_SIZE; | |
|
49 | } | |
|
50 | if(count>0) | |
|
51 | { | |
|
52 | for(int i=0;i<((int)count);i++) | |
|
53 | { | |
|
54 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char) ((unsigned int) Value[written+i]>>24); | |
|
55 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char) ((unsigned int) Value[written+i]>>16); | |
|
56 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char) ((unsigned int) Value[written+i]>>8); | |
|
57 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char) ((unsigned int) Value[written+i]); | |
|
58 | } | |
|
59 | RMAP_build_tx_request_header(254,2,1,transactionID,address+written,count*4,writeBuffer+1); | |
|
60 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
|
61 | // QHexEdit* viewer = new QHexEdit(); | |
|
62 | // viewer->setData(QByteArray(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4)+1)); | |
|
63 | // viewer->show(); | |
|
64 | written+=count; | |
|
65 | } | |
|
66 | return written; | |
|
67 | } | |
|
68 | ||
|
69 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
|
70 | { | |
|
71 | //Add transactionID! | |
|
72 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
|
73 | char* RMAP_AnswerBuffer; | |
|
74 | requestBuffer[0]=1;//Link number | |
|
75 | int transactionID = 0; | |
|
76 | int read=0; | |
|
77 | // SocExplorerEngine::message(this->plugin,"Enter read function"); | |
|
78 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE)); | |
|
79 | ||
|
80 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
|
81 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
|
82 | { | |
|
83 | transactionID = manager->getRMAPtransactionID(); | |
|
84 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID)); | |
|
85 | RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); | |
|
86 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
|
87 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
|
88 | for(int i=0;i<(len/4);i++) | |
|
89 | { | |
|
90 | Value[read+i]=((unsigned int)(RMAP_AnswerBuffer[i])<<24) + ((unsigned int)(RMAP_AnswerBuffer[i+1])<<16) + ((unsigned int)(RMAP_AnswerBuffer[i+2])<<8) + ((unsigned int)(RMAP_AnswerBuffer[i+3])); | |
|
91 | } | |
|
92 | free(RMAP_AnswerBuffer); | |
|
93 | read+=RMAP_MAX_XFER_SIZE; | |
|
94 | count-=RMAP_MAX_XFER_SIZE; | |
|
95 | } | |
|
96 | if((int)count>0) | |
|
97 | { | |
|
98 | transactionID = manager->getRMAPtransactionID(); | |
|
99 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID)); | |
|
100 | SocExplorerEngine::message(this->plugin,QString("Building request with:")); | |
|
101 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16)); | |
|
102 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4)); | |
|
103 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13)); | |
|
104 | RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),count*4,requestBuffer+1); | |
|
105 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
|
106 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
|
107 | for(int i=0;i<(len/4);i++) | |
|
108 | { | |
|
109 | Value[read+i]=((unsigned int)(RMAP_AnswerBuffer[i])<<24) + ((unsigned int)(RMAP_AnswerBuffer[i+1])<<16) + ((unsigned int)(RMAP_AnswerBuffer[i+2])<<8) + ((unsigned int)(RMAP_AnswerBuffer[i+3])); | |
|
110 | } | |
|
111 | free(RMAP_AnswerBuffer); | |
|
112 | read+=count; | |
|
113 | } | |
|
114 | return read; | |
|
115 | } | |
|
116 | ||
|
117 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *parent) | |
|
118 | :QThread((QObject*)parent) | |
|
119 | { | |
|
120 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
|
121 | this->RMAP_AnswersSem = new QSemaphore(0); | |
|
122 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
|
123 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
|
124 | this->plugin = parent; | |
|
125 | connected = false; | |
|
126 | } | |
|
127 | ||
|
128 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
|
129 | { | |
|
130 | this->terminate(); | |
|
131 | while (!this->isFinished()) { | |
|
132 | this->usleep(1000); | |
|
133 | } | |
|
134 | } | |
|
135 | ||
|
136 | ||
|
137 | void stardundeeSPW_USB_Manager::run() | |
|
138 | { | |
|
139 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
|
140 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
|
141 | USB_SPACEWIRE_STATUS stat; | |
|
142 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread"); | |
|
143 | char buffer[RMAP_MAX_XFER_SIZE*4]; | |
|
144 | while (!this->isInterruptionRequested()) | |
|
145 | { | |
|
146 | if(this->connected) | |
|
147 | { | |
|
148 | handleMutex->lock(); | |
|
149 | //SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets"); | |
|
150 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
|
151 | { | |
|
152 | SocExplorerEngine::message(this->plugin,"Got packet"); | |
|
153 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, RMAP_MAX_XFER_SIZE*4,1, 1, &properties, &pIdentifier); | |
|
154 | if (stat == TRANSFER_SUCCESS) | |
|
155 | { | |
|
156 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
|
157 | { | |
|
158 | SocExplorerEngine::message(this->plugin,"It's a SPW packet"); | |
|
159 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
|
160 | { | |
|
161 | SocExplorerEngine::message(this->plugin,"Got end of packet"); | |
|
162 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
|
163 | { | |
|
164 | SocExplorerEngine::message(this->plugin,"Got RMAP packet"); | |
|
165 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len)); | |
|
166 | char* packetbuffer = (char*)malloc(properties.len-13); | |
|
167 | memcpy(packetbuffer,buffer+12,properties.len-13); | |
|
168 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
|
169 | pIdentifier = NULL; | |
|
170 | handleMutex->unlock(); | |
|
171 | RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
|
172 | RMAP_AnswersMtx->lock(); | |
|
173 | RMAP_Answers.append(packet); | |
|
174 | RMAP_AnswersMtx->unlock(); | |
|
175 | RMAP_AnswersSem->release(); | |
|
176 | } | |
|
177 | else //any non-rmap packet will be pushed to the network | |
|
178 | { | |
|
179 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
|
180 | handleMutex->unlock(); | |
|
181 | SocExplorerEngine::message(this->plugin,"Got SPW packet"); | |
|
182 | } | |
|
183 | } | |
|
184 | else | |
|
185 | { | |
|
186 | SocExplorerEngine::message(this->plugin,"No EOP received"); | |
|
187 | } | |
|
188 | } | |
|
189 | ||
|
190 | } | |
|
191 | else | |
|
192 | { | |
|
193 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
|
194 | handleMutex->unlock(); | |
|
195 | } | |
|
196 | } | |
|
197 | else | |
|
198 | { | |
|
199 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
|
200 | handleMutex->unlock(); | |
|
201 | } | |
|
202 | } | |
|
203 | else | |
|
204 | { | |
|
205 | sleep(1); | |
|
206 | SocExplorerEngine::message(this->plugin,"Bridge not connected"); | |
|
207 | } | |
|
208 | usleep(1000); | |
|
209 | // sleep(2); | |
|
210 | } | |
|
211 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread"); | |
|
212 | } | |
|
213 | ||
|
214 | bool stardundeeSPW_USB_Manager::connectBridge() | |
|
215 | { | |
|
216 | this->handleMutex->lock(); | |
|
217 | int status; | |
|
218 | U32 statusControl; | |
|
219 | int brickNumber=0; | |
|
220 | int linkNumber=1; | |
|
221 | this->connected = false; | |
|
222 | if (!USBSpaceWire_Open(&hDevice, brickNumber)) // Open the USB device | |
|
223 | { | |
|
224 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |
|
225 | this->handleMutex->unlock(); | |
|
226 | return false; | |
|
227 | } | |
|
228 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful"); | |
|
229 | ||
|
230 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
|
231 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
|
232 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
|
233 | ||
|
234 | // Set the path and return path to the device | |
|
235 | CFGSpaceWire_StackClear(); | |
|
236 | CFGSpaceWire_AddrStackPush(0); | |
|
237 | CFGSpaceWire_AddrStackPush(254); | |
|
238 | CFGSpaceWire_RetAddrStackPush(254); | |
|
239 | // set the base transmit rate to 100 MHz | |
|
240 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
|
241 | if (status != CFG_TRANSFER_SUCCESS) | |
|
242 | { | |
|
243 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |
|
244 | return false; | |
|
245 | } | |
|
246 | else | |
|
247 | { | |
|
248 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |
|
249 | } | |
|
250 | ||
|
251 | // read the link status | |
|
252 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
|
253 | { | |
|
254 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
|
255 | return false; | |
|
256 | } | |
|
257 | else | |
|
258 | { | |
|
259 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
|
260 | ||
|
261 | // Set the link status control register properties | |
|
262 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
|
263 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
|
264 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
|
265 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
|
266 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
|
267 | ||
|
268 | // Set the link status control register | |
|
269 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
|
270 | { | |
|
271 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
|
272 | return false; | |
|
273 | } | |
|
274 | else | |
|
275 | { | |
|
276 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(linkNumber)); | |
|
277 | } | |
|
278 | } | |
|
279 | ||
|
280 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
|
281 | { | |
|
282 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); | |
|
283 | return false; | |
|
284 | } | |
|
285 | else | |
|
286 | { | |
|
287 | SocExplorerEngine::message(this->plugin,"Device set to be an interface"); | |
|
288 | } | |
|
289 | ||
|
290 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
|
291 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
|
292 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
|
293 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |
|
294 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |
|
295 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |
|
296 | this->connected = true; | |
|
297 | this->handleMutex->unlock(); | |
|
298 | return true; | |
|
299 | } | |
|
300 | ||
|
301 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
|
302 | { | |
|
303 | this->handleMutex->lock(); | |
|
304 | USBSpaceWire_Close(hDevice); // Close the device | |
|
305 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0)); | |
|
306 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
|
307 | this->handleMutex->unlock(); | |
|
308 | return true; | |
|
309 | } | |
|
310 | ||
|
311 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
|
312 | { | |
|
313 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
|
314 | int ID=0; | |
|
315 | bool found=true; | |
|
316 | while(ID<65536) | |
|
317 | { | |
|
318 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
|
319 | { | |
|
320 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
|
321 | } | |
|
322 | if(found==true)break; | |
|
323 | ID++; | |
|
324 | found = true; | |
|
325 | } | |
|
326 | if(found) | |
|
327 | { | |
|
328 | RMAP_pending_transaction_IDs.append(ID); | |
|
329 | } | |
|
330 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
|
331 | return ID; | |
|
332 | } | |
|
333 | ||
|
334 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
|
335 | { | |
|
336 | *buffer=NULL; | |
|
337 | int count=0; | |
|
338 | while (*buffer==NULL) | |
|
339 | { | |
|
340 | this->RMAP_AnswersMtx->lock(); | |
|
341 | for(int i=0;i<RMAP_Answers.count();i++) | |
|
342 | { | |
|
343 | if(RMAP_Answers[i]->transactionID==transactionID) | |
|
344 | { | |
|
345 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
|
346 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
|
347 | { | |
|
348 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
|
349 | { | |
|
350 | RMAP_pending_transaction_IDs.removeAt(j); | |
|
351 | } | |
|
352 | } | |
|
353 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
|
354 | *buffer = RMAP_Answers[i]->data; | |
|
355 | count = RMAP_Answers[i]->len; | |
|
356 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
|
357 | RMAP_Answers.removeAt(i); | |
|
358 | delete tmp; | |
|
359 | } | |
|
360 | } | |
|
361 | this->RMAP_AnswersMtx->unlock(); | |
|
362 | //if no answer found in the stack wait until a new packet is pushed | |
|
363 | if(!buffer) | |
|
364 | { | |
|
365 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed"); | |
|
366 | this->RMAP_AnswersSem->acquire(); | |
|
367 | } | |
|
368 | } | |
|
369 | return count; | |
|
370 | } | |
|
371 | ||
|
372 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
|
373 | { | |
|
374 | USB_SPACEWIRE_STATUS result; | |
|
375 | USB_SPACEWIRE_ID pIdentifier; | |
|
376 | SocExplorerEngine::message(this->plugin,"Sending SPW packet"); | |
|
377 | this->handleMutex->lock(); | |
|
378 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
|
379 | if (result != TRANSFER_SUCCESS) | |
|
380 | { | |
|
381 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command "); | |
|
382 | this->handleMutex->unlock(); | |
|
383 | return false; | |
|
384 | } | |
|
385 | else | |
|
386 | { | |
|
387 | SocExplorerEngine::message(this->plugin,"Packet sent"); | |
|
388 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
|
389 | } | |
|
390 | this->handleMutex->unlock(); | |
|
391 | return true; | |
|
392 | } | |
|
393 | ||
|
394 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
|
395 | { | |
|
396 | char* packetbuffer = (char*)malloc(len); | |
|
397 | memcpy(packetbuffer,packet,len); | |
|
398 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
|
399 | RMAP_AnswersMtx->lock(); | |
|
400 | RMAP_Answers.append(RMPAPpacket); | |
|
401 | RMAP_AnswersMtx->unlock(); | |
|
402 | } | |
|
403 | ||
|
404 | ||
|
405 | ||
|
406 | ||
|
407 | ||
|
408 | ||
|
409 | ||
|
410 | ||
|
411 | ||
|
412 | ||
|
413 | ||
|
414 | ||
|
415 | ||
|
416 | ||
|
417 | ||
|
418 | ||
|
419 | ||
|
420 | ||
|
421 | ||
|
422 | ||
|
423 | ||
|
424 |
@@ -0,0 +1,71 | |||
|
1 | #ifndef STARDUNDEESPW_USB_H | |
|
2 | #define STARDUNDEESPW_USB_H | |
|
3 | ||
|
4 | #include <QObject> | |
|
5 | #include <spw_usb_api.h> | |
|
6 | #include <spw_config_library.h> | |
|
7 | #include <socexplorerplugin.h> | |
|
8 | #include <abstractspwbridge.h> | |
|
9 | #include <QThread> | |
|
10 | #include <QMutex> | |
|
11 | #include <QSemaphore> | |
|
12 | ||
|
13 | class RMAP_Answer | |
|
14 | { | |
|
15 | public: | |
|
16 | RMAP_Answer(int ID,char* data,int len) | |
|
17 | { | |
|
18 | transactionID = ID; | |
|
19 | this->data = data; | |
|
20 | this->len = len; | |
|
21 | } | |
|
22 | int transactionID; | |
|
23 | char* data; | |
|
24 | int len; | |
|
25 | }; | |
|
26 | ||
|
27 | class stardundeeSPW_USB_Manager: public QThread | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | public: | |
|
31 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *parent = 0); | |
|
32 | ~stardundeeSPW_USB_Manager(); | |
|
33 | void run(); | |
|
34 | bool connectBridge(); | |
|
35 | bool disconnectBridge(); | |
|
36 | int getRMAPtransactionID(); | |
|
37 | int getRMAPanswer(int transactionID,char** buffer); | |
|
38 | bool sendPacket(char* packet,int size); | |
|
39 | private: | |
|
40 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; | |
|
41 | QSemaphore* RMAP_AnswersSem; | |
|
42 | void pushRmapPacket(char* packet,int len); | |
|
43 | star_device_handle hDevice; | |
|
44 | socexplorerplugin* plugin; | |
|
45 | bool connected; | |
|
46 | char* SPWPacketBuff; | |
|
47 | QList<RMAP_Answer*> RMAP_Answers; | |
|
48 | QList<int> RMAP_pending_transaction_IDs; | |
|
49 | }; | |
|
50 | ||
|
51 | class stardundeeSPW_USB : public abstractSpwBridge | |
|
52 | { | |
|
53 | Q_OBJECT | |
|
54 | public: | |
|
55 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); | |
|
56 | ||
|
57 | signals: | |
|
58 | ||
|
59 | public slots: | |
|
60 | bool connectBridge(); | |
|
61 | bool disconnectBridge(); | |
|
62 | int pushRMAPPacket(char* packet,int size); | |
|
63 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
64 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
|
65 | ||
|
66 | private: | |
|
67 | stardundeeSPW_USB_Manager* manager; | |
|
68 | ||
|
69 | }; | |
|
70 | ||
|
71 | #endif // STARDUNDEESPW_USB_H |
General Comments 0
You need to be logged in to leave comments.
Login now