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