@@ -0,0 +1,80 | |||||
|
1 | %global upstream_name socexplorer-plugins-0.5 | |||
|
2 | ||||
|
3 | Name: socexplorer-plugins | |||
|
4 | Version: 0.5 | |||
|
5 | Release: 0%{?dist} | |||
|
6 | Summary: Base plugins for SocExplorer. | |||
|
7 | Group: Development/Tools | |||
|
8 | License: GPLv2 | |||
|
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 | |||
|
11 | ||||
|
12 | BuildRequires: python2-devel | |||
|
13 | BuildRequires: qt5-qtbase-devel | |||
|
14 | BuildRequires: qt5-qtwebkit-devel | |||
|
15 | BuildRequires: qt5-qttools-static | |||
|
16 | BuildRequires: qt5-qttools-devel | |||
|
17 | BuildRequires: qt5-qtsvg-devel | |||
|
18 | BuildRequires: qt5-qtxmlpatterns-devel | |||
|
19 | BuildRequires: elfutils-libelf-devel | |||
|
20 | BuildRequires: qt5-pythonqt-devel | |||
|
21 | BuildRequires: socexplorer-devel | |||
|
22 | ||||
|
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. | |||
|
25 | You will get: | |||
|
26 | - AHB UART plugin | |||
|
27 | - APB UART plugin | |||
|
28 | - AMBA plugin | |||
|
29 | - DSU3 plugin | |||
|
30 | - Generic rw plugin | |||
|
31 | - Memcheck & Memectr plugins | |||
|
32 | ||||
|
33 | %prep | |||
|
34 | %setup -q -n %{upstream_name} | |||
|
35 | ||||
|
36 | %build | |||
|
37 | %{_qt5_qmake} | |||
|
38 | ||||
|
39 | make %{?_smp_mflags} | |||
|
40 | ||||
|
41 | %install | |||
|
42 | make install INSTALL_ROOT=%{buildroot} | |||
|
43 | ||||
|
44 | %post -p /sbin/ldconfig | |||
|
45 | ||||
|
46 | %postun -p /sbin/ldconfig | |||
|
47 | ||||
|
48 | %files | |||
|
49 | %{_qt5_libdir}/SocExplorer/plugins/libApbUartPlugin.so* | |||
|
50 | %{_qt5_libdir}/SocExplorer/plugins/libahbuartplugin.so* | |||
|
51 | %{_qt5_libdir}/SocExplorer/plugins/libambaplugin.so* | |||
|
52 | %{_qt5_libdir}/SocExplorer/plugins/libdsu3plugin.so* | |||
|
53 | %{_qt5_libdir}/SocExplorer/plugins/libgenericrwplugin.so* | |||
|
54 | %{_qt5_libdir}/SocExplorer/plugins/libmemcheckplugin.so* | |||
|
55 | %{_qt5_libdir}/SocExplorer/plugins/libmemctrlrplugin.so* | |||
|
56 | ||||
|
57 | %changelog | |||
|
58 | * Thu Mar 26 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.5 | |||
|
59 | -Uses r51 as source. | |||
|
60 | ||||
|
61 | * Wed Mar 25 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
62 | -Uses r50 as source. | |||
|
63 | ||||
|
64 | * Fri Mar 20 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
65 | -Uses r49 as source. | |||
|
66 | ||||
|
67 | * Mon Mar 9 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
68 | -Uses r48 as source. | |||
|
69 | ||||
|
70 | * Wed Feb 18 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
71 | -Uses r45 as source. | |||
|
72 | ||||
|
73 | * Tue Feb 10 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
74 | -Uses r44 as source. | |||
|
75 | ||||
|
76 | * Tue Dec 30 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
77 | - Uses r42 as source. | |||
|
78 | ||||
|
79 | * Sat Jun 28 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |||
|
80 | - Initial Fedora packaging |
@@ -0,0 +1,43 | |||||
|
1 | #include "incomingpacketparser.h" | |||
|
2 | ||||
|
3 | IncomingPacketParser::IncomingPacketParser(QObject *parent) : | |||
|
4 | QObject(parent) | |||
|
5 | { | |||
|
6 | incompleteData = false; | |||
|
7 | localDataArray.clear(); | |||
|
8 | } | |||
|
9 | ||||
|
10 | void IncomingPacketParser::processIncomingQByteArray(QByteArray incomingQByteArray) | |||
|
11 | { | |||
|
12 | int ccsdsSize; | |||
|
13 | bool keepParsing; | |||
|
14 | QByteArray tcPacket; | |||
|
15 | ||||
|
16 | keepParsing = true; | |||
|
17 | ||||
|
18 | localDataArray.append( incomingQByteArray ); | |||
|
19 | ||||
|
20 | if (localDataArray.size() >= 4 ) | |||
|
21 | { | |||
|
22 | while(keepParsing == true) | |||
|
23 | { | |||
|
24 | ccsdsSize = ( (unsigned char) localDataArray[1] ) * 256 * 256 | |||
|
25 | + ( (unsigned char) localDataArray[2] ) * 256 | |||
|
26 | + ( (unsigned char) localDataArray[3] ); | |||
|
27 | ||||
|
28 | if (localDataArray.size() < (ccsdsSize+4) ) keepParsing = false; | |||
|
29 | else | |||
|
30 | { | |||
|
31 | tcPacket = QByteArray( localDataArray ); | |||
|
32 | tcPacket.resize( ccsdsSize + 4 ); | |||
|
33 | ||||
|
34 | emit sendPacketUsingSpaceWire( tcPacket ); | |||
|
35 | ||||
|
36 | localDataArray.remove(0, ccsdsSize + 4); | |||
|
37 | } | |||
|
38 | ||||
|
39 | if (localDataArray.size() >= 4 ) keepParsing = true; | |||
|
40 | else keepParsing = false; | |||
|
41 | } | |||
|
42 | } | |||
|
43 | } |
@@ -0,0 +1,26 | |||||
|
1 | #ifndef INCOMINGTCPARSER_H | |||
|
2 | #define INCOMINGTCPARSER_H | |||
|
3 | ||||
|
4 | #include <QObject> | |||
|
5 | ||||
|
6 | class IncomingPacketParser : public QObject | |||
|
7 | { | |||
|
8 | Q_OBJECT | |||
|
9 | public: | |||
|
10 | explicit IncomingPacketParser(QObject *parent = 0); | |||
|
11 | ||||
|
12 | void processIncomingQByteArray(QByteArray incomingQByteArray); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | void sendMessage( QString ); | |||
|
16 | void sendPacketUsingSpaceWire( QByteArray packet ); | |||
|
17 | ||||
|
18 | public slots: | |||
|
19 | ||||
|
20 | private: | |||
|
21 | QByteArray localDataArray; | |||
|
22 | bool incompleteData; | |||
|
23 | ||||
|
24 | }; | |||
|
25 | ||||
|
26 | #endif // INCOMINGTCPARSER_H |
@@ -1,75 +1,68 | |||||
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 |
|
10 | VERSION=1.0.0 | ||
11 | #CONFIG(debug, debug|release) { |
|
|||
12 | # DEBUG_EXT = _d |
|
|||
13 | #} else { |
|
|||
14 | # DEBUG_EXT = |
|
|||
15 | #} |
|
|||
16 |
|
||||
17 | TARGET = ApbUartPlugin #$${DEBUG_EXT} |
|
11 | TARGET = ApbUartPlugin #$${DEBUG_EXT} | |
18 |
|
12 | |||
19 | DEFINES += PLUGIN=ApbUartPlugin |
|
13 | DEFINES += PLUGIN=ApbUartPlugin | |
20 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" |
|
14 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" | |
21 | DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\" |
|
15 | DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\" | |
22 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" |
|
16 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
23 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
|||
24 | 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."\\\"\" | |
25 | DEFINES += driver_can_be_root=0 |
|
18 | DEFINES += driver_can_be_root=0 | |
26 | DEFINES += driver_can_be_child=1 |
|
19 | DEFINES += driver_can_be_child=1 | |
27 | DEFINES += driver_VID=1 |
|
20 | DEFINES += driver_VID=1 | |
28 | DEFINES += driver_PID=0x0c |
|
21 | DEFINES += driver_PID=0x0c | |
29 |
|
22 | |||
30 |
|
23 | |||
31 |
|
24 | |||
32 | INCLUDEPATH += \ |
|
25 | INCLUDEPATH += \ | |
33 | $${PWD} |
|
26 | $${PWD} | |
34 |
|
27 | |||
35 | HEADERS += \ |
|
28 | HEADERS += \ | |
36 | APBUARTPLUGIN.h \ |
|
29 | APBUARTPLUGIN.h \ | |
37 | apbuartterminal.h \ |
|
30 | apbuartterminal.h \ | |
38 | apbuart_plugin_ui.h \ |
|
31 | apbuart_plugin_ui.h \ | |
39 | uartpollingthread.h \ |
|
32 | uartpollingthread.h \ | |
40 | apbuartpywrapper.h |
|
33 | apbuartpywrapper.h | |
41 |
|
34 | |||
42 |
|
35 | |||
43 | SOURCES += \ |
|
36 | SOURCES += \ | |
44 | APBUARTPLUGIN.cpp \ |
|
37 | APBUARTPLUGIN.cpp \ | |
45 | apbuartterminal.cpp \ |
|
38 | apbuartterminal.cpp \ | |
46 | apbuart_plugin_ui.cpp \ |
|
39 | apbuart_plugin_ui.cpp \ | |
47 | uartpollingthread.cpp \ |
|
40 | uartpollingthread.cpp \ | |
48 | apbuartpywrapper.cpp |
|
41 | apbuartpywrapper.cpp | |
49 |
|
42 | |||
50 | FORMS += \ |
|
43 | FORMS += \ | |
51 | apbuart_plugin_ui.ui |
|
44 | apbuart_plugin_ui.ui | |
52 |
|
45 | |||
53 |
|
46 | |||
54 |
|
47 | |||
55 |
|
48 | |||
56 |
|
49 | |||
57 |
|
50 | |||
58 |
|
51 | |||
59 |
|
52 | |||
60 |
|
53 | |||
61 |
|
54 | |||
62 |
|
55 | |||
63 |
|
56 | |||
64 |
|
57 | |||
65 |
|
58 | |||
66 |
|
59 | |||
67 |
|
60 | |||
68 |
|
61 | |||
69 |
|
62 | |||
70 |
|
63 | |||
71 |
|
64 | |||
72 |
|
65 | |||
73 |
|
66 | |||
74 |
|
67 | |||
75 |
|
68 |
@@ -1,14 +1,15 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | SUBDIRS = \ |
|
5 | SUBDIRS = \ | |
6 | ahbuartplugin \ |
|
6 | ahbuartplugin \ | |
7 | ambaplugin \ |
|
7 | ambaplugin \ | |
8 | APBUARTPLUGIN \ |
|
8 | APBUARTPLUGIN \ | |
9 | dsu3plugin \ |
|
9 | dsu3plugin \ | |
10 | genericrwplugin \ |
|
10 | genericrwplugin \ | |
11 | memctrlrplugin \ |
|
11 | memctrlrplugin \ | |
12 | memcheckplugin |
|
12 | memcheckplugin | |
13 |
|
13 | |||
|
14 | OTHER_FILES += SocExplorer-plugins.spec | |||
14 | #unix:SUBDIRS += spwplugin |
|
15 | #unix:SUBDIRS += spwplugin |
@@ -1,70 +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 | TEMPLATE = lib |
|
7 | TEMPLATE = lib | |
8 | CONFIG += dll |
|
8 | CONFIG += dll | |
9 | CONFIG -= static |
|
9 | CONFIG -= static | |
10 | #CONFIG(debug, debug|release) { |
|
10 | VERSION=1.4.0 | |
11 | # DEBUG_EXT = _d |
|
|||
12 | #} else { |
|
|||
13 | # DEBUG_EXT = |
|
|||
14 | #} |
|
|||
15 | TARGET = ahbuartplugin #$${DEBUG_EXT} |
|
11 | TARGET = ahbuartplugin #$${DEBUG_EXT} | |
16 | DEFINES += PLUGIN=ahbuartplugin |
|
12 | DEFINES += PLUGIN=ahbuartplugin | |
17 | DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\" |
|
13 | DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\" | |
18 | DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\" |
|
14 | DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\" | |
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
15 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
20 | DEFINES += driver_Version="\"\\\"1.3.2"\\\"\" |
|
|||
21 | DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\" |
|
16 | DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\" | |
22 | DEFINES += driver_can_be_root=1 |
|
17 | DEFINES += driver_can_be_root=1 | |
23 | DEFINES += driver_can_be_child=0 |
|
18 | DEFINES += driver_can_be_child=0 | |
24 | DEFINES += driver_VID=0 |
|
19 | DEFINES += driver_VID=0 | |
25 | DEFINES += driver_PID=0 |
|
20 | DEFINES += driver_PID=0 | |
26 |
|
21 | |||
27 |
|
22 | |||
28 |
|
23 | |||
29 |
|
24 | |||
30 | INCLUDEPATH += \ |
|
25 | INCLUDEPATH += \ | |
31 | $${PWD} |
|
26 | $${PWD} | |
32 |
|
27 | |||
33 |
|
28 | |||
34 | HEADERS += \ |
|
29 | HEADERS += \ | |
35 | ahbuartplugin.h \ |
|
30 | ahbuartplugin.h \ | |
36 | ahbuartpluginui.h \ |
|
31 | ahbuartpluginui.h \ | |
37 | ahbuartpywrapper.h \ |
|
32 | ahbuartpywrapper.h \ | |
38 | ahbuartpywrapper.h |
|
33 | ahbuartpywrapper.h | |
39 |
|
34 | |||
40 |
|
35 | |||
41 |
|
36 | |||
42 | SOURCES += \ |
|
37 | SOURCES += \ | |
43 | ahbuartplugin.cpp \ |
|
38 | ahbuartplugin.cpp \ | |
44 | ahbuartpluginui.cpp \ |
|
39 | ahbuartpluginui.cpp \ | |
45 | ahbuartpywrapper.cpp |
|
40 | ahbuartpywrapper.cpp | |
46 |
|
41 | |||
47 | FORMS += \ |
|
42 | FORMS += \ | |
48 | ahbuartpluginui.ui |
|
43 | ahbuartpluginui.ui | |
49 |
|
44 | |||
50 |
|
45 | |||
51 |
|
46 | |||
52 |
|
47 | |||
53 |
|
48 | |||
54 |
|
49 | |||
55 |
|
50 | |||
56 |
|
51 | |||
57 |
|
52 | |||
58 |
|
53 | |||
59 |
|
54 | |||
60 |
|
55 | |||
61 |
|
56 | |||
62 |
|
57 | |||
63 |
|
58 | |||
64 |
|
59 | |||
65 |
|
60 | |||
66 |
|
61 | |||
67 |
|
62 | |||
68 |
|
63 | |||
69 |
|
64 | |||
70 |
|
65 |
@@ -1,68 +1,63 | |||||
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 | #CONFIG(debug, debug|release) { |
|
9 | VERSION=0.2.0 | |
10 | # DEBUG_EXT = _d |
|
|||
11 | #} else { |
|
|||
12 | # DEBUG_EXT = |
|
|||
13 | #} |
|
|||
14 | TARGET = ambaplugin #$${DEBUG_EXT} |
|
10 | TARGET = ambaplugin #$${DEBUG_EXT} | |
15 | DEFINES += PLUGIN=ambaplugin |
|
11 | DEFINES += PLUGIN=ambaplugin | |
16 | DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\" |
|
12 | DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\" | |
17 | DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\" |
|
13 | DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\" | |
18 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
14 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
19 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
|||
20 | DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\" |
|
15 | DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\" | |
21 | DEFINES += driver_can_be_root=0 |
|
16 | DEFINES += driver_can_be_root=0 | |
22 | DEFINES += driver_can_be_child=1 |
|
17 | DEFINES += driver_can_be_child=1 | |
23 | DEFINES += driver_VID=0 |
|
18 | DEFINES += driver_VID=0 | |
24 | DEFINES += driver_PID=0 |
|
19 | DEFINES += driver_PID=0 | |
25 |
|
20 | |||
26 | INCLUDEPATH += \ |
|
21 | INCLUDEPATH += \ | |
27 | $${PWD} |
|
22 | $${PWD} | |
28 |
|
23 | |||
29 | HEADERS += \ |
|
24 | HEADERS += \ | |
30 | ambaplugin.h \ |
|
25 | ambaplugin.h \ | |
31 | AHB/ahbpluginui.h \ |
|
26 | AHB/ahbpluginui.h \ | |
32 | AHB/ahbdevicelist.h \ |
|
27 | AHB/ahbdevicelist.h \ | |
33 | APB/apbpluginui.h \ |
|
28 | APB/apbpluginui.h \ | |
34 | APB/apbdevicelist.h \ |
|
29 | APB/apbdevicelist.h \ | |
35 | ambapluginui.h |
|
30 | ambapluginui.h | |
36 |
|
31 | |||
37 |
|
32 | |||
38 | SOURCES += \ |
|
33 | SOURCES += \ | |
39 | ambaplugin.cpp \ |
|
34 | ambaplugin.cpp \ | |
40 | AHB/ahbpluginui.cpp \ |
|
35 | AHB/ahbpluginui.cpp \ | |
41 | AHB/ahbdevicelist.cpp \ |
|
36 | AHB/ahbdevicelist.cpp \ | |
42 | APB/apbpluginui.cpp \ |
|
37 | APB/apbpluginui.cpp \ | |
43 | APB/apbdevicelist.cpp \ |
|
38 | APB/apbdevicelist.cpp \ | |
44 | ambapluginui.cpp |
|
39 | ambapluginui.cpp | |
45 |
|
40 | |||
46 |
|
41 | |||
47 |
|
42 | |||
48 |
|
43 | |||
49 |
|
44 | |||
50 |
|
45 | |||
51 |
|
46 | |||
52 |
|
47 | |||
53 |
|
48 | |||
54 |
|
49 | |||
55 |
|
50 | |||
56 |
|
51 | |||
57 |
|
52 | |||
58 |
|
53 | |||
59 |
|
54 | |||
60 |
|
55 | |||
61 |
|
56 | |||
62 |
|
57 | |||
63 |
|
58 | |||
64 |
|
59 | |||
65 |
|
60 | |||
66 |
|
61 | |||
67 |
|
62 | |||
68 |
|
63 |
@@ -1,75 +1,68 | |||||
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 | #CONFIG(debug, debug|release) { |
|
|||
11 | # DEBUG_EXT = _d |
|
|||
12 | #} else { |
|
|||
13 | # DEBUG_EXT = |
|
|||
14 | #} |
|
|||
15 |
|
||||
16 | QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign |
|
10 | QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign | |
17 | QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign |
|
11 | QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign | |
18 |
|
12 | |||
19 |
|
13 | VERSION=0.2.0 | ||
20 | TARGET = dsu3plugin #$${DEBUG_EXT} |
|
14 | TARGET = dsu3plugin #$${DEBUG_EXT} | |
21 |
|
15 | |||
22 | DEFINES += PLUGIN=dsu3plugin |
|
16 | DEFINES += PLUGIN=dsu3plugin | |
23 | DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" |
|
17 | DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" | |
24 | DEFINES += driver_Name="\"\\\"dsu3plugin"\\\"\" |
|
18 | DEFINES += driver_Name="\"\\\"dsu3plugin"\\\"\" | |
25 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
26 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
|||
27 | DEFINES += driver_Description="\"\\\"DSU driver, works with GAISLER's DSU3 unit."\\\"\" |
|
20 | DEFINES += driver_Description="\"\\\"DSU driver, works with GAISLER's DSU3 unit."\\\"\" | |
28 | DEFINES += driver_can_be_root=0 |
|
21 | DEFINES += driver_can_be_root=0 | |
29 | DEFINES += driver_can_be_child=1 |
|
22 | DEFINES += driver_can_be_child=1 | |
30 | DEFINES += driver_VID=0x00 |
|
23 | DEFINES += driver_VID=0x00 | |
31 | DEFINES += driver_PID=0x00 |
|
24 | DEFINES += driver_PID=0x00 | |
32 |
|
25 | |||
33 |
|
26 | |||
34 | INCLUDEPATH += \ |
|
27 | INCLUDEPATH += \ | |
35 | $${PWD} |
|
28 | $${PWD} | |
36 |
|
29 | |||
37 |
|
30 | |||
38 |
|
31 | |||
39 | HEADERS += \ |
|
32 | HEADERS += \ | |
40 | dsu3plugin.h \ |
|
33 | dsu3plugin.h \ | |
41 | dsu3pluginui.h \ |
|
34 | dsu3pluginui.h \ | |
42 | dsu3pluginpywrapper.h |
|
35 | dsu3pluginpywrapper.h | |
43 |
|
36 | |||
44 | SOURCES += \ |
|
37 | SOURCES += \ | |
45 | dsu3plugin.cpp \ |
|
38 | dsu3plugin.cpp \ | |
46 | dsu3pluginui.cpp \ |
|
39 | dsu3pluginui.cpp \ | |
47 | dsu3pluginpywrapper.cpp |
|
40 | dsu3pluginpywrapper.cpp | |
48 |
|
41 | |||
49 |
|
42 | |||
50 |
|
43 | |||
51 |
|
44 | |||
52 |
|
45 | |||
53 |
|
46 | |||
54 |
|
47 | |||
55 |
|
48 | |||
56 |
|
49 | |||
57 |
|
50 | |||
58 |
|
51 | |||
59 |
|
52 | |||
60 |
|
53 | |||
61 |
|
54 | |||
62 |
|
55 | |||
63 |
|
56 | |||
64 |
|
57 | |||
65 |
|
58 | |||
66 |
|
59 | |||
67 |
|
60 | |||
68 |
|
61 | |||
69 |
|
62 | |||
70 |
|
63 | |||
71 |
|
64 | |||
72 |
|
65 | |||
73 |
|
66 | |||
74 |
|
67 | |||
75 |
|
68 |
@@ -1,53 +1,48 | |||||
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 | #CONFIG(debug, debug|release) { |
|
10 | VERSION=1.1.0 | |
11 | # DEBUG_EXT = _d |
|
11 | TARGET = genericrwplugin | |
12 | #} else { |
|
|||
13 | # DEBUG_EXT = |
|
|||
14 | #} |
|
|||
15 | TARGET = genericrwplugin #$${DEBUG_EXT} |
|
|||
16 | DEFINES += PLUGIN=genericrwplugin |
|
12 | DEFINES += PLUGIN=genericrwplugin | |
17 | DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\" |
|
13 | DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\" | |
18 | DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\" |
|
14 | DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\" | |
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
15 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
20 | DEFINES += driver_Version="\"\\\"1.1.0"\\\"\" |
|
|||
21 | DEFINES += driver_Description="\"\\\"Generic plugin, gives you R/W access to any memory area."\\\"\" |
|
16 | DEFINES += driver_Description="\"\\\"Generic plugin, gives you R/W access to any memory area."\\\"\" | |
22 | DEFINES += driver_can_be_root=0 |
|
17 | DEFINES += driver_can_be_root=0 | |
23 | DEFINES += driver_can_be_child=1 |
|
18 | DEFINES += driver_can_be_child=1 | |
24 | DEFINES += driver_VID=0 |
|
19 | DEFINES += driver_VID=0 | |
25 | DEFINES += driver_PID=0 |
|
20 | DEFINES += driver_PID=0 | |
26 |
|
21 | |||
27 |
|
22 | |||
28 | INCLUDEPATH += \ |
|
23 | INCLUDEPATH += \ | |
29 | $${PWD} |
|
24 | $${PWD} | |
30 |
|
25 | |||
31 | #LIBS +=-llppmoncommon$${DEBUG_EXT} |
|
26 | #LIBS +=-llppmoncommon$${DEBUG_EXT} | |
32 |
|
27 | |||
33 | HEADERS += \ |
|
28 | HEADERS += \ | |
34 | genericrwplugin.h \ |
|
29 | genericrwplugin.h \ | |
35 | genericrwpluginui.h \ |
|
30 | genericrwpluginui.h \ | |
36 | memeditor.h \ |
|
31 | memeditor.h \ | |
37 | genericrwpluginpywrapper.h |
|
32 | genericrwpluginpywrapper.h | |
38 |
|
33 | |||
39 | SOURCES += \ |
|
34 | SOURCES += \ | |
40 | genericrwplugin.cpp \ |
|
35 | genericrwplugin.cpp \ | |
41 | genericrwpluginui.cpp \ |
|
36 | genericrwpluginui.cpp \ | |
42 | memeditor.cpp \ |
|
37 | memeditor.cpp \ | |
43 | genericrwpluginpywrapper.cpp |
|
38 | genericrwpluginpywrapper.cpp | |
44 |
|
39 | |||
45 |
|
40 | |||
46 |
|
41 | |||
47 |
|
42 | |||
48 |
|
43 | |||
49 |
|
44 | |||
50 |
|
45 | |||
51 |
|
46 | |||
52 |
|
47 | |||
53 |
|
48 |
@@ -1,72 +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 | #CONFIG(debug, debug|release) { |
|
10 | VERSION=0.1.0 | |
11 | # DEBUG_EXT = _d |
|
11 | TARGET = memcheckplugin | |
12 | #} else { |
|
|||
13 | # DEBUG_EXT = |
|
|||
14 | #} |
|
|||
15 |
|
||||
16 |
|
||||
17 | TARGET = memcheckplugin #$${DEBUG_EXT} |
|
|||
18 | DEFINES += PLUGIN=memcheckplugin |
|
12 | DEFINES += PLUGIN=memcheckplugin | |
19 | DEFINES += PLUGINHEADER="\"\\\"memcheckplugin.h"\\\"\" |
|
13 | DEFINES += PLUGINHEADER="\"\\\"memcheckplugin.h"\\\"\" | |
20 | DEFINES += driver_Name="\"\\\"MemChecker"\\\"\" |
|
14 | DEFINES += driver_Name="\"\\\"MemChecker"\\\"\" | |
21 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
15 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
22 | DEFINES += driver_Version="\"\\\"1.0.1"\\\"\" |
|
|||
23 | 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."\\\"\" | |
24 | DEFINES += driver_can_be_root=0 |
|
17 | DEFINES += driver_can_be_root=0 | |
25 | DEFINES += driver_can_be_child=1 |
|
18 | DEFINES += driver_can_be_child=1 | |
26 | DEFINES += driver_VID=0x04 |
|
19 | DEFINES += driver_VID=0x04 | |
27 | DEFINES += driver_PID=0x0f |
|
20 | DEFINES += driver_PID=0x0f | |
28 |
|
21 | |||
29 | #LIBS +=-llppmoncommon |
|
22 | #LIBS +=-llppmoncommon | |
30 |
|
23 | |||
31 | INCLUDEPATH += \ |
|
24 | INCLUDEPATH += \ | |
32 | $${PWD} |
|
25 | $${PWD} | |
33 |
|
26 | |||
34 | HEADERS += \ |
|
27 | HEADERS += \ | |
35 | memcheckplugin.h \ |
|
28 | memcheckplugin.h \ | |
36 | memcheckplugin_ui.h \ |
|
29 | memcheckplugin_ui.h \ | |
37 | memchecker.h |
|
30 | memchecker.h | |
38 |
|
31 | |||
39 | SOURCES += \ |
|
32 | SOURCES += \ | |
40 | memcheckplugin.cpp \ |
|
33 | memcheckplugin.cpp \ | |
41 | memcheckplugin_ui.cpp \ |
|
34 | memcheckplugin_ui.cpp \ | |
42 | memchecker.cpp |
|
35 | memchecker.cpp | |
43 |
|
36 | |||
44 | FORMS += \ |
|
37 | FORMS += \ | |
45 | memcheckplugin_ui.ui |
|
38 | memcheckplugin_ui.ui | |
46 |
|
39 | |||
47 |
|
40 | |||
48 |
|
41 | |||
49 |
|
42 | |||
50 |
|
43 | |||
51 |
|
44 | |||
52 |
|
45 | |||
53 |
|
46 | |||
54 |
|
47 | |||
55 |
|
48 | |||
56 |
|
49 | |||
57 |
|
50 | |||
58 |
|
51 | |||
59 |
|
52 | |||
60 |
|
53 | |||
61 |
|
54 | |||
62 |
|
55 | |||
63 |
|
56 | |||
64 |
|
57 | |||
65 |
|
58 | |||
66 |
|
59 | |||
67 |
|
60 | |||
68 |
|
61 | |||
69 |
|
62 | |||
70 |
|
63 | |||
71 |
|
64 | |||
72 |
|
65 |
@@ -1,73 +1,67 | |||||
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 | #CONFIG(debug, debug|release) { |
|
10 | VERSION=1.0.1 | |
11 | # DEBUG_EXT = _d |
|
11 | TARGET = memctrlrplugin | |
12 | #} else { |
|
|||
13 | # DEBUG_EXT = |
|
|||
14 | #} |
|
|||
15 |
|
||||
16 | TARGET = memctrlrplugin #$${DEBUG_EXT} |
|
|||
17 | DEFINES += PLUGIN=memctrlrplugin |
|
12 | DEFINES += PLUGIN=memctrlrplugin | |
18 | DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" |
|
13 | DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" | |
19 | DEFINES += driver_Name="\"\\\"MemControler"\\\"\" |
|
14 | DEFINES += driver_Name="\"\\\"MemControler"\\\"\" | |
20 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" |
|
15 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" | |
21 | DEFINES += driver_Version="\"\\\"1.0.1"\\\"\" |
|
|||
22 | DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\" |
|
16 | DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\" | |
23 | DEFINES += driver_can_be_root=0 |
|
17 | DEFINES += driver_can_be_root=0 | |
24 | DEFINES += driver_can_be_child=1 |
|
18 | DEFINES += driver_can_be_child=1 | |
25 | DEFINES += driver_VID=0x04 |
|
19 | DEFINES += driver_VID=0x04 | |
26 | DEFINES += driver_PID=0x0f |
|
20 | DEFINES += driver_PID=0x0f | |
27 |
|
21 | |||
28 | #LIBS +=-llppmoncommon |
|
22 | #LIBS +=-llppmoncommon | |
29 |
|
23 | |||
30 | INCLUDEPATH += \ |
|
24 | INCLUDEPATH += \ | |
31 | $${PWD} |
|
25 | $${PWD} | |
32 |
|
26 | |||
33 | HEADERS += \ |
|
27 | HEADERS += \ | |
34 | memctrlrplugin.h \ |
|
28 | memctrlrplugin.h \ | |
35 | memctrlrpluginui.h \ |
|
29 | memctrlrpluginui.h \ | |
36 | memorycheck.h \ |
|
30 | memorycheck.h \ | |
37 | genericmemoryspacecheck.h \ |
|
31 | genericmemoryspacecheck.h \ | |
38 | memctrlrpywrapper.h |
|
32 | memctrlrpywrapper.h | |
39 |
|
33 | |||
40 | SOURCES += \ |
|
34 | SOURCES += \ | |
41 | memctrlrplugin.cpp \ |
|
35 | memctrlrplugin.cpp \ | |
42 | memctrlrpluginui.cpp \ |
|
36 | memctrlrpluginui.cpp \ | |
43 | memorycheck.cpp \ |
|
37 | memorycheck.cpp \ | |
44 | genericmemoryspacecheck.cpp \ |
|
38 | genericmemoryspacecheck.cpp \ | |
45 | memctrlrpywrapper.cpp |
|
39 | memctrlrpywrapper.cpp | |
46 |
|
40 | |||
47 |
|
41 | |||
48 |
|
42 | |||
49 |
|
43 | |||
50 |
|
44 | |||
51 |
|
45 | |||
52 |
|
46 | |||
53 |
|
47 | |||
54 |
|
48 | |||
55 |
|
49 | |||
56 |
|
50 | |||
57 |
|
51 | |||
58 |
|
52 | |||
59 |
|
53 | |||
60 |
|
54 | |||
61 |
|
55 | |||
62 |
|
56 | |||
63 |
|
57 | |||
64 |
|
58 | |||
65 |
|
59 | |||
66 |
|
60 | |||
67 |
|
61 | |||
68 |
|
62 | |||
69 |
|
63 | |||
70 |
|
64 | |||
71 |
|
65 | |||
72 |
|
66 | |||
73 |
|
67 |
@@ -1,231 +1,231 | |||||
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 | #include "spwtcppacketserver.h" |
|
22 | #include "spwtcppacketserver.h" | |
23 | #include "ui_spwtcppacketserver.h" |
|
23 | #include "ui_spwtcppacketserver.h" | |
24 | #include <QNetworkInterface> |
|
24 | #include <QNetworkInterface> | |
25 | #include <QByteArray> |
|
25 | #include <QByteArray> | |
26 |
|
26 | |||
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : |
|
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : | |
28 | QWidget(parent), |
|
28 | QWidget(parent), | |
29 | ui(new Ui::SpwTcpPacketServer) |
|
29 | ui(new Ui::SpwTcpPacketServer) | |
30 | { |
|
30 | { | |
31 | ui->setupUi(this); |
|
31 | ui->setupUi(this); | |
32 | this->p_bridge = NULL; |
|
32 | this->p_bridge = NULL; | |
33 | this->p_server = new QTcpServer(); |
|
33 | this->p_server = new QTcpServer(); | |
34 |
this->incoming |
|
34 | this->incomingPacketParser = new IncomingPacketParser(); | |
35 |
|
35 | |||
36 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); |
|
36 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); | |
37 | updateHostIP(); |
|
37 | updateHostIP(); | |
38 | this->ui->PortLineEdit->setText("2200"); |
|
38 | this->ui->PortLineEdit->setText("2200"); | |
39 | connect(this->p_server,SIGNAL(newConnection()),this,SLOT(newConnection())); |
|
39 | connect(this->p_server,SIGNAL(newConnection()),this,SLOT(newConnection())); | |
40 | resetStatististics(); |
|
40 | resetStatististics(); | |
41 |
|
41 | |||
42 |
connect( this->incoming |
|
42 | connect( this->incomingPacketParser, SIGNAL(sendPacketUsingSpaceWire(QByteArray)), | |
43 |
this, SLOT(send |
|
43 | this, SLOT(sendSPWPacketUsingSpaceWireaceWire(QByteArray))); | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | SpwTcpPacketServer::~SpwTcpPacketServer() |
|
46 | SpwTcpPacketServer::~SpwTcpPacketServer() | |
47 | { |
|
47 | { | |
48 | delete ui; |
|
48 | delete ui; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) |
|
51 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) | |
52 | { |
|
52 | { | |
53 | if(this->p_bridge!=NULL) |
|
53 | if(this->p_bridge!=NULL) | |
54 | { |
|
54 | { | |
55 | disconnect(this,SLOT(pushPacket(char*,int))); |
|
55 | disconnect(this,SLOT(pushPacket(char*,int))); | |
56 | } |
|
56 | } | |
57 | this->p_bridge = bridge; |
|
57 | this->p_bridge = bridge; | |
58 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); |
|
58 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void SpwTcpPacketServer::pushPacket(char *packet, int size) |
|
61 | void SpwTcpPacketServer::pushPacket(char *packet, int size) | |
62 | { |
|
62 | { | |
63 | QByteArray data; |
|
63 | QByteArray data; | |
64 | char sizech[3]; |
|
64 | char sizech[3]; | |
65 | data.append((char)0); |
|
65 | data.append((char)0); | |
66 | sizech[0]=size & 0x0FF; |
|
66 | sizech[0]=size & 0x0FF; | |
67 | sizech[1]=(size>>8) & 0x0FF; |
|
67 | sizech[1]=(size>>8) & 0x0FF; | |
68 | sizech[2]=(size>>16) & 0x0FF; |
|
68 | sizech[2]=(size>>16) & 0x0FF; | |
69 | data.append(sizech,3); |
|
69 | data.append(sizech,3); | |
70 | data.append(packet,size); |
|
70 | data.append(packet,size); | |
71 | for(int i=0;i<connectedClients.count();i++) |
|
71 | for(int i=0;i<connectedClients.count();i++) | |
72 | { |
|
72 | { | |
73 | QTcpSocket* soc=connectedClients.at(i); |
|
73 | QTcpSocket* soc=connectedClients.at(i); | |
74 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
74 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
75 | { |
|
75 | { | |
76 | connectedClients.removeAt(i); |
|
76 | connectedClients.removeAt(i); | |
77 | delete soc; |
|
77 | delete soc; | |
78 | } |
|
78 | } | |
79 | else |
|
79 | else | |
80 | { |
|
80 | { | |
81 | connectedClients.at(i)->write(data); |
|
81 | connectedClients.at(i)->write(data); | |
82 | onePacketTransmitted(); |
|
82 | onePacketTransmitted(); | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 | free(packet); |
|
85 | free(packet); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void SpwTcpPacketServer::toggleServer() |
|
88 | void SpwTcpPacketServer::toggleServer() | |
89 | { |
|
89 | { | |
90 | if(this->p_server->isListening()) |
|
90 | if(this->p_server->isListening()) | |
91 | { |
|
91 | { | |
92 | disconnectServer(); |
|
92 | disconnectServer(); | |
93 | } |
|
93 | } | |
94 | else |
|
94 | else | |
95 | { |
|
95 | { | |
96 | connectServer(); |
|
96 | connectServer(); | |
97 | } |
|
97 | } | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void SpwTcpPacketServer::connectServer() |
|
100 | void SpwTcpPacketServer::connectServer() | |
101 | { |
|
101 | { | |
102 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); |
|
102 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); | |
103 | this->ui->startServeQpb->setText("Stop Server"); |
|
103 | this->ui->startServeQpb->setText("Stop Server"); | |
104 | resetStatististics(); |
|
104 | resetStatististics(); | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | void SpwTcpPacketServer::disconnectServer() |
|
107 | void SpwTcpPacketServer::disconnectServer() | |
108 | { |
|
108 | { | |
109 | this->ui->startServeQpb->setText("Start Server"); |
|
109 | this->ui->startServeQpb->setText("Start Server"); | |
110 | this->p_server->close(); |
|
110 | this->p_server->close(); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | void SpwTcpPacketServer::setServerPort(qint32 port) |
|
113 | void SpwTcpPacketServer::setServerPort(qint32 port) | |
114 | { |
|
114 | { | |
115 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); |
|
115 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void SpwTcpPacketServer::setServerSetIP(QString ip) |
|
118 | void SpwTcpPacketServer::setServerSetIP(QString ip) | |
119 | { |
|
119 | { | |
120 | this->ui->IPLineEdit->setText(ip); |
|
120 | this->ui->IPLineEdit->setText(ip); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void SpwTcpPacketServer::newConnection() |
|
123 | void SpwTcpPacketServer::newConnection() | |
124 | { |
|
124 | { | |
125 | QTcpSocket* soc=this->p_server->nextPendingConnection(); |
|
125 | QTcpSocket* soc=this->p_server->nextPendingConnection(); | |
126 | this->connectedClients.append(soc); |
|
126 | this->connectedClients.append(soc); | |
127 | this->ui->listWidget->addItem(this->connectedClients.last()->peerAddress().toString()); |
|
127 | this->ui->listWidget->addItem(this->connectedClients.last()->peerAddress().toString()); | |
128 |
connect(soc,SIGNAL(readyRead()),this,SLOT(parseIncoming |
|
128 | connect(soc,SIGNAL(readyRead()),this,SLOT(parseIncomingPacket())); | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 |
void SpwTcpPacketServer::parseIncoming |
|
131 | void SpwTcpPacketServer::parseIncomingPacket() | |
132 | { |
|
132 | { | |
133 | for(int i=0;i<connectedClients.count();i++) |
|
133 | for(int i=0;i<connectedClients.count();i++) | |
134 | { |
|
134 | { | |
135 | QTcpSocket* soc=connectedClients.at(i); |
|
135 | QTcpSocket* soc=connectedClients.at(i); | |
136 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
136 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
137 | { |
|
137 | { | |
138 | connectedClients.removeAt(i); |
|
138 | connectedClients.removeAt(i); | |
139 | delete soc; |
|
139 | delete soc; | |
140 | } |
|
140 | } | |
141 | else |
|
141 | else | |
142 | { |
|
142 | { | |
143 | if(soc->bytesAvailable()!=0) |
|
143 | if(soc->bytesAvailable()!=0) | |
144 | { |
|
144 | { | |
145 | do |
|
145 | do | |
146 | { |
|
146 | { | |
147 | QByteArray data = soc->readAll(); |
|
147 | QByteArray data = soc->readAll(); | |
148 |
incoming |
|
148 | incomingPacketParser->processIncomingQByteArray( data ); | |
149 | }while(soc->bytesAvailable()!=0); |
|
149 | }while(soc->bytesAvailable()!=0); | |
150 | } |
|
150 | } | |
151 | } |
|
151 | } | |
152 | } |
|
152 | } | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 |
void SpwTcpPacketServer::send |
|
155 | void SpwTcpPacketServer::sendSPWPacketUsingSpaceWire(QByteArray data) | |
156 | { |
|
156 | { | |
157 | onePacketReceived(); |
|
157 | onePacketReceived(); | |
158 | if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission |
|
158 | if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission | |
159 | { |
|
159 | { | |
160 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; |
|
160 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; | |
161 | char* SPWpacket = (char*)malloc(size); |
|
161 | char* SPWpacket = (char*)malloc(size); | |
162 | memcpy(SPWpacket,data.data()+4,size); // 4 bytes will be added later to the packet |
|
162 | memcpy(SPWpacket,data.data()+4,size); // 4 bytes will be added later to the packet | |
163 | emit sendSPWPacket(SPWpacket,size); |
|
163 | emit sendSPWPacket(SPWpacket,size); | |
164 | } |
|
164 | } | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void SpwTcpPacketServer::readReady() |
|
167 | void SpwTcpPacketServer::readReady() | |
168 | { |
|
168 | { | |
169 | for(int i=0;i<connectedClients.count();i++) |
|
169 | for(int i=0;i<connectedClients.count();i++) | |
170 | { |
|
170 | { | |
171 | QTcpSocket* soc=connectedClients.at(i); |
|
171 | QTcpSocket* soc=connectedClients.at(i); | |
172 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
172 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
173 | { |
|
173 | { | |
174 | connectedClients.removeAt(i); |
|
174 | connectedClients.removeAt(i); | |
175 | delete soc; |
|
175 | delete soc; | |
176 | } |
|
176 | } | |
177 | else |
|
177 | else | |
178 | { |
|
178 | { | |
179 | if(soc->bytesAvailable()!=0) |
|
179 | if(soc->bytesAvailable()!=0) | |
180 | { |
|
180 | { | |
181 | do |
|
181 | do | |
182 | { |
|
182 | { | |
183 | QByteArray data = soc->readAll(); |
|
183 | QByteArray data = soc->readAll(); | |
184 | onePacketReceived(); |
|
184 | onePacketReceived(); | |
185 | if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission |
|
185 | if(data[0]==(char)0) // Protocole = 0 => Host to SpaceWire packet transmission | |
186 | { |
|
186 | { | |
187 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; |
|
187 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; | |
188 | char* SPWpacket = (char*)malloc(size); |
|
188 | char* SPWpacket = (char*)malloc(size); | |
189 | memcpy(SPWpacket,data.data()+4,size); // 4 bytes will be added later to the packet |
|
189 | memcpy(SPWpacket,data.data()+4,size); // 4 bytes will be added later to the packet | |
190 | emit sendSPWPacket(SPWpacket,size); |
|
190 | emit sendSPWPacket(SPWpacket,size); | |
191 | } |
|
191 | } | |
192 | }while(soc->bytesAvailable()!=0); |
|
192 | }while(soc->bytesAvailable()!=0); | |
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 | } |
|
195 | } | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | void SpwTcpPacketServer::resetStatististics() |
|
198 | void SpwTcpPacketServer::resetStatististics() | |
199 | { |
|
199 | { | |
200 | receivedPackets = 0; |
|
200 | receivedPackets = 0; | |
201 | transmittedPackets = 0; |
|
201 | transmittedPackets = 0; | |
202 |
|
202 | |||
203 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); |
|
203 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); | |
204 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); |
|
204 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void SpwTcpPacketServer::updateHostIP() |
|
207 | void SpwTcpPacketServer::updateHostIP() | |
208 | { |
|
208 | { | |
209 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); |
|
209 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); | |
210 |
|
210 | |||
211 | for(int nIter=0; nIter<list.count(); nIter++) |
|
211 | for(int nIter=0; nIter<list.count(); nIter++) | |
212 | { |
|
212 | { | |
213 | if(!list[nIter].isLoopback()) |
|
213 | if(!list[nIter].isLoopback()) | |
214 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) |
|
214 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) | |
215 | this->ui->IPLineEdit->setText(list[nIter].toString()); |
|
215 | this->ui->IPLineEdit->setText(list[nIter].toString()); | |
216 | } |
|
216 | } | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | void SpwTcpPacketServer::onePacketReceived() |
|
219 | void SpwTcpPacketServer::onePacketReceived() | |
220 | { |
|
220 | { | |
221 | receivedPackets = receivedPackets + 1; |
|
221 | receivedPackets = receivedPackets + 1; | |
222 |
|
222 | |||
223 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); |
|
223 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); | |
224 | } |
|
224 | } | |
225 |
|
225 | |||
226 | void SpwTcpPacketServer::onePacketTransmitted() |
|
226 | void SpwTcpPacketServer::onePacketTransmitted() | |
227 | { |
|
227 | { | |
228 | transmittedPackets = transmittedPackets + 1; |
|
228 | transmittedPackets = transmittedPackets + 1; | |
229 |
|
229 | |||
230 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); |
|
230 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); | |
231 | } |
|
231 | } |
@@ -1,72 +1,72 | |||||
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 SPWTCPPACKETSERVER_H |
|
22 | #ifndef SPWTCPPACKETSERVER_H | |
23 | #define SPWTCPPACKETSERVER_H |
|
23 | #define SPWTCPPACKETSERVER_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <abstractspwbridge.h> |
|
26 | #include <abstractspwbridge.h> | |
27 | #include <QTcpServer> |
|
27 | #include <QTcpServer> | |
28 | #include <QList> |
|
28 | #include <QList> | |
29 | #include <QTcpSocket> |
|
29 | #include <QTcpSocket> | |
30 |
#include <incoming |
|
30 | #include <incomingpacketparser.h> | |
31 |
|
31 | |||
32 | namespace Ui { |
|
32 | namespace Ui { | |
33 | class SpwTcpPacketServer; |
|
33 | class SpwTcpPacketServer; | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | class SpwTcpPacketServer : public QWidget |
|
36 | class SpwTcpPacketServer : public QWidget | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | explicit SpwTcpPacketServer(QWidget *parent = 0); |
|
41 | explicit SpwTcpPacketServer(QWidget *parent = 0); | |
42 | ~SpwTcpPacketServer(); |
|
42 | ~SpwTcpPacketServer(); | |
43 |
|
43 | |||
44 | void setBridge(abstractSpwBridge* bridge); |
|
44 | void setBridge(abstractSpwBridge* bridge); | |
45 | signals: |
|
45 | signals: | |
46 | void sendSPWPacket(char* packet,int size); |
|
46 | void sendSPWPacket(char* packet,int size); | |
47 | public slots: |
|
47 | public slots: | |
48 | void pushPacket(char* packet,int size); |
|
48 | void pushPacket(char* packet,int size); | |
49 | void toggleServer(); |
|
49 | void toggleServer(); | |
50 | void connectServer(); |
|
50 | void connectServer(); | |
51 | void disconnectServer(); |
|
51 | void disconnectServer(); | |
52 | void setServerPort(qint32 port); |
|
52 | void setServerPort(qint32 port); | |
53 | void setServerSetIP(QString ip); |
|
53 | void setServerSetIP(QString ip); | |
54 | void newConnection(); |
|
54 | void newConnection(); | |
55 |
void parseIncoming |
|
55 | void parseIncomingPacket(); | |
56 |
void send |
|
56 | void sendSPWPacketUsingSpaceWire(QByteArray data ); | |
57 | void readReady(); |
|
57 | void readReady(); | |
58 | void resetStatististics(); |
|
58 | void resetStatististics(); | |
59 | private: |
|
59 | private: | |
60 | void updateHostIP(); |
|
60 | void updateHostIP(); | |
61 | void onePacketReceived(); |
|
61 | void onePacketReceived(); | |
62 | void onePacketTransmitted(); |
|
62 | void onePacketTransmitted(); | |
63 | Ui::SpwTcpPacketServer *ui; |
|
63 | Ui::SpwTcpPacketServer *ui; | |
64 | abstractSpwBridge* p_bridge; |
|
64 | abstractSpwBridge* p_bridge; | |
65 | QTcpServer* p_server; |
|
65 | QTcpServer* p_server; | |
66 | QList<QTcpSocket*> connectedClients; |
|
66 | QList<QTcpSocket*> connectedClients; | |
67 | unsigned int receivedPackets; |
|
67 | unsigned int receivedPackets; | |
68 | unsigned int transmittedPackets; |
|
68 | unsigned int transmittedPackets; | |
69 |
Incoming |
|
69 | IncomingPacketParser *incomingPacketParser; | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | #endif // SPWTCPPACKETSERVER_H |
|
72 | #endif // SPWTCPPACKETSERVER_H |
@@ -1,1103 +1,1102 | |||||
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 "stardundeespw_usb.h" |
|
23 | #include "stardundeespw_usb.h" | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 | #include <qhexedit.h> |
|
25 | #include <qhexedit.h> | |
26 |
|
26 | |||
27 | QString dwLinkStatusQString[6] = { |
|
27 | QString dwLinkStatusQString[6] = { | |
28 | "CFG_SPACEWIRE_ERROR_RESET", |
|
28 | "CFG_SPACEWIRE_ERROR_RESET", | |
29 | "CFG_SPACEWIRE_ERROR_WAIT", |
|
29 | "CFG_SPACEWIRE_ERROR_WAIT", | |
30 | "CFG_SPACEWIRE_READY", |
|
30 | "CFG_SPACEWIRE_READY", | |
31 | "CFG_SPACEWIRE_STARTED", |
|
31 | "CFG_SPACEWIRE_STARTED", | |
32 | "CFG_SPACEWIRE_CONNECTING", |
|
32 | "CFG_SPACEWIRE_CONNECTING", | |
33 | "CFG_SPACEWIRE_RUN" |
|
33 | "CFG_SPACEWIRE_RUN" | |
34 | }; |
|
34 | }; | |
35 |
|
35 | |||
36 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
36 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
37 | abstractSpwBridge(parent) |
|
37 | abstractSpwBridge(parent) | |
38 | { |
|
38 | { | |
39 | Q_UNUSED(parent) |
|
39 | Q_UNUSED(parent) | |
40 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
40 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
41 | makeGUI(parent); |
|
41 | makeGUI(parent); | |
42 | this->manager->start(); |
|
42 | this->manager->start(); | |
43 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); |
|
43 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); | |
44 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); |
|
44 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); | |
45 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); |
|
45 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); | |
46 | connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw())); |
|
46 | connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw())); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
49 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
50 | { |
|
50 | { | |
51 | this->manager->requestInterruption(); |
|
51 | this->manager->requestInterruption(); | |
52 | while(this->manager->isRunning()); |
|
52 | while(this->manager->isRunning()); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
55 | void stardundeeSPW_USB::toggleBridgeConnection() | |
56 | { |
|
56 | { | |
57 | if(this->plugin->isConnected()) |
|
57 | if(this->plugin->isConnected()) | |
58 | { |
|
58 | { | |
59 | this->disconnectBridge(); |
|
59 | this->disconnectBridge(); | |
60 | } |
|
60 | } | |
61 | else |
|
61 | else | |
62 | { |
|
62 | { | |
63 | this->connectBridge(); |
|
63 | this->connectBridge(); | |
64 | } |
|
64 | } | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | bool stardundeeSPW_USB::connectBridge() |
|
67 | bool stardundeeSPW_USB::connectBridge() | |
68 | { |
|
68 | { | |
69 | if(this->manager->connectBridge()) |
|
69 | if(this->manager->connectBridge()) | |
70 | { |
|
70 | { | |
71 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); |
|
71 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); | |
72 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); |
|
72 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); | |
73 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
73 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
74 | emit setConnected(true); |
|
74 | emit setConnected(true); | |
75 | return true; |
|
75 | return true; | |
76 | } |
|
76 | } | |
77 | return false; |
|
77 | return false; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | bool stardundeeSPW_USB::disconnectBridge() |
|
80 | bool stardundeeSPW_USB::disconnectBridge() | |
81 | { |
|
81 | { | |
82 | if(this->manager->disconnectBridge()) |
|
82 | if(this->manager->disconnectBridge()) | |
83 | { |
|
83 | { | |
84 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
84 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
85 | emit setConnected(false); |
|
85 | emit setConnected(false); | |
86 | return true; |
|
86 | return true; | |
87 | } |
|
87 | } | |
88 | return false; |
|
88 | return false; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
91 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
92 | { |
|
92 | { | |
93 | return this->manager->sendPacket(packet,size); |
|
93 | return this->manager->sendPacket(packet,size); | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
96 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
97 | { |
|
97 | { | |
98 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
98 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; | |
99 | char *RMAPAckBuff; |
|
99 | char *RMAPAckBuff; | |
100 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
100 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
101 | int transactionID = 0; |
|
101 | int transactionID = 0; | |
102 | int written=0; |
|
102 | int written=0; | |
103 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
103 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
104 | QProgressBar* progress=NULL; |
|
104 | QProgressBar* progress=NULL; | |
105 | SocExplorerAutoProgressBar autopb; |
|
105 | SocExplorerAutoProgressBar autopb; | |
106 | if(count>RMAP_MAX_XFER_SIZE) |
|
106 | if(count>RMAP_MAX_XFER_SIZE) | |
107 | { |
|
107 | { | |
108 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
108 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
109 | autopb.setProgressBar(progress); |
|
109 | autopb.setProgressBar(progress); | |
110 | } |
|
110 | } | |
111 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
111 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
112 | while(count>=RMAP_MAX_XFER_SIZE) |
|
112 | while(count>=RMAP_MAX_XFER_SIZE) | |
113 | { |
|
113 | { | |
114 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
114 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
115 | { |
|
115 | { | |
116 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
116 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
118 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
118 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
119 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
119 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
120 | } |
|
120 | } | |
121 | transactionID=manager->getRMAPtransactionID(); |
|
121 | transactionID=manager->getRMAPtransactionID(); | |
122 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
122 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
123 | RMAP_build_tx_request_header( |
|
123 | RMAP_build_tx_request_header( | |
124 | this->manager->destinationLogicalAddress, |
|
124 | this->manager->destinationLogicalAddress, | |
125 | this->manager->destinationKey, |
|
125 | this->manager->destinationKey, | |
126 | this->manager->sourceLogicalAddress, |
|
126 | this->manager->sourceLogicalAddress, | |
127 | transactionID, |
|
127 | transactionID, | |
128 | address+(written*4), |
|
128 | address+(written*4), | |
129 | RMAP_MAX_XFER_SIZE*4, |
|
129 | RMAP_MAX_XFER_SIZE*4, | |
130 | writeBuffer+1); |
|
130 | writeBuffer+1); | |
131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
133 | free(RMAPAckBuff); |
|
133 | free(RMAPAckBuff); | |
134 | written+=RMAP_MAX_XFER_SIZE; |
|
134 | written+=RMAP_MAX_XFER_SIZE; | |
135 | count-=RMAP_MAX_XFER_SIZE; |
|
135 | count-=RMAP_MAX_XFER_SIZE; | |
136 | progress->setValue(written); |
|
136 | progress->setValue(written); | |
137 | qApp->processEvents(); |
|
137 | qApp->processEvents(); | |
138 | } |
|
138 | } | |
139 | if(count>0) |
|
139 | if(count>0) | |
140 | { |
|
140 | { | |
141 | for(int i=0;i<((int)count);i++) |
|
141 | for(int i=0;i<((int)count);i++) | |
142 | { |
|
142 | { | |
143 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
143 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
145 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
145 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
146 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
146 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
147 | } |
|
147 | } | |
148 | transactionID=manager->getRMAPtransactionID(); |
|
148 | transactionID=manager->getRMAPtransactionID(); | |
149 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
149 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
150 | RMAP_build_tx_request_header( |
|
150 | RMAP_build_tx_request_header( | |
151 | this->manager->destinationLogicalAddress, |
|
151 | this->manager->destinationLogicalAddress, | |
152 | this->manager->destinationKey, |
|
152 | this->manager->destinationKey, | |
153 | this->manager->sourceLogicalAddress, |
|
153 | this->manager->sourceLogicalAddress, | |
154 | transactionID, |
|
154 | transactionID, | |
155 | address+(written*4), |
|
155 | address+(written*4), | |
156 | count*4, |
|
156 | count*4, | |
157 | writeBuffer+1); |
|
157 | writeBuffer+1); | |
158 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
158 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
159 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
159 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
160 | free(RMAPAckBuff); |
|
160 | free(RMAPAckBuff); | |
161 | written+=count; |
|
161 | written+=count; | |
162 | if(progress!=NULL) |
|
162 | if(progress!=NULL) | |
163 | { |
|
163 | { | |
164 | progress->setValue(written); |
|
164 | progress->setValue(written); | |
165 | qApp->processEvents(); |
|
165 | qApp->processEvents(); | |
166 | } |
|
166 | } | |
167 | } |
|
167 | } | |
168 | return written; |
|
168 | return written; | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
171 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
172 | { |
|
172 | { | |
173 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
173 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
174 | char* RMAP_AnswerBuffer; |
|
174 | char* RMAP_AnswerBuffer; | |
175 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
175 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
176 | int transactionID = 0; |
|
176 | int transactionID = 0; | |
177 | int read=0; |
|
177 | int read=0; | |
178 | QProgressBar* progress=NULL; |
|
178 | QProgressBar* progress=NULL; | |
179 | SocExplorerAutoProgressBar autopb; |
|
179 | SocExplorerAutoProgressBar autopb; | |
180 | if(count>RMAP_MAX_XFER_SIZE) |
|
180 | if(count>RMAP_MAX_XFER_SIZE) | |
181 | { |
|
181 | { | |
182 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
182 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
183 | autopb.setProgressBar(progress); |
|
183 | autopb.setProgressBar(progress); | |
184 | } |
|
184 | } | |
185 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
185 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); | |
186 |
|
186 | |||
187 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
187 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
188 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
188 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
189 | { |
|
189 | { | |
190 | transactionID = manager->getRMAPtransactionID(); |
|
190 | transactionID = manager->getRMAPtransactionID(); | |
191 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
191 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
192 | RMAP_build_rx_request_header( |
|
192 | RMAP_build_rx_request_header( | |
193 | this->manager->destinationLogicalAddress, |
|
193 | this->manager->destinationLogicalAddress, | |
194 | this->manager->destinationKey, |
|
194 | this->manager->destinationKey, | |
195 | this->manager->sourceLogicalAddress, |
|
195 | this->manager->sourceLogicalAddress, | |
196 | transactionID, |
|
196 | transactionID, | |
197 | address+(read*4), |
|
197 | address+(read*4), | |
198 | RMAP_MAX_XFER_SIZE*4, |
|
198 | RMAP_MAX_XFER_SIZE*4, | |
199 | requestBuffer+1); |
|
199 | requestBuffer+1); | |
200 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
200 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
201 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
201 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
202 | if(len==-1) |
|
202 | if(len==-1) | |
203 | { |
|
203 | { | |
204 | this->toggleBridgeConnection(); |
|
204 | this->toggleBridgeConnection(); | |
205 | return 0; |
|
205 | return 0; | |
206 | } |
|
206 | } | |
207 | for(int i=0;i<((len-13)/4);i++) |
|
207 | for(int i=0;i<((len-13)/4);i++) | |
208 | { |
|
208 | { | |
209 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
209 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
210 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
210 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
211 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
211 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
212 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
212 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
213 | } |
|
213 | } | |
214 | free(RMAP_AnswerBuffer); |
|
214 | free(RMAP_AnswerBuffer); | |
215 | read+=RMAP_MAX_XFER_SIZE; |
|
215 | read+=RMAP_MAX_XFER_SIZE; | |
216 | count-=RMAP_MAX_XFER_SIZE; |
|
216 | count-=RMAP_MAX_XFER_SIZE; | |
217 | progress->setValue(read); |
|
217 | progress->setValue(read); | |
218 | qApp->processEvents(); |
|
218 | qApp->processEvents(); | |
219 | } |
|
219 | } | |
220 | if((int)count>0) |
|
220 | if((int)count>0) | |
221 | { |
|
221 | { | |
222 | transactionID = manager->getRMAPtransactionID(); |
|
222 | transactionID = manager->getRMAPtransactionID(); | |
223 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
223 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
224 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
224 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
225 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
225 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
226 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
226 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
227 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
227 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
228 | RMAP_build_rx_request_header( |
|
228 | RMAP_build_rx_request_header( | |
229 | this->manager->destinationLogicalAddress, |
|
229 | this->manager->destinationLogicalAddress, | |
230 | this->manager->destinationKey, |
|
230 | this->manager->destinationKey, | |
231 | this->manager->sourceLogicalAddress, |
|
231 | this->manager->sourceLogicalAddress, | |
232 | transactionID, |
|
232 | transactionID, | |
233 | address+(read*4), |
|
233 | address+(read*4), | |
234 | count*4, |
|
234 | count*4, | |
235 | requestBuffer+1); |
|
235 | requestBuffer+1); | |
236 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
236 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
237 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
237 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
238 | if(len==-1) |
|
238 | if(len==-1) | |
239 | { |
|
239 | { | |
240 | this->toggleBridgeConnection(); |
|
240 | this->toggleBridgeConnection(); | |
241 | return 0; |
|
241 | return 0; | |
242 | } |
|
242 | } | |
243 | for(int i=0;i<((len-13)/4);i++) |
|
243 | for(int i=0;i<((len-13)/4);i++) | |
244 | { |
|
244 | { | |
245 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
245 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
246 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
246 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
247 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
247 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
248 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
248 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
249 | } |
|
249 | } | |
250 | free(RMAP_AnswerBuffer); |
|
250 | free(RMAP_AnswerBuffer); | |
251 | read+=count; |
|
251 | read+=count; | |
252 | if(progress!=NULL) |
|
252 | if(progress!=NULL) | |
253 | { |
|
253 | { | |
254 | progress->setValue(read); |
|
254 | progress->setValue(read); | |
255 | qApp->processEvents(); |
|
255 | qApp->processEvents(); | |
256 | } |
|
256 | } | |
257 | } |
|
257 | } | |
258 | return read; |
|
258 | return read; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
261 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
262 | { |
|
262 | { | |
263 | this->manager->selectedBrick = brickIndex-1; |
|
263 | this->manager->selectedBrick = brickIndex-1; | |
264 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
264 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
267 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
268 | { |
|
268 | { | |
269 | this->manager->linkNumber = linkIndex + 1; |
|
269 | this->manager->linkNumber = linkIndex + 1; | |
270 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
270 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
273 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
274 | { |
|
274 | { | |
275 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
275 | this->manager->linkSpeed = linkSpeed.toInt(); | |
276 |
|
276 | |||
277 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
277 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) |
|
280 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) | |
281 | { |
|
281 | { | |
282 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); |
|
282 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); | |
283 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); |
|
283 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) |
|
286 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) | |
287 | { |
|
287 | { | |
288 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); |
|
288 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); | |
289 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); |
|
289 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) |
|
292 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) | |
293 | { |
|
293 | { | |
294 | this->manager->destinationKey = key.toInt(); |
|
294 | this->manager->destinationKey = key.toInt(); | |
295 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); |
|
295 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) |
|
298 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) | |
299 | { |
|
299 | { | |
300 | this->manager->interfaceMode = interfaceMode; |
|
300 | this->manager->interfaceMode = interfaceMode; | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) |
|
303 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) | |
304 | { |
|
304 | { | |
305 | this->manager->timecodeFrequency = frequency.toDouble(); |
|
305 | this->manager->timecodeFrequency = frequency.toDouble(); | |
306 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); |
|
306 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); | |
307 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); |
|
307 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) |
|
310 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) | |
311 | { |
|
311 | { | |
312 | this->manager->sendTimecodePeriodically( onOff ); |
|
312 | this->manager->sendTimecodePeriodically( onOff ); | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
315 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) | |
316 | { |
|
316 | { | |
317 | int tim=timeout.toInt(); |
|
317 | int tim=timeout.toInt(); | |
318 | if(tim<50) |
|
318 | if(tim<50) | |
319 | { |
|
319 | { | |
320 | tim = 50; |
|
320 | tim = 50; | |
321 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
321 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); | |
322 | } |
|
322 | } | |
323 | this->manager->RMAPtimeout = tim; |
|
323 | this->manager->RMAPtimeout = tim; | |
324 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
324 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); | |
325 | } |
|
325 | } | |
326 |
|
326 | |||
327 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
327 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
328 | { |
|
328 | { | |
329 | Q_UNUSED(parent) |
|
329 | Q_UNUSED(parent) | |
330 | this->p_GUI = new StarDundeeGUI(); |
|
330 | this->p_GUI = new StarDundeeGUI(); | |
331 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
331 | // this->mainLayout = new QGridLayout(this->p_GUI); | |
332 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
332 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
333 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
333 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
334 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
334 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); |
|
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); | |
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); |
|
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); | |
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); | |
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); |
|
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); | |
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); |
|
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); | |
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); |
|
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); | |
344 |
|
344 | |||
345 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
345 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
346 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
346 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
347 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
347 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
348 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); |
|
348 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); | |
349 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); |
|
349 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); | |
350 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); |
|
350 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
351 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); |
|
351 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
352 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); |
|
352 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |
353 |
|
353 | |||
354 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
354 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
355 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
355 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
356 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); |
|
356 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
357 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); |
|
357 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
358 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); |
|
358 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); | |
359 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); |
|
359 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); | |
360 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); |
|
360 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
361 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); |
|
361 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |
362 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); |
|
362 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); | |
363 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), |
|
363 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), | |
364 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); |
|
364 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); | |
365 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); |
|
365 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |
366 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); |
|
366 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |
367 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); |
|
367 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |
368 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); |
|
368 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |
369 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); |
|
369 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); | |
370 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); |
|
370 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); | |
371 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); |
|
371 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); | |
372 |
|
372 | |||
373 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); |
|
373 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); | |
374 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); |
|
374 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) |
|
377 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) | |
378 | { |
|
378 | { | |
379 | char* data; |
|
379 | char* data; | |
380 | int i; |
|
380 | int i; | |
381 |
|
381 | |||
382 | data = (char *) malloc( size + 5 ); |
|
382 | data = (char *) malloc( size + 5 ); | |
383 |
|
383 | |||
384 | data[0] = this->manager->linkNumber; |
|
384 | data[0] = this->manager->linkNumber; | |
385 | data[1] = this->manager->destinationLogicalAddress; // target logical address |
|
385 | data[1] = this->manager->destinationLogicalAddress; // target logical address | |
386 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier |
|
386 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier | |
387 | data[3] = 0x00; // reserved |
|
387 | data[3] = 0x00; // reserved | |
388 | data[4] = 0x00; // user application |
|
388 | data[4] = 0x00; // user application | |
389 |
|
389 | |||
390 | for ( i=0; i<size; i++ ) |
|
390 | for ( i=0; i<size; i++ ) | |
391 | { |
|
391 | { | |
392 | data[i+5] = packet[i]; |
|
392 | data[i+5] = packet[i]; | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | this->manager->sendPacket( data, size + 5); |
|
395 | this->manager->sendPacket( data, size + 5); | |
396 |
|
396 | |||
397 | free(data); |
|
397 | free(data); | |
398 | free(packet); |
|
398 | free(packet); | |
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
401 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
402 | :QThread((QObject*)parent) |
|
402 | :QThread((QObject*)parent) | |
403 | { |
|
403 | { | |
404 | this->RMAPtimeout = 2000; |
|
404 | this->RMAPtimeout = 2000; | |
405 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
405 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
406 | // this->handleMutex = new QMutex(QMutex::Recursive); |
|
406 | // this->handleMutex = new QMutex(QMutex::Recursive); | |
407 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
407 | this->RMAP_AnswersSem = new QSemaphore(0); | |
408 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
408 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
409 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
409 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
410 | this->plugin = plugin; |
|
410 | this->plugin = plugin; | |
411 | connected = false; |
|
411 | connected = false; | |
412 | // TODO remove this crap! |
|
412 | // TODO remove this crap! | |
413 | this->initDialog(); |
|
413 | this->initDialog(); | |
414 | // this->moveToThread(this); |
|
414 | // this->moveToThread(this); | |
415 | } |
|
415 | } | |
416 |
|
416 | |||
417 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
417 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
418 | { |
|
418 | { | |
419 | this->terminate(); |
|
419 | this->terminate(); | |
420 | while (!this->isFinished()) { |
|
420 | while (!this->isFinished()) { | |
421 | this->usleep(1000); |
|
421 | this->usleep(1000); | |
422 | } |
|
422 | } | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | void stardundeeSPW_USB_Manager::run() |
|
425 | void stardundeeSPW_USB_Manager::run() | |
426 | { |
|
426 | { | |
427 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
427 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
428 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
428 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
429 | USB_SPACEWIRE_STATUS stat; |
|
429 | USB_SPACEWIRE_STATUS stat; | |
430 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
430 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
431 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
431 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
432 | while (!this->isInterruptionRequested()) |
|
432 | while (!this->isInterruptionRequested()) | |
433 | { |
|
433 | { | |
434 | if(this->connected) |
|
434 | if(this->connected) | |
435 | { |
|
435 | { | |
436 | this->handleMutex->lock(); |
|
436 | this->handleMutex->lock(); | |
437 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
437 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
438 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
438 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
439 | { |
|
439 | { | |
440 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
440 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
441 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
441 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
442 | if (stat == TRANSFER_SUCCESS) |
|
442 | if (stat == TRANSFER_SUCCESS) | |
443 | { |
|
443 | { | |
444 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
444 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
445 | { |
|
445 | { | |
446 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
446 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
447 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
447 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
448 | { |
|
448 | { | |
449 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
449 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); | |
450 | emit bytesReceivedFromSpw( properties.len ); |
|
450 | emit bytesReceivedFromSpw( properties.len ); | |
451 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
451 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
452 | { |
|
452 | { | |
453 | RMAP_Answer* packet; |
|
453 | RMAP_Answer* packet; | |
454 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
454 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
455 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
455 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
456 | char* packetbuffer = (char*)malloc(properties.len); |
|
456 | char* packetbuffer = (char*)malloc(properties.len); | |
457 | memcpy(packetbuffer,buffer,properties.len); |
|
457 | memcpy(packetbuffer,buffer,properties.len); | |
458 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
458 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
459 | pIdentifier = NULL; |
|
459 | pIdentifier = NULL; | |
460 | this->handleMutex->unlock(); |
|
460 | this->handleMutex->unlock(); | |
461 | if(properties.len==8) |
|
461 | if(properties.len==8) | |
462 | { |
|
462 | { | |
463 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
463 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); | |
464 | } |
|
464 | } | |
465 | else |
|
465 | else | |
466 | { |
|
466 | { | |
467 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
467 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
468 | } |
|
468 | } | |
469 | RMAP_AnswersMtx->lock(); |
|
469 | RMAP_AnswersMtx->lock(); | |
470 | RMAP_Answers.append(packet); |
|
470 | RMAP_Answers.append(packet); | |
471 | RMAP_AnswersMtx->unlock(); |
|
471 | RMAP_AnswersMtx->unlock(); | |
472 | RMAP_AnswersSem->release(); |
|
472 | RMAP_AnswersSem->release(); | |
473 | } |
|
473 | } | |
474 | else //any non-rmap packet will be pushed to the network |
|
474 | else //any non-rmap packet will be pushed to the network | |
475 | { |
|
475 | { | |
476 | char* packetbuffer = (char*)malloc(properties.len); |
|
476 | char* packetbuffer = (char*)malloc(properties.len); | |
477 | memcpy(packetbuffer,buffer,properties.len); |
|
477 | memcpy(packetbuffer,buffer,properties.len); | |
478 | emit emitPacket(packetbuffer,properties.len); |
|
478 | emit emitPacket(packetbuffer,properties.len); | |
479 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
479 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
480 | this->handleMutex->unlock(); |
|
480 | this->handleMutex->unlock(); | |
481 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
481 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
482 | } |
|
482 | } | |
483 | } |
|
483 | } | |
484 | else |
|
484 | else | |
485 | { |
|
485 | { | |
486 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
486 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
487 | this->handleMutex->unlock(); |
|
487 | this->handleMutex->unlock(); | |
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | } |
|
491 | } | |
492 | else |
|
492 | else | |
493 | { |
|
493 | { | |
494 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
494 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
495 | this->handleMutex->unlock(); |
|
495 | this->handleMutex->unlock(); | |
496 | } |
|
496 | } | |
497 | } |
|
497 | } | |
498 | else |
|
498 | else | |
499 | { |
|
499 | { | |
500 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
500 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
501 | this->handleMutex->unlock(); |
|
501 | this->handleMutex->unlock(); | |
502 | } |
|
502 | } | |
503 | } |
|
503 | } | |
504 | else |
|
504 | else | |
505 | { |
|
505 | { | |
506 | //do some sanity checks! |
|
506 | //do some sanity checks! | |
507 | int list = USBSpaceWire_ListDevices(); |
|
507 | int list = USBSpaceWire_ListDevices(); | |
508 | if(this->brickList!=list) |
|
508 | if(this->brickList!=list) | |
509 | { |
|
509 | { | |
510 | this->brickList = list; |
|
510 | this->brickList = list; | |
511 | emit updateAvailableBrickCount(this->brickList); |
|
511 | emit updateAvailableBrickCount(this->brickList); | |
512 | } |
|
512 | } | |
513 | usleep(RMAPtimeout/2); |
|
513 | usleep(RMAPtimeout/2); | |
514 | } |
|
514 | } | |
515 | usleep(1000); |
|
515 | usleep(1000); | |
516 | } |
|
516 | } | |
517 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
517 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
520 | bool stardundeeSPW_USB_Manager::connectBridge() | |
521 | { |
|
521 | { | |
522 | bool ret; |
|
522 | bool ret; | |
523 |
|
523 | |||
524 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) |
|
524 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) | |
525 | { |
|
525 | { | |
526 | ret = connectBridgeAsInterface(); |
|
526 | ret = connectBridgeAsInterface(); | |
527 | } |
|
527 | } | |
528 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) |
|
528 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) | |
529 | { |
|
529 | { | |
530 | ret = connectBridgeAsRouter(); |
|
530 | ret = connectBridgeAsRouter(); | |
531 | } |
|
531 | } | |
532 | else |
|
532 | else | |
533 | { |
|
533 | { | |
534 | ret = false; |
|
534 | ret = false; | |
535 | } |
|
535 | } | |
536 |
|
536 | |||
537 | return ret; |
|
537 | return ret; | |
538 | } |
|
538 | } | |
539 |
|
539 | |||
540 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() |
|
540 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() | |
541 | { |
|
541 | { | |
542 | // QMutexLocker mlock(&this->handleMutex); |
|
|||
543 | this->handleMutex->lock(); |
|
542 | this->handleMutex->lock(); | |
544 | int status; |
|
543 | int status; | |
545 | U32 statusControl; |
|
544 | U32 statusControl; | |
546 | this->connected = false; |
|
545 | this->connected = false; | |
547 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
546 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
548 | { |
|
547 | { | |
549 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
548 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
550 | this->handleMutex->unlock(); |
|
549 | this->handleMutex->unlock(); | |
551 | return false; |
|
550 | return false; | |
552 | } |
|
551 | } | |
553 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
552 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
554 |
|
553 | |||
555 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
554 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
556 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
555 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
557 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
556 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
558 |
|
557 | |||
559 | // Set the path and return path to the device |
|
558 | // Set the path and return path to the device | |
560 | CFGSpaceWire_StackClear(); |
|
559 | CFGSpaceWire_StackClear(); | |
561 | CFGSpaceWire_AddrStackPush(0); |
|
560 | CFGSpaceWire_AddrStackPush(0); | |
562 | CFGSpaceWire_AddrStackPush(254); |
|
561 | CFGSpaceWire_AddrStackPush(254); | |
563 | CFGSpaceWire_RetAddrStackPush(254); |
|
562 | CFGSpaceWire_RetAddrStackPush(254); | |
564 | // set the base transmit rate to 100 MHz |
|
563 | // set the base transmit rate to 100 MHz | |
565 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
564 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
566 | if (status != CFG_TRANSFER_SUCCESS) |
|
565 | if (status != CFG_TRANSFER_SUCCESS) | |
567 | { |
|
566 | { | |
568 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
567 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
569 | this->handleMutex->unlock(); |
|
568 | this->handleMutex->unlock(); | |
570 | return false; |
|
569 | return false; | |
571 | } |
|
570 | } | |
572 | else |
|
571 | else | |
573 | { |
|
572 | { | |
574 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
573 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
575 | } |
|
574 | } | |
576 |
|
575 | |||
577 | // read the link status |
|
576 | // read the link status | |
578 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
577 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
579 | { |
|
578 | { | |
580 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
579 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
581 | this->handleMutex->unlock(); |
|
580 | this->handleMutex->unlock(); | |
582 | return false; |
|
581 | return false; | |
583 | } |
|
582 | } | |
584 | else |
|
583 | else | |
585 | { |
|
584 | { | |
586 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
585 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
587 |
|
586 | |||
588 | // Set the link status control register properties |
|
587 | // Set the link status control register properties | |
589 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
588 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
590 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
589 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
591 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
590 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
592 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
591 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
593 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
592 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
594 |
|
593 | |||
595 | // Set the link status control register |
|
594 | // Set the link status control register | |
596 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
595 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
597 | { |
|
596 | { | |
598 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
597 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
599 | this->handleMutex->unlock(); |
|
598 | this->handleMutex->unlock(); | |
600 | return false; |
|
599 | return false; | |
601 | } |
|
600 | } | |
602 | else |
|
601 | else | |
603 | { |
|
602 | { | |
604 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
603 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
605 | } |
|
604 | } | |
606 | } |
|
605 | } | |
607 |
|
606 | |||
608 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
607 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
609 | { |
|
608 | { | |
610 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
609 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
611 | this->handleMutex->unlock(); |
|
610 | this->handleMutex->unlock(); | |
612 | return false; |
|
611 | return false; | |
613 | } |
|
612 | } | |
614 | else |
|
613 | else | |
615 | { |
|
614 | { | |
616 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
615 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
617 | } |
|
616 | } | |
618 |
|
617 | |||
619 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
618 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
620 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
619 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
621 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
620 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
622 | this->handleMutex->unlock(); |
|
621 | this->handleMutex->unlock(); | |
623 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
622 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
624 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
623 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
625 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
624 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
626 | this->connected = true; |
|
625 | this->connected = true; | |
627 | return true; |
|
626 | return true; | |
628 | } |
|
627 | } | |
629 |
|
628 | |||
630 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() |
|
629 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() | |
631 | { |
|
630 | { | |
632 | // QMutexLocker mlock(&this->handleMutex); |
|
631 | // QMutexLocker mlock(&this->handleMutex); | |
633 | this->handleMutex->lock(); |
|
632 | this->handleMutex->lock(); | |
634 | int status; |
|
633 | int status; | |
635 | U32 statusControl; |
|
634 | U32 statusControl; | |
636 | unsigned int linkStatus1; |
|
635 | unsigned int linkStatus1; | |
637 | unsigned int linkStatus2; |
|
636 | unsigned int linkStatus2; | |
638 | unsigned char linkNumber; |
|
637 | unsigned char linkNumber; | |
639 | unsigned char deviceIsAnInterface; |
|
638 | unsigned char deviceIsAnInterface; | |
640 |
|
639 | |||
641 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
640 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
642 | { |
|
641 | { | |
643 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); |
|
642 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |
644 | this->handleMutex->unlock(); |
|
643 | this->handleMutex->unlock(); | |
645 | return false; |
|
644 | return false; | |
646 | } |
|
645 | } | |
647 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " |
|
646 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " | |
648 | + QString::number(this->selectedBrick)); |
|
647 | + QString::number(this->selectedBrick)); | |
649 |
|
648 | |||
650 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
649 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
651 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
650 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
652 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
651 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
653 |
|
652 | |||
654 | // Set the path and return path to the device |
|
653 | // Set the path and return path to the device | |
655 | // This affects just the operations performed by the Configuration Library and does not affect the packets |
|
654 | // This affects just the operations performed by the Configuration Library and does not affect the packets | |
656 | // sent and received using the driver API. |
|
655 | // sent and received using the driver API. | |
657 | CFGSpaceWire_StackClear(); |
|
656 | CFGSpaceWire_StackClear(); | |
658 | CFGSpaceWire_AddrStackPush(0); |
|
657 | CFGSpaceWire_AddrStackPush(0); | |
659 | CFGSpaceWire_AddrStackPush(254); |
|
658 | CFGSpaceWire_AddrStackPush(254); | |
660 | CFGSpaceWire_RetAddrStackPush(254); |
|
659 | CFGSpaceWire_RetAddrStackPush(254); | |
661 |
|
660 | |||
662 | // set the base transmit rate to 100 MHz |
|
661 | // set the base transmit rate to 100 MHz | |
663 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
662 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
664 | if (status != CFG_TRANSFER_SUCCESS) |
|
663 | if (status != CFG_TRANSFER_SUCCESS) | |
665 | { |
|
664 | { | |
666 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); |
|
665 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |
667 | } |
|
666 | } | |
668 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); |
|
667 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |
669 |
|
668 | |||
670 | //********************* |
|
669 | //********************* | |
671 | // LINK 1 CONFIGURATION |
|
670 | // LINK 1 CONFIGURATION | |
672 | linkNumber = 1; |
|
671 | linkNumber = 1; | |
673 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
672 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
674 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
673 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
675 | else |
|
674 | else | |
676 | { |
|
675 | { | |
677 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
676 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
678 |
|
677 | |||
679 | // Set the link status control register properties |
|
678 | // Set the link status control register properties | |
680 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
679 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
681 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
680 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
682 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
681 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
683 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
682 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
684 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
683 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
685 |
|
684 | |||
686 | // Set the link status control register |
|
685 | // Set the link status control register | |
687 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
686 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
688 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
687 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
689 | else |
|
688 | else | |
690 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); |
|
689 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); | |
691 | } |
|
690 | } | |
692 |
|
691 | |||
693 | //********************* |
|
692 | //********************* | |
694 | // LINK 2 CONFIGURATION |
|
693 | // LINK 2 CONFIGURATION | |
695 | linkNumber = 2; |
|
694 | linkNumber = 2; | |
696 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
695 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
697 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
696 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
698 | else |
|
697 | else | |
699 | { |
|
698 | { | |
700 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
699 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
701 |
|
700 | |||
702 | // Set the link status control register properties |
|
701 | // Set the link status control register properties | |
703 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
702 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
704 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
703 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
705 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
704 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
706 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
705 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
707 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
706 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
708 |
|
707 | |||
709 | // Set the link status control register |
|
708 | // Set the link status control register | |
710 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
709 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
711 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
710 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
712 | else |
|
711 | else | |
713 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); |
|
712 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); | |
714 | } |
|
713 | } | |
715 |
|
714 | |||
716 | //*************************** |
|
715 | //*************************** | |
717 | // SET THE DEVICE AS A ROUTER |
|
716 | // SET THE DEVICE AS A ROUTER | |
718 | deviceIsAnInterface = 0; // 0 = router, 1 = interface |
|
717 | deviceIsAnInterface = 0; // 0 = router, 1 = interface | |
719 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) |
|
718 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) | |
720 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); |
|
719 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); | |
721 | else |
|
720 | else | |
722 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); |
|
721 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); | |
723 |
|
722 | |||
724 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 |
|
723 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 | |
725 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 |
|
724 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 | |
726 |
|
725 | |||
727 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only |
|
726 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only | |
728 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
727 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
729 |
|
728 | |||
730 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); |
|
729 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |
731 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); |
|
730 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |
732 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); |
|
731 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |
733 |
|
732 | |||
734 | //************ |
|
733 | //************ | |
735 | // test Link 1 and Link 2 |
|
734 | // test Link 1 and Link 2 | |
736 | linkStatus1 = getLinkStatus(0x01); |
|
735 | linkStatus1 = getLinkStatus(0x01); | |
737 | linkStatus2 = getLinkStatus(0x02); |
|
736 | linkStatus2 = getLinkStatus(0x02); | |
738 | this->handleMutex->unlock(); |
|
737 | this->handleMutex->unlock(); | |
739 |
|
738 | |||
740 | if ((linkStatus1==1) || (linkStatus2==1)) |
|
739 | if ((linkStatus1==1) || (linkStatus2==1)) | |
741 | { |
|
740 | { | |
742 | initializeTimecodeGeneration(); |
|
741 | initializeTimecodeGeneration(); | |
743 | this->connected=true; |
|
742 | this->connected=true; | |
744 | return true; |
|
743 | return true; | |
745 | } |
|
744 | } | |
746 | else |
|
745 | else | |
747 | { |
|
746 | { | |
748 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
747 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |
749 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
748 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |
750 | starDundeeStatusQueryDialog->exec(); |
|
749 | starDundeeStatusQueryDialog->exec(); | |
751 | this->connected = false; |
|
750 | this->connected = false; | |
752 | return false; |
|
751 | return false; | |
753 | } |
|
752 | } | |
754 | } |
|
753 | } | |
755 |
|
754 | |||
756 | void stardundeeSPW_USB_Manager::initDialog( void ) |
|
755 | void stardundeeSPW_USB_Manager::initDialog( void ) | |
757 | { |
|
756 | { | |
758 | // STAR DUNDEE STATUS QUERY DIALOG |
|
757 | // STAR DUNDEE STATUS QUERY DIALOG | |
759 | starDundeeStatusQueryDialog = new QDialog; |
|
758 | starDundeeStatusQueryDialog = new QDialog; | |
760 | starDundeeStatusQueryDialogLayout = new QGridLayout; |
|
759 | starDundeeStatusQueryDialogLayout = new QGridLayout; | |
761 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); |
|
760 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); | |
762 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); |
|
761 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); | |
763 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); |
|
762 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); | |
764 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); |
|
763 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); | |
765 | statusLink1 = new QLabel(tr("Link 1 status code: -")); |
|
764 | statusLink1 = new QLabel(tr("Link 1 status code: -")); | |
766 | statusLink2 = new QLabel(tr("Link 2 status code: -")); |
|
765 | statusLink2 = new QLabel(tr("Link 2 status code: -")); | |
767 |
|
766 | |||
768 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); |
|
767 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); | |
769 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); |
|
768 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); | |
770 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); |
|
769 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); | |
771 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); |
|
770 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); | |
772 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); |
|
771 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); | |
773 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); |
|
772 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); | |
774 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); |
|
773 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); | |
775 | } |
|
774 | } | |
776 |
|
775 | |||
777 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) |
|
776 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) | |
778 | { |
|
777 | { | |
779 | U32 routingTableEntry; |
|
778 | U32 routingTableEntry; | |
780 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber |
|
779 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber | |
781 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) |
|
780 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) | |
782 | { |
|
781 | { | |
783 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); |
|
782 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); | |
784 | } |
|
783 | } | |
785 | // Build the routing table entry |
|
784 | // Build the routing table entry | |
786 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, |
|
785 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, | |
787 | dwOutputPorts, // route out of port dwOutputPorts |
|
786 | dwOutputPorts, // route out of port dwOutputPorts | |
788 | bDelHead, // header deletion is enabled [1] or disabled [0] |
|
787 | bDelHead, // header deletion is enabled [1] or disabled [0] | |
789 | 0); // priority normal |
|
788 | 0); // priority normal | |
790 | // Set the routing table entry for logical address tableEntry |
|
789 | // Set the routing table entry for logical address tableEntry | |
791 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
790 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
792 | { |
|
791 | { | |
793 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); |
|
792 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); | |
794 | } |
|
793 | } | |
795 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); |
|
794 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); | |
796 | return 1; |
|
795 | return 1; | |
797 | } |
|
796 | } | |
798 |
|
797 | |||
799 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) |
|
798 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) | |
800 | { |
|
799 | { | |
801 | U32 routingTableEntry, outputPorts; |
|
800 | U32 routingTableEntry, outputPorts; | |
802 | char enabled, delHead, priority; |
|
801 | char enabled, delHead, priority; | |
803 | int portNum; |
|
802 | int portNum; | |
804 |
|
803 | |||
805 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); |
|
804 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); | |
806 | // Read the routing table entry |
|
805 | // Read the routing table entry | |
807 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
806 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
808 | { |
|
807 | { | |
809 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); |
|
808 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); | |
810 | } |
|
809 | } | |
811 | else |
|
810 | else | |
812 | { |
|
811 | { | |
813 | // Display the routing table entry properties |
|
812 | // Display the routing table entry properties | |
814 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); |
|
813 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); | |
815 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); |
|
814 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); | |
816 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); |
|
815 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); | |
817 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); |
|
816 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); | |
818 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); |
|
817 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); | |
819 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); |
|
818 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); | |
820 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); |
|
819 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); | |
821 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); |
|
820 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); | |
822 | for (portNum = 0; portNum < 32; portNum++) |
|
821 | for (portNum = 0; portNum < 32; portNum++) | |
823 | { |
|
822 | { | |
824 | if (outputPorts & (1 << portNum)) |
|
823 | if (outputPorts & (1 << portNum)) | |
825 | { |
|
824 | { | |
826 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); |
|
825 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); | |
827 | } |
|
826 | } | |
828 | } |
|
827 | } | |
829 | } |
|
828 | } | |
830 |
|
829 | |||
831 | return 1; |
|
830 | return 1; | |
832 | } |
|
831 | } | |
833 |
|
832 | |||
834 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() |
|
833 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() | |
835 | { |
|
834 | { | |
836 | U32 dwTickEnableStatus; |
|
835 | U32 dwTickEnableStatus; | |
837 | U32 rtr_clk_freq; |
|
836 | U32 rtr_clk_freq; | |
838 |
|
837 | |||
839 | // (1) RESET |
|
838 | // (1) RESET | |
840 | if (!USBSpaceWire_TC_Reset(hDevice)) |
|
839 | if (!USBSpaceWire_TC_Reset(hDevice)) | |
841 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); |
|
840 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); | |
842 |
|
841 | |||
843 | // (2) Clear the tick enable register |
|
842 | // (2) Clear the tick enable register | |
844 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) |
|
843 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) | |
845 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); |
|
844 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); | |
846 | else |
|
845 | else | |
847 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); |
|
846 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); | |
848 |
|
847 | |||
849 | // (3) get the tick status |
|
848 | // (3) get the tick status | |
850 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); |
|
849 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); | |
851 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); |
|
850 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); | |
852 |
|
851 | |||
853 | // (4) enable external timecode selection |
|
852 | // (4) enable external timecode selection | |
854 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
853 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
855 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); |
|
854 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); | |
856 |
|
855 | |||
857 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
856 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
858 |
|
857 | |||
859 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); |
|
858 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); | |
860 |
|
859 | |||
861 | //************************************************** |
|
860 | //************************************************** | |
862 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
861 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
863 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) |
|
862 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) | |
864 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
863 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
865 | } |
|
864 | } | |
866 |
|
865 | |||
867 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) |
|
866 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) | |
868 | { |
|
867 | { | |
869 | U32 statusControl, errorStatus, portType; |
|
868 | U32 statusControl, errorStatus, portType; | |
870 | U32 linkStatus, operatingSpeed, outputPortConnection; |
|
869 | U32 linkStatus, operatingSpeed, outputPortConnection; | |
871 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; |
|
870 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; | |
872 |
|
871 | |||
873 | // Read the link status control register |
|
872 | // Read the link status control register | |
874 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
873 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) | |
875 | { |
|
874 | { | |
876 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); |
|
875 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); | |
877 | } |
|
876 | } | |
878 | else |
|
877 | else | |
879 | { |
|
878 | { | |
880 | // Display the link status control register properties |
|
879 | // Display the link status control register properties | |
881 | CFGSpaceWire_LSPortType(statusControl, &portType); |
|
880 | CFGSpaceWire_LSPortType(statusControl, &portType); | |
882 | if (portType == CFG_CONFIGURATION_PORT) |
|
881 | if (portType == CFG_CONFIGURATION_PORT) | |
883 | { |
|
882 | { | |
884 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); |
|
883 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); | |
885 | } |
|
884 | } | |
886 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) |
|
885 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) | |
887 | { |
|
886 | { | |
888 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); |
|
887 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); | |
889 | } |
|
888 | } | |
890 | else |
|
889 | else | |
891 | { |
|
890 | { | |
892 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); |
|
891 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); | |
893 | } |
|
892 | } | |
894 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); |
|
893 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); | |
895 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); |
|
894 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); | |
896 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); |
|
895 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); | |
897 | CFGSpaceWire_LSIsStart(statusControl, &isStart); |
|
896 | CFGSpaceWire_LSIsStart(statusControl, &isStart); | |
898 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); |
|
897 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); | |
899 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); |
|
898 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); | |
900 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); |
|
899 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); | |
901 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); |
|
900 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); | |
902 | } |
|
901 | } | |
903 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) |
|
902 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) | |
904 | +" is " + dwLinkStatusQString[linkStatus]); |
|
903 | +" is " + dwLinkStatusQString[linkStatus]); | |
905 | if (linkStatus == 5) |
|
904 | if (linkStatus == 5) | |
906 | { |
|
905 | { | |
907 | return 1; |
|
906 | return 1; | |
908 | } |
|
907 | } | |
909 | else return 0; |
|
908 | else return 0; | |
910 | } |
|
909 | } | |
911 |
|
910 | |||
912 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
911 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
913 | { |
|
912 | { | |
914 | this->handleMutex->lock(); |
|
913 | this->handleMutex->lock(); | |
915 | USBSpaceWire_Close(hDevice); // Close the device |
|
914 | USBSpaceWire_Close(hDevice); // Close the device | |
916 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
915 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
917 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
916 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
918 | this->handleMutex->unlock(); |
|
917 | this->handleMutex->unlock(); | |
919 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
918 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
920 | this->RMAP_pending_transaction_IDs.clear(); |
|
919 | this->RMAP_pending_transaction_IDs.clear(); | |
921 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
920 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
922 | this->RMAP_AnswersMtx->lock(); |
|
921 | this->RMAP_AnswersMtx->lock(); | |
923 | this->RMAP_Answers.clear(); |
|
922 | this->RMAP_Answers.clear(); | |
924 | this->RMAP_AnswersMtx->unlock(); |
|
923 | this->RMAP_AnswersMtx->unlock(); | |
925 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
924 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
926 | return true; |
|
925 | return true; | |
927 | } |
|
926 | } | |
928 |
|
927 | |||
929 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
928 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
930 | { |
|
929 | { | |
931 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
930 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
932 | int ID=0; |
|
931 | int ID=0; | |
933 | bool found=true; |
|
932 | bool found=true; | |
934 | while(ID<511) |
|
933 | while(ID<511) | |
935 | { |
|
934 | { | |
936 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
935 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
937 | { |
|
936 | { | |
938 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
937 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
939 | } |
|
938 | } | |
940 | if(found==true)break; |
|
939 | if(found==true)break; | |
941 | ID++; |
|
940 | ID++; | |
942 | found = true; |
|
941 | found = true; | |
943 | } |
|
942 | } | |
944 | if(found) |
|
943 | if(found) | |
945 | { |
|
944 | { | |
946 | RMAP_pending_transaction_IDs.append(ID); |
|
945 | RMAP_pending_transaction_IDs.append(ID); | |
947 | } |
|
946 | } | |
948 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
947 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
949 | return ID; |
|
948 | return ID; | |
950 | } |
|
949 | } | |
951 |
|
950 | |||
952 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
951 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
953 | { |
|
952 | { | |
954 | QTime timeout; |
|
953 | QTime timeout; | |
955 | *buffer=NULL; |
|
954 | *buffer=NULL; | |
956 | int count=0; |
|
955 | int count=0; | |
957 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
956 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
958 | timeout.start(); |
|
957 | timeout.start(); | |
959 | while (*buffer==NULL) |
|
958 | while (*buffer==NULL) | |
960 | { |
|
959 | { | |
961 | this->RMAP_AnswersMtx->lock(); |
|
960 | this->RMAP_AnswersMtx->lock(); | |
962 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
961 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
963 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
962 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
964 | for(int i=0;i<RMAP_Answers.count();i++) |
|
963 | for(int i=0;i<RMAP_Answers.count();i++) | |
965 | { |
|
964 | { | |
966 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
965 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); | |
967 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
966 | if(RMAP_Answers[i]->transactionID==transactionID) | |
968 | { |
|
967 | { | |
969 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
968 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
970 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
969 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
971 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
970 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
972 | { |
|
971 | { | |
973 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
972 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
974 | { |
|
973 | { | |
975 | RMAP_pending_transaction_IDs.removeAt(j); |
|
974 | RMAP_pending_transaction_IDs.removeAt(j); | |
976 | } |
|
975 | } | |
977 | } |
|
976 | } | |
978 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
977 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
979 | *buffer = RMAP_Answers[i]->data; |
|
978 | *buffer = RMAP_Answers[i]->data; | |
980 | count = RMAP_Answers[i]->len; |
|
979 | count = RMAP_Answers[i]->len; | |
981 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
980 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
982 | RMAP_Answers.removeAt(i); |
|
981 | RMAP_Answers.removeAt(i); | |
983 | delete tmp; |
|
982 | delete tmp; | |
984 | } |
|
983 | } | |
985 | } |
|
984 | } | |
986 | this->RMAP_AnswersMtx->unlock(); |
|
985 | this->RMAP_AnswersMtx->unlock(); | |
987 | //if no answer found in the stack wait until a new packet is pushed |
|
986 | //if no answer found in the stack wait until a new packet is pushed | |
988 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
987 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
989 | if(*buffer==NULL) |
|
988 | if(*buffer==NULL) | |
990 | { |
|
989 | { | |
991 | while (0==this->RMAP_AnswersSem->available()) |
|
990 | while (0==this->RMAP_AnswersSem->available()) | |
992 | { |
|
991 | { | |
993 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
992 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
994 | if(timeout.elapsed()>=RMAPtimeout) |
|
993 | if(timeout.elapsed()>=RMAPtimeout) | |
995 | { |
|
994 | { | |
996 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
995 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
997 | return -1; |
|
996 | return -1; | |
998 | } |
|
997 | } | |
999 | usleep(1000); |
|
998 | usleep(1000); | |
1000 | } |
|
999 | } | |
1001 | this->RMAP_AnswersSem->acquire(); |
|
1000 | this->RMAP_AnswersSem->acquire(); | |
1002 | } |
|
1001 | } | |
1003 | } |
|
1002 | } | |
1004 | return count; |
|
1003 | return count; | |
1005 | } |
|
1004 | } | |
1006 |
|
1005 | |||
1007 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
1006 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
1008 | { |
|
1007 | { | |
1009 | char protocoleIdentifier; |
|
1008 | char protocoleIdentifier; | |
1010 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; |
|
1009 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; | |
1011 | USB_SPACEWIRE_ID pIdentifier; |
|
1010 | USB_SPACEWIRE_ID pIdentifier; | |
1012 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
1011 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
1013 | this->handleMutex->lock(); |
|
1012 | this->handleMutex->lock(); | |
1014 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
1013 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
1015 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
1014 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
1016 | this->handleMutex->unlock(); |
|
1015 | this->handleMutex->unlock(); | |
1017 | if (result != TRANSFER_SUCCESS) |
|
1016 | if (result != TRANSFER_SUCCESS) | |
1018 | { |
|
1017 | { | |
1019 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
1018 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
1020 | return false; |
|
1019 | return false; | |
1021 | } |
|
1020 | } | |
1022 | else |
|
1021 | else | |
1023 | { |
|
1022 | { | |
1024 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link |
|
1023 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link | |
1025 | // read the protocole identifier |
|
1024 | // read the protocole identifier | |
1026 | protocoleIdentifier = packet[2]; |
|
1025 | protocoleIdentifier = packet[2]; | |
1027 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) |
|
1026 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) | |
1028 | emit ccsdsPacketTransmittedToSpw(); |
|
1027 | emit ccsdsPacketTransmittedToSpw(); | |
1029 |
|
1028 | |||
1030 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
1029 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
1031 | } |
|
1030 | } | |
1032 | // this->handleMutex->unlock(); |
|
1031 | // this->handleMutex->unlock(); | |
1033 | return true; |
|
1032 | return true; | |
1034 | } |
|
1033 | } | |
1035 |
|
1034 | |||
1036 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
1035 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
1037 | { |
|
1036 | { | |
1038 | char* packetbuffer = (char*)malloc(len); |
|
1037 | char* packetbuffer = (char*)malloc(len); | |
1039 | memcpy(packetbuffer,packet,len); |
|
1038 | memcpy(packetbuffer,packet,len); | |
1040 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
1039 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
1041 | RMAP_AnswersMtx->lock(); |
|
1040 | RMAP_AnswersMtx->lock(); | |
1042 | RMAP_Answers.append(RMPAPpacket); |
|
1041 | RMAP_Answers.append(RMPAPpacket); | |
1043 | RMAP_AnswersMtx->unlock(); |
|
1042 | RMAP_AnswersMtx->unlock(); | |
1044 | } |
|
1043 | } | |
1045 |
|
1044 | |||
1046 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) |
|
1045 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) | |
1047 | { |
|
1046 | { | |
1048 | if (onOff == true) |
|
1047 | if (onOff == true) | |
1049 | { |
|
1048 | { | |
1050 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) |
|
1049 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |
1051 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); |
|
1050 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); | |
1052 | } |
|
1051 | } | |
1053 | else |
|
1052 | else | |
1054 | { |
|
1053 | { | |
1055 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) |
|
1054 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |
1056 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); |
|
1055 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); | |
1057 | } |
|
1056 | } | |
1058 | } |
|
1057 | } | |
1059 |
|
1058 | |||
1060 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) |
|
1059 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) | |
1061 | { |
|
1060 | { | |
1062 | return this->linkNumber; |
|
1061 | return this->linkNumber; | |
1063 | } |
|
1062 | } | |
1064 |
|
1063 | |||
1065 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) |
|
1064 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) | |
1066 | { |
|
1065 | { | |
1067 | U32 rtr_clk_freq=0; |
|
1066 | U32 rtr_clk_freq=0; | |
1068 | U32 freqCount=0; |
|
1067 | U32 freqCount=0; | |
1069 | double freqCountInDouble=0.0; |
|
1068 | double freqCountInDouble=0.0; | |
1070 | double currentFrequency=0.0; |
|
1069 | double currentFrequency=0.0; | |
1071 |
|
1070 | |||
1072 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
1071 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
1073 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; |
|
1072 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; | |
1074 | freqCount = (unsigned int) freqCountInDouble; |
|
1073 | freqCount = (unsigned int) freqCountInDouble; | |
1075 |
|
1074 | |||
1076 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); |
|
1075 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); | |
1077 |
|
1076 | |||
1078 | //************************************************** |
|
1077 | //************************************************** | |
1079 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
1078 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
1080 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) |
|
1079 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) | |
1081 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
1080 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
1082 | else |
|
1081 | else | |
1083 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" |
|
1082 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" | |
1084 | + " (freqCount set to " + QString::number(freqCount) + ")" ); |
|
1083 | + " (freqCount set to " + QString::number(freqCount) + ")" ); | |
1085 | } |
|
1084 | } | |
1086 |
|
1085 | |||
1087 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) |
|
1086 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) | |
1088 | { |
|
1087 | { | |
1089 | // enable external timecode selection |
|
1088 | // enable external timecode selection | |
1090 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) |
|
1089 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) | |
1091 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); |
|
1090 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); | |
1092 |
|
1091 | |||
1093 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) |
|
1092 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) | |
1094 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); |
|
1093 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); | |
1095 | else |
|
1094 | else | |
1096 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); |
|
1095 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); | |
1097 |
|
1096 | |||
1098 | // disable external timecode selection |
|
1097 | // disable external timecode selection | |
1099 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
1098 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
1100 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); |
|
1099 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); | |
1101 | } |
|
1100 | } | |
1102 |
|
1101 | |||
1103 |
|
1102 |
@@ -1,89 +1,90 | |||||
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 | TARGET = spwplugin |
|
13 | TARGET = spwplugin | |
13 | DEFINES += PLUGIN=spwplugin |
|
14 | DEFINES += PLUGIN=spwplugin | |
14 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" |
|
15 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" | |
15 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" |
|
16 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" | |
16 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" |
|
17 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org; Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\" | |
17 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
18 | DEFINES += driver_Description="\"\\\"This plugin allows you to use spacewire's RMAP protocol with Stardundee USB brick v1"\\\"\" | |
18 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" |
|
|||
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 | GR-ESB |
|
34 | GR-ESB | |
34 |
|
35 | |||
35 | HEADERS += \ |
|
36 | HEADERS += \ | |
36 | spwplugin.h \ |
|
37 | spwplugin.h \ | |
37 | StarDundee/stardundeespw_usb.h \ |
|
38 | StarDundee/stardundeespw_usb.h \ | |
38 | abstractspwbridge.h \ |
|
39 | abstractspwbridge.h \ | |
39 | spw.h \ |
|
40 | spw.h \ | |
40 | StarDundee/stardundeegui.h \ |
|
41 | StarDundee/stardundeegui.h \ | |
41 | SpwTcpPacketServer/spwtcppacketserver.h \ |
|
42 | SpwTcpPacketServer/spwtcppacketserver.h \ | |
42 | spwpywrapper.h \ |
|
43 | spwpywrapper.h \ | |
43 | GR-ESB/gr_esb_bridge.h \ |
|
44 | GR-ESB/gr_esb_bridge.h \ | |
44 | GR-ESB/gr_esb_ui.h \ |
|
45 | GR-ESB/gr_esb_ui.h \ | |
45 |
incoming |
|
46 | SpwTcpPacketServer/incomingpacketparser.h | |
46 |
|
47 | |||
47 |
|
48 | |||
48 | SOURCES += \ |
|
49 | SOURCES += \ | |
49 | spwplugin.cpp \ |
|
50 | spwplugin.cpp \ | |
50 | StarDundee/stardundeespw_usb.cpp \ |
|
51 | StarDundee/stardundeespw_usb.cpp \ | |
51 | abstractspwbridge.cpp \ |
|
52 | abstractspwbridge.cpp \ | |
52 | StarDundee/stardundeegui.cpp \ |
|
53 | StarDundee/stardundeegui.cpp \ | |
53 | SpwTcpPacketServer/spwtcppacketserver.cpp \ |
|
54 | SpwTcpPacketServer/spwtcppacketserver.cpp \ | |
54 | spwpywrapper.cpp \ |
|
55 | spwpywrapper.cpp \ | |
55 | GR-ESB/gr_esb_bridge.cpp \ |
|
56 | GR-ESB/gr_esb_bridge.cpp \ | |
56 | GR-ESB/gr_esb_ui.cpp \ |
|
57 | GR-ESB/gr_esb_ui.cpp \ | |
57 |
incoming |
|
58 | SpwTcpPacketServer/incomingpacketparser.cpp | |
58 |
|
59 | |||
59 | FORMS += \ |
|
60 | FORMS += \ | |
60 | StarDundee/stardundeeGUI.ui \ |
|
61 | StarDundee/stardundeeGUI.ui \ | |
61 | SpwTcpPacketServer/spwtcppacketserver.ui \ |
|
62 | SpwTcpPacketServer/spwtcppacketserver.ui \ | |
62 | GR-ESB/gr_esb_ui.ui |
|
63 | GR-ESB/gr_esb_ui.ui | |
63 |
|
64 | |||
64 | RESOURCES += \ |
|
65 | RESOURCES += \ | |
65 | spwRessources.qrc |
|
66 | spwRessources.qrc | |
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 |
|
89 | |||
89 |
|
90 |
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