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