@@ -1,109 +1,115 | |||||
1 |
%global upstream_name socexplorer-plugins-0.7- |
|
1 | %global upstream_name socexplorer-plugins-0.7-2 | |
2 |
|
2 | |||
3 | Name: socexplorer-plugins |
|
3 | Name: socexplorer-plugins | |
4 | Version: 0.7 |
|
4 | Version: 0.7 | |
5 |
Release: |
|
5 | Release: 2%{?dist} | |
6 | Summary: Base plugins for SocExplorer. |
|
6 | Summary: Base plugins for SocExplorer. | |
7 | Group: Development/Tools |
|
7 | Group: Development/Tools | |
8 | License: GPLv2 |
|
8 | License: GPLv2 | |
9 | URL: https://hephaistos.lpp.polytechnique.fr/redmine/projects/socexplorer |
|
9 | URL: https://hephaistos.lpp.polytechnique.fr/redmine/projects/socexplorer | |
10 | Source0: https://hephaistos.lpp.polytechnique.fr/redmine/attachments/download/381/%{upstream_name}.zip |
|
10 | Source0: https://hephaistos.lpp.polytechnique.fr/redmine/attachments/download/381/%{upstream_name}.zip | |
11 |
|
11 | |||
12 | BuildRequires: python2-devel |
|
12 | BuildRequires: python2-devel | |
13 | BuildRequires: qt5-qtbase-devel |
|
13 | BuildRequires: qt5-qtbase-devel | |
14 | BuildRequires: qt5-qtwebkit-devel |
|
14 | BuildRequires: qt5-qtwebkit-devel | |
15 | BuildRequires: qt5-qttools-static |
|
15 | BuildRequires: qt5-qttools-static | |
16 | BuildRequires: qt5-qttools-devel |
|
16 | BuildRequires: qt5-qttools-devel | |
17 | BuildRequires: qt5-qtsvg-devel |
|
17 | BuildRequires: qt5-qtsvg-devel | |
18 | BuildRequires: qt5-qtxmlpatterns-devel |
|
18 | BuildRequires: qt5-qtxmlpatterns-devel | |
19 | BuildRequires: elfutils-libelf-devel |
|
19 | BuildRequires: elfutils-libelf-devel | |
20 | BuildRequires: qt5-pythonqt-devel |
|
20 | BuildRequires: qt5-pythonqt-devel | |
21 | BuildRequires: socexplorer-devel = 0.7 |
|
21 | BuildRequires: socexplorer-devel = 0.7 | |
22 |
|
22 | |||
23 | Requires: socexplorer = 0.7 |
|
23 | Requires: socexplorer = 0.7 | |
24 | Requires: qt5-pythonqt |
|
24 | Requires: qt5-pythonqt | |
25 | Requires: python2 |
|
25 | Requires: python2 | |
26 | Requires: qt5-qtwebkit |
|
26 | Requires: qt5-qtwebkit | |
27 | Requires: qt5-qttools |
|
27 | Requires: qt5-qttools | |
28 | Requires: qt5-qtsvg |
|
28 | Requires: qt5-qtsvg | |
29 | Requires: qt5-qtxmlpatterns |
|
29 | Requires: qt5-qtxmlpatterns | |
30 | Requires: elfutils-libelf |
|
30 | Requires: elfutils-libelf | |
31 |
|
31 | |||
32 | %description |
|
32 | %description | |
33 | 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. |
|
33 | 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. | |
34 | You will get: |
|
34 | You will get: | |
35 | - AHB UART plugin |
|
35 | - AHB UART plugin | |
36 | - APB UART plugin |
|
36 | - APB UART plugin | |
37 | - AMBA plugin |
|
37 | - AMBA plugin | |
38 | - DSU3 plugin |
|
38 | - DSU3 plugin | |
39 | - Generic rw plugin |
|
39 | - Generic rw plugin | |
40 | - Memcheck & Memectr plugins |
|
40 | - Memcheck & Memectr plugins | |
41 |
|
41 | |||
42 | %prep |
|
42 | %prep | |
43 | %setup -q -n %{upstream_name} |
|
43 | %setup -q -n %{upstream_name} | |
44 |
|
44 | |||
45 | %build |
|
45 | %build | |
46 | %{_qt5_qmake} |
|
46 | %{_qt5_qmake} | |
47 |
|
47 | |||
48 | make %{?_smp_mflags} |
|
48 | make %{?_smp_mflags} | |
49 |
|
49 | |||
50 | %install |
|
50 | %install | |
51 | make install INSTALL_ROOT=%{buildroot} |
|
51 | make install INSTALL_ROOT=%{buildroot} | |
52 |
|
52 | |||
53 | %post -p /sbin/ldconfig |
|
53 | %post -p /sbin/ldconfig | |
54 |
|
54 | |||
55 | %postun -p /sbin/ldconfig |
|
55 | %postun -p /sbin/ldconfig | |
56 |
|
56 | |||
57 | %files |
|
57 | %files | |
58 | %{_qt5_libdir}/SocExplorer/plugins/libApbUartPlugin.so* |
|
58 | %{_qt5_libdir}/SocExplorer/plugins/libApbUartPlugin.so* | |
59 | %{_qt5_libdir}/SocExplorer/plugins/libahbuartplugin.so* |
|
59 | %{_qt5_libdir}/SocExplorer/plugins/libahbuartplugin.so* | |
60 | %{_qt5_libdir}/SocExplorer/plugins/libambaplugin.so* |
|
60 | %{_qt5_libdir}/SocExplorer/plugins/libambaplugin.so* | |
61 | %{_qt5_libdir}/SocExplorer/plugins/libdsu3plugin.so* |
|
61 | %{_qt5_libdir}/SocExplorer/plugins/libdsu3plugin.so* | |
62 | %{_qt5_libdir}/SocExplorer/plugins/libgenericrwplugin.so* |
|
62 | %{_qt5_libdir}/SocExplorer/plugins/libgenericrwplugin.so* | |
63 | %{_qt5_libdir}/SocExplorer/plugins/libmemcheckplugin.so* |
|
63 | %{_qt5_libdir}/SocExplorer/plugins/libmemcheckplugin.so* | |
64 | %{_qt5_libdir}/SocExplorer/plugins/libmemctrlrplugin.so* |
|
64 | %{_qt5_libdir}/SocExplorer/plugins/libmemctrlrplugin.so* | |
65 | %{_qt5_libdir}/SocExplorer/plugins/libspwplugin.so* |
|
65 | %{_qt5_libdir}/SocExplorer/plugins/libspwplugin.so* | |
66 |
|
66 | |||
67 | %changelog |
|
67 | %changelog | |
|
68 | * Fri May 13 2016 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.7-2 | |||
|
69 | - Fixed another segfault on SpwPlugin. | |||
|
70 | ||||
|
71 | * Thu Apr 21 2016 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.7-1 | |||
|
72 | - Fixed segfault on SpwPlugin. | |||
|
73 | ||||
68 | * Wed Apr 20 2016 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.7-0 |
|
74 | * Wed Apr 20 2016 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.7-0 | |
69 | - Updated to SocExplorer 0.7, some work on spwplugin merged. |
|
75 | - Updated to SocExplorer 0.7, some work on spwplugin merged. | |
70 |
|
76 | |||
71 | * Mon Oct 12 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-4 |
|
77 | * Mon Oct 12 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-4 | |
72 | - Added DSU3 cache status readout. |
|
78 | - Added DSU3 cache status readout. | |
73 |
|
79 | |||
74 | * Tue Sep 8 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-3 |
|
80 | * Tue Sep 8 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-3 | |
75 | - Added spwplugin, improved AHB plugn'play decoding, fixed GUI bug on spwplugin. |
|
81 | - Added spwplugin, improved AHB plugn'play decoding, fixed GUI bug on spwplugin. | |
76 |
|
82 | |||
77 | * Fri Apr 3 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-2 |
|
83 | * Fri Apr 3 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-2 | |
78 | - Improved ds3plugin. |
|
84 | - Improved ds3plugin. | |
79 |
|
85 | |||
80 | * Fri Apr 3 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-1 |
|
86 | * Fri Apr 3 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-1 | |
81 | - Fix some remaining mistakes. |
|
87 | - Fix some remaining mistakes. | |
82 |
|
88 | |||
83 | * Thu Apr 2 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-0 |
|
89 | * Thu Apr 2 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.6-0 | |
84 | -Uses r53 as source. |
|
90 | -Uses r53 as source. | |
85 | -Removed GenericPySysdriver interface, now socexplorer plugins can be subclassed in python. |
|
91 | -Removed GenericPySysdriver interface, now socexplorer plugins can be subclassed in python. | |
86 |
|
92 | |||
87 | * Thu Mar 26 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.5 |
|
93 | * Thu Mar 26 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.5 | |
88 | -Uses r51 as source. |
|
94 | -Uses r51 as source. | |
89 |
|
95 | |||
90 | * Wed Mar 25 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
96 | * Wed Mar 25 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
91 | -Uses r50 as source. |
|
97 | -Uses r50 as source. | |
92 |
|
98 | |||
93 | * Fri Mar 20 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
99 | * Fri Mar 20 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
94 | -Uses r49 as source. |
|
100 | -Uses r49 as source. | |
95 |
|
101 | |||
96 | * Mon Mar 9 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
102 | * Mon Mar 9 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
97 | -Uses r48 as source. |
|
103 | -Uses r48 as source. | |
98 |
|
104 | |||
99 | * Wed Feb 18 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
105 | * Wed Feb 18 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
100 | -Uses r45 as source. |
|
106 | -Uses r45 as source. | |
101 |
|
107 | |||
102 | * Tue Feb 10 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
108 | * Tue Feb 10 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
103 | -Uses r44 as source. |
|
109 | -Uses r44 as source. | |
104 |
|
110 | |||
105 | * Tue Dec 30 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
111 | * Tue Dec 30 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
106 | - Uses r42 as source. |
|
112 | - Uses r42 as source. | |
107 |
|
113 | |||
108 | * Sat Jun 28 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 |
|
114 | * Sat Jun 28 2014 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.4 | |
109 | - Initial Fedora packaging |
|
115 | - Initial Fedora packaging |
@@ -1,1011 +1,1014 | |||||
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 "fakestardundeespwusb_lib.h" |
|
24 | #include "fakestardundeespwusb_lib.h" | |
25 | #include <socexplorerengine.h> |
|
25 | #include <socexplorerengine.h> | |
26 | #include <qhexedit.h> |
|
26 | #include <qhexedit.h> | |
27 |
|
27 | |||
28 | const QString dwLinkStatusQString[6] = { |
|
28 | const QString dwLinkStatusQString[6] = { | |
29 | "CFG_SPACEWIRE_ERROR_RESET", |
|
29 | "CFG_SPACEWIRE_ERROR_RESET", | |
30 | "CFG_SPACEWIRE_ERROR_WAIT", |
|
30 | "CFG_SPACEWIRE_ERROR_WAIT", | |
31 | "CFG_SPACEWIRE_READY", |
|
31 | "CFG_SPACEWIRE_READY", | |
32 | "CFG_SPACEWIRE_STARTED", |
|
32 | "CFG_SPACEWIRE_STARTED", | |
33 | "CFG_SPACEWIRE_CONNECTING", |
|
33 | "CFG_SPACEWIRE_CONNECTING", | |
34 | "CFG_SPACEWIRE_RUN" |
|
34 | "CFG_SPACEWIRE_RUN" | |
35 | }; |
|
35 | }; | |
36 |
|
36 | |||
37 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
37 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
38 | abstractSpwBridge(parent) |
|
38 | abstractSpwBridge(parent) | |
39 | { |
|
39 | { | |
40 | Q_UNUSED(parent) |
|
40 | Q_UNUSED(parent) | |
41 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
41 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
42 | makeGUI(parent); |
|
42 | makeGUI(parent); | |
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 | this->manager->start(); |
|
47 | this->manager->start(); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
50 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
51 | { |
|
51 | { | |
52 | this->manager->requestInterruption(); |
|
52 | ||
53 | while(this->manager->isRunning()); |
|
|||
54 | } |
|
53 | } | |
55 |
|
54 | |||
56 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
55 | void stardundeeSPW_USB::toggleBridgeConnection() | |
57 | { |
|
56 | { | |
58 | if(this->plugin->isConnected()) |
|
57 | if(this->plugin->isConnected()) | |
59 | { |
|
58 | { | |
60 | this->disconnectBridge(); |
|
59 | this->disconnectBridge(); | |
61 | } |
|
60 | } | |
62 | else |
|
61 | else | |
63 | { |
|
62 | { | |
64 | this->connectBridge(); |
|
63 | this->connectBridge(); | |
65 | } |
|
64 | } | |
66 | } |
|
65 | } | |
67 |
|
66 | |||
68 | bool stardundeeSPW_USB::connectBridge() |
|
67 | bool stardundeeSPW_USB::connectBridge() | |
69 | { |
|
68 | { | |
70 | if(this->manager->connectBridge()) |
|
69 | if(this->manager->connectBridge()) | |
71 | { |
|
70 | { | |
72 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); |
|
71 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); | |
73 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); |
|
72 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); | |
74 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
73 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
75 | emit setConnected(true); |
|
74 | emit setConnected(true); | |
76 | return true; |
|
75 | return true; | |
77 | } |
|
76 | } | |
78 | return false; |
|
77 | return false; | |
79 | } |
|
78 | } | |
80 |
|
79 | |||
81 | bool stardundeeSPW_USB::disconnectBridge() |
|
80 | bool stardundeeSPW_USB::disconnectBridge() | |
82 | { |
|
81 | { | |
83 | if(this->manager->disconnectBridge()) |
|
82 | if(this->manager->disconnectBridge()) | |
84 | { |
|
83 | { | |
85 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
84 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
86 | emit setConnected(false); |
|
85 | emit setConnected(false); | |
87 | return true; |
|
86 | return true; | |
88 | } |
|
87 | } | |
89 | return false; |
|
88 | return false; | |
90 | } |
|
89 | } | |
91 |
|
90 | |||
92 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
91 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
93 | { |
|
92 | { | |
94 | return this->manager->sendPacket(packet,size); |
|
93 | return this->manager->sendPacket(packet,size); | |
95 | } |
|
94 | } | |
96 |
|
95 | |||
97 | 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) | |
98 | { |
|
97 | { | |
99 | 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]; | |
100 | char *RMAPAckBuff; |
|
99 | char *RMAPAckBuff; | |
101 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
100 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
102 | int transactionID = 0; |
|
101 | int transactionID = 0; | |
103 | int written=0; |
|
102 | int written=0; | |
104 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
103 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
105 | QProgressBar* progress=NULL; |
|
104 | QProgressBar* progress=NULL; | |
106 | SocExplorerAutoProgressBar autopb; |
|
105 | SocExplorerAutoProgressBar autopb; | |
107 | if(count>RMAP_MAX_XFER_SIZE) |
|
106 | if(count>RMAP_MAX_XFER_SIZE) | |
108 | { |
|
107 | { | |
109 | 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); | |
110 | autopb.setProgressBar(progress); |
|
109 | autopb.setProgressBar(progress); | |
111 | } |
|
110 | } | |
112 | //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! | |
113 | while(count>=RMAP_MAX_XFER_SIZE) |
|
112 | while(count>=RMAP_MAX_XFER_SIZE) | |
114 | { |
|
113 | { | |
115 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
114 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
116 | { |
|
115 | { | |
117 | 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); | |
118 | 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); | |
119 | 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); | |
120 | 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); | |
121 | } |
|
120 | } | |
122 | transactionID=manager->getRMAPtransactionID(); |
|
121 | transactionID=manager->getRMAPtransactionID(); | |
123 | 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); | |
124 | RMAP_build_tx_request_header( |
|
123 | RMAP_build_tx_request_header( | |
125 | this->manager->destinationLogicalAddress, |
|
124 | this->manager->destinationLogicalAddress, | |
126 | this->manager->destinationKey, |
|
125 | this->manager->destinationKey, | |
127 | this->manager->sourceLogicalAddress, |
|
126 | this->manager->sourceLogicalAddress, | |
128 | transactionID, |
|
127 | transactionID, | |
129 | address+(written*4), |
|
128 | address+(written*4), | |
130 | RMAP_MAX_XFER_SIZE*4, |
|
129 | RMAP_MAX_XFER_SIZE*4, | |
131 | writeBuffer+1); |
|
130 | writeBuffer+1); | |
132 | 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); | |
133 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
134 | free(RMAPAckBuff); |
|
133 | free(RMAPAckBuff); | |
135 | written+=RMAP_MAX_XFER_SIZE; |
|
134 | written+=RMAP_MAX_XFER_SIZE; | |
136 | count-=RMAP_MAX_XFER_SIZE; |
|
135 | count-=RMAP_MAX_XFER_SIZE; | |
137 | progress->setValue(written); |
|
136 | progress->setValue(written); | |
138 | qApp->processEvents(); |
|
137 | qApp->processEvents(); | |
139 | } |
|
138 | } | |
140 | if(count>0) |
|
139 | if(count>0) | |
141 | { |
|
140 | { | |
142 | for(int i=0;i<((int)count);i++) |
|
141 | for(int i=0;i<((int)count);i++) | |
143 | { |
|
142 | { | |
144 | 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); | |
145 | 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); | |
146 | 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); | |
147 | 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); | |
148 | } |
|
147 | } | |
149 | transactionID=manager->getRMAPtransactionID(); |
|
148 | transactionID=manager->getRMAPtransactionID(); | |
150 | 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); | |
151 | RMAP_build_tx_request_header( |
|
150 | RMAP_build_tx_request_header( | |
152 | this->manager->destinationLogicalAddress, |
|
151 | this->manager->destinationLogicalAddress, | |
153 | this->manager->destinationKey, |
|
152 | this->manager->destinationKey, | |
154 | this->manager->sourceLogicalAddress, |
|
153 | this->manager->sourceLogicalAddress, | |
155 | transactionID, |
|
154 | transactionID, | |
156 | address+(written*4), |
|
155 | address+(written*4), | |
157 | count*4, |
|
156 | count*4, | |
158 | writeBuffer+1); |
|
157 | writeBuffer+1); | |
159 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
158 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
160 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
159 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
161 | free(RMAPAckBuff); |
|
160 | free(RMAPAckBuff); | |
162 | written+=count; |
|
161 | written+=count; | |
163 | if(progress!=NULL) |
|
162 | if(progress!=NULL) | |
164 | { |
|
163 | { | |
165 | progress->setValue(written); |
|
164 | progress->setValue(written); | |
166 | qApp->processEvents(); |
|
165 | qApp->processEvents(); | |
167 | } |
|
166 | } | |
168 | } |
|
167 | } | |
169 | return written; |
|
168 | return written; | |
170 | } |
|
169 | } | |
171 |
|
170 | |||
172 | 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) | |
173 | { |
|
172 | { | |
174 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
173 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
175 | char* RMAP_AnswerBuffer; |
|
174 | char* RMAP_AnswerBuffer; | |
176 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
175 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
177 | int transactionID = 0; |
|
176 | int transactionID = 0; | |
178 | int read=0; |
|
177 | int read=0; | |
179 | QProgressBar* progress=NULL; |
|
178 | QProgressBar* progress=NULL; | |
180 | SocExplorerAutoProgressBar autopb; |
|
179 | SocExplorerAutoProgressBar autopb; | |
181 | if(count>RMAP_MAX_XFER_SIZE) |
|
180 | if(count>RMAP_MAX_XFER_SIZE) | |
182 | { |
|
181 | { | |
183 | 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); | |
184 | autopb.setProgressBar(progress); |
|
183 | autopb.setProgressBar(progress); | |
185 | } |
|
184 | } | |
186 | 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); | |
187 |
|
186 | |||
188 | //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! | |
189 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
188 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
190 | { |
|
189 | { | |
191 | transactionID = manager->getRMAPtransactionID(); |
|
190 | transactionID = manager->getRMAPtransactionID(); | |
192 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
191 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
193 | RMAP_build_rx_request_header( |
|
192 | RMAP_build_rx_request_header( | |
194 | this->manager->destinationLogicalAddress, |
|
193 | this->manager->destinationLogicalAddress, | |
195 | this->manager->destinationKey, |
|
194 | this->manager->destinationKey, | |
196 | this->manager->sourceLogicalAddress, |
|
195 | this->manager->sourceLogicalAddress, | |
197 | transactionID, |
|
196 | transactionID, | |
198 | address+(read*4), |
|
197 | address+(read*4), | |
199 | RMAP_MAX_XFER_SIZE*4, |
|
198 | RMAP_MAX_XFER_SIZE*4, | |
200 | requestBuffer+1); |
|
199 | requestBuffer+1); | |
201 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
200 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
202 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
201 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
203 | if(len==-1) |
|
202 | if(len==-1) | |
204 | { |
|
203 | { | |
205 | this->toggleBridgeConnection(); |
|
204 | this->toggleBridgeConnection(); | |
206 | return 0; |
|
205 | return 0; | |
207 | } |
|
206 | } | |
208 | for(int i=0;i<((len-13)/4);i++) |
|
207 | for(int i=0;i<((len-13)/4);i++) | |
209 | { |
|
208 | { | |
210 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
209 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
211 | 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])); | |
212 | 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])); | |
213 | 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])); | |
214 | } |
|
213 | } | |
215 | free(RMAP_AnswerBuffer); |
|
214 | free(RMAP_AnswerBuffer); | |
216 | read+=RMAP_MAX_XFER_SIZE; |
|
215 | read+=RMAP_MAX_XFER_SIZE; | |
217 | count-=RMAP_MAX_XFER_SIZE; |
|
216 | count-=RMAP_MAX_XFER_SIZE; | |
218 | if(progress!=NULL) |
|
217 | if(progress!=NULL) | |
219 | { |
|
218 | { | |
220 | progress->setValue(read); |
|
219 | progress->setValue(read); | |
221 | qApp->processEvents(); |
|
220 | qApp->processEvents(); | |
222 | } |
|
221 | } | |
223 | } |
|
222 | } | |
224 | if((int)count>0) |
|
223 | if((int)count>0) | |
225 | { |
|
224 | { | |
226 | transactionID = manager->getRMAPtransactionID(); |
|
225 | transactionID = manager->getRMAPtransactionID(); | |
227 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
226 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
228 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
227 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
229 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
228 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
230 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
229 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
231 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
230 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
232 | RMAP_build_rx_request_header( |
|
231 | RMAP_build_rx_request_header( | |
233 | this->manager->destinationLogicalAddress, |
|
232 | this->manager->destinationLogicalAddress, | |
234 | this->manager->destinationKey, |
|
233 | this->manager->destinationKey, | |
235 | this->manager->sourceLogicalAddress, |
|
234 | this->manager->sourceLogicalAddress, | |
236 | transactionID, |
|
235 | transactionID, | |
237 | address+(read*4), |
|
236 | address+(read*4), | |
238 | count*4, |
|
237 | count*4, | |
239 | requestBuffer+1); |
|
238 | requestBuffer+1); | |
240 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
239 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
241 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
240 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
242 | if(len==-1) |
|
241 | if(len==-1) | |
243 | { |
|
242 | { | |
244 | this->toggleBridgeConnection(); |
|
243 | this->toggleBridgeConnection(); | |
245 | return 0; |
|
244 | return 0; | |
246 | } |
|
245 | } | |
247 | for(int i=0;i<((len-13)/4);i++) |
|
246 | for(int i=0;i<((len-13)/4);i++) | |
248 | { |
|
247 | { | |
249 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
248 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
250 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
249 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
251 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
250 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
252 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
251 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
253 | } |
|
252 | } | |
254 | free(RMAP_AnswerBuffer); |
|
253 | free(RMAP_AnswerBuffer); | |
255 | read+=count; |
|
254 | read+=count; | |
256 | if(progress!=NULL) |
|
255 | if(progress!=NULL) | |
257 | { |
|
256 | { | |
258 | progress->setValue(read); |
|
257 | progress->setValue(read); | |
259 | qApp->processEvents(); |
|
258 | qApp->processEvents(); | |
260 | } |
|
259 | } | |
261 | } |
|
260 | } | |
262 | return read; |
|
261 | return read; | |
263 | } |
|
262 | } | |
264 |
|
263 | |||
265 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
264 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
266 | { |
|
265 | { | |
267 | this->manager->selectedBrick = brickIndex-1; |
|
266 | this->manager->selectedBrick = brickIndex-1; | |
268 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
267 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); | |
269 | } |
|
268 | } | |
270 |
|
269 | |||
271 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
270 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
272 | { |
|
271 | { | |
273 | this->manager->linkNumber = linkIndex + 1; |
|
272 | this->manager->linkNumber = linkIndex + 1; | |
274 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
273 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); | |
275 | } |
|
274 | } | |
276 |
|
275 | |||
277 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
276 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
278 | { |
|
277 | { | |
279 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
278 | this->manager->linkSpeed = linkSpeed.toInt(); | |
280 |
|
279 | |||
281 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
280 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); | |
282 | } |
|
281 | } | |
283 |
|
282 | |||
284 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) |
|
283 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) | |
285 | { |
|
284 | { | |
286 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); |
|
285 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); | |
287 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); |
|
286 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); | |
288 | } |
|
287 | } | |
289 |
|
288 | |||
290 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) |
|
289 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) | |
291 | { |
|
290 | { | |
292 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); |
|
291 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); | |
293 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); |
|
292 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); | |
294 | } |
|
293 | } | |
295 |
|
294 | |||
296 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) |
|
295 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) | |
297 | { |
|
296 | { | |
298 | this->manager->destinationKey = key.toInt(); |
|
297 | this->manager->destinationKey = key.toInt(); | |
299 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); |
|
298 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); | |
300 | } |
|
299 | } | |
301 |
|
300 | |||
302 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) |
|
301 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) | |
303 | { |
|
302 | { | |
304 | this->manager->interfaceMode = interfaceMode; |
|
303 | this->manager->interfaceMode = interfaceMode; | |
305 | } |
|
304 | } | |
306 |
|
305 | |||
307 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) |
|
306 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) | |
308 | { |
|
307 | { | |
309 | this->manager->timecodeFrequency = frequency.toDouble(); |
|
308 | this->manager->timecodeFrequency = frequency.toDouble(); | |
310 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); |
|
309 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); | |
311 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); |
|
310 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); | |
312 | } |
|
311 | } | |
313 |
|
312 | |||
314 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) |
|
313 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) | |
315 | { |
|
314 | { | |
316 | this->manager->sendTimecodePeriodically( onOff ); |
|
315 | this->manager->sendTimecodePeriodically( onOff ); | |
317 | } |
|
316 | } | |
318 |
|
317 | |||
319 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
318 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) | |
320 | { |
|
319 | { | |
321 | int tim=timeout.toInt(); |
|
320 | int tim=timeout.toInt(); | |
322 | if(tim<50) |
|
321 | if(tim<50) | |
323 | { |
|
322 | { | |
324 | tim = 50; |
|
323 | tim = 50; | |
325 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
324 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); | |
326 | } |
|
325 | } | |
327 | this->manager->RMAPtimeout = tim; |
|
326 | this->manager->RMAPtimeout = tim; | |
328 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
327 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); | |
329 | } |
|
328 | } | |
330 |
|
329 | |||
331 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
330 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
332 | { |
|
331 | { | |
333 | Q_UNUSED(parent) |
|
332 | Q_UNUSED(parent) | |
334 | this->p_GUI = new StarDundeeGUI(); |
|
333 | this->p_GUI = new StarDundeeGUI(); | |
335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
334 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
336 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
335 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); |
|
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); | |
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); |
|
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); | |
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); | |
344 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); |
|
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); | |
345 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); |
|
344 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); | |
346 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); |
|
345 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); | |
347 |
|
346 | |||
348 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
347 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
349 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
348 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
350 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
349 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
351 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); |
|
350 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); | |
352 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); |
|
351 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); | |
353 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); |
|
352 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
354 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); |
|
353 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
355 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); |
|
354 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |
356 |
|
355 | |||
357 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
356 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
358 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
357 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
359 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); |
|
358 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
360 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); |
|
359 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
361 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); |
|
360 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); | |
362 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); |
|
361 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); | |
363 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); |
|
362 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
364 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); |
|
363 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |
365 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); |
|
364 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); | |
366 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), |
|
365 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), | |
367 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); |
|
366 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); | |
368 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); |
|
367 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |
369 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); |
|
368 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |
370 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); |
|
369 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |
371 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); |
|
370 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |
372 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); |
|
371 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); | |
373 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); |
|
372 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); | |
374 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); |
|
373 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); | |
375 |
|
374 | |||
376 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); |
|
375 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); | |
377 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); |
|
376 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); | |
378 | } |
|
377 | } | |
379 |
|
378 | |||
380 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) |
|
379 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) | |
381 | { |
|
380 | { | |
382 | char* data; |
|
381 | char* data; | |
383 | int i; |
|
382 | int i; | |
384 |
|
383 | |||
385 | data = (char *) malloc( size + 5 ); |
|
384 | data = (char *) malloc( size + 5 ); | |
386 |
|
385 | |||
387 | data[0] = this->manager->linkNumber; |
|
386 | data[0] = this->manager->linkNumber; | |
388 | data[1] = this->manager->destinationLogicalAddress; // target logical address |
|
387 | data[1] = this->manager->destinationLogicalAddress; // target logical address | |
389 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier |
|
388 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier | |
390 | data[3] = 0x00; // reserved |
|
389 | data[3] = 0x00; // reserved | |
391 | data[4] = 0x00; // user application |
|
390 | data[4] = 0x00; // user application | |
392 |
|
391 | |||
393 | for ( i=0; i<size; i++ ) |
|
392 | for ( i=0; i<size; i++ ) | |
394 | { |
|
393 | { | |
395 | data[i+5] = packet[i]; |
|
394 | data[i+5] = packet[i]; | |
396 | } |
|
395 | } | |
397 |
|
396 | |||
398 | this->manager->sendPacket( data, size + 5); |
|
397 | this->manager->sendPacket( data, size + 5); | |
399 |
|
398 | |||
400 | free(data); |
|
399 | free(data); | |
401 | free(packet); |
|
400 | free(packet); | |
402 | } |
|
401 | } | |
403 |
|
402 | |||
404 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
403 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
405 | :abstractSpwManager(plugin, parent) |
|
404 | :abstractSpwManager(plugin, parent) | |
406 | { |
|
405 | { | |
407 | // TODO remove this crap! |
|
406 | // TODO remove this crap! | |
408 | this->initDialog(); |
|
407 | this->initDialog(); | |
409 | // this->moveToThread(this); |
|
408 | // this->moveToThread(this); | |
410 | } |
|
409 | } | |
411 |
|
410 | |||
412 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
411 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
413 | { |
|
412 | { | |
|
413 | if(this->connected)disconnectBridge(); | |||
|
414 | this->requestInterruption(); | |||
|
415 | while(!this->isFinished()); | |||
414 | } |
|
416 | } | |
415 |
|
417 | |||
416 | void stardundeeSPW_USB_Manager::run() |
|
418 | void stardundeeSPW_USB_Manager::run() | |
417 | { |
|
419 | { | |
418 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
420 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
419 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
421 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
420 | USB_SPACEWIRE_STATUS stat; |
|
422 | USB_SPACEWIRE_STATUS stat; | |
421 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
423 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
422 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
424 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
423 |
while (! |
|
425 | while (!QThread::currentThread()->isInterruptionRequested()) | |
424 | { |
|
426 | { | |
425 | if(this->connected) |
|
427 | if(this->connected) | |
426 | { |
|
428 | { | |
427 | this->handleMutex->lock(); |
|
429 | this->handleMutex->lock(); | |
428 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
430 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
429 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
431 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
430 | { |
|
432 | { | |
431 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
433 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
432 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
434 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
433 | if (stat == TRANSFER_SUCCESS) |
|
435 | if (stat == TRANSFER_SUCCESS) | |
434 | { |
|
436 | { | |
435 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
437 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
436 | { |
|
438 | { | |
437 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
439 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
438 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
440 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
439 | { |
|
441 | { | |
440 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
442 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); | |
441 | emit bytesReceivedFromSpw( properties.len ); |
|
443 | emit bytesReceivedFromSpw( properties.len ); | |
442 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
444 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
443 | { |
|
445 | { | |
444 | RMAP_Answer* packet; |
|
446 | RMAP_Answer* packet; | |
445 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
447 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
446 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
448 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
447 | char* packetbuffer = (char*)malloc(properties.len); |
|
449 | char* packetbuffer = (char*)malloc(properties.len); | |
448 | memcpy(packetbuffer,buffer,properties.len); |
|
450 | memcpy(packetbuffer,buffer,properties.len); | |
449 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
451 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
450 | pIdentifier = NULL; |
|
452 | pIdentifier = NULL; | |
451 | this->handleMutex->unlock(); |
|
453 | this->handleMutex->unlock(); | |
452 | if(properties.len==8) |
|
454 | if(properties.len==8) | |
453 | { |
|
455 | { | |
454 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
456 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); | |
455 | } |
|
457 | } | |
456 | else |
|
458 | else | |
457 | { |
|
459 | { | |
458 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
460 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
459 | } |
|
461 | } | |
460 | RMAP_AnswersMtx->lock(); |
|
462 | RMAP_AnswersMtx->lock(); | |
461 | RMAP_Answers.append(packet); |
|
463 | RMAP_Answers.append(packet); | |
462 | RMAP_AnswersMtx->unlock(); |
|
464 | RMAP_AnswersMtx->unlock(); | |
463 | RMAP_AnswersSem->release(); |
|
465 | RMAP_AnswersSem->release(); | |
464 | } |
|
466 | } | |
465 | else //any non-rmap packet will be pushed to the network |
|
467 | else //any non-rmap packet will be pushed to the network | |
466 | { |
|
468 | { | |
467 | char* packetbuffer = (char*)malloc(properties.len); |
|
469 | char* packetbuffer = (char*)malloc(properties.len); | |
468 | memcpy(packetbuffer,buffer,properties.len); |
|
470 | memcpy(packetbuffer,buffer,properties.len); | |
469 | emit emitPacket(packetbuffer,properties.len); |
|
471 | emit emitPacket(packetbuffer,properties.len); | |
470 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
472 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
471 | this->handleMutex->unlock(); |
|
473 | this->handleMutex->unlock(); | |
472 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
474 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
473 | } |
|
475 | } | |
474 | } |
|
476 | } | |
475 | else |
|
477 | else | |
476 | { |
|
478 | { | |
477 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
479 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
478 | this->handleMutex->unlock(); |
|
480 | this->handleMutex->unlock(); | |
479 | } |
|
481 | } | |
480 | } |
|
482 | } | |
481 |
|
483 | |||
482 | } |
|
484 | } | |
483 | else |
|
485 | else | |
484 | { |
|
486 | { | |
485 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
487 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
486 | this->handleMutex->unlock(); |
|
488 | this->handleMutex->unlock(); | |
487 | } |
|
489 | } | |
488 | } |
|
490 | } | |
489 | else |
|
491 | else | |
490 | { |
|
492 | { | |
491 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
493 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
492 | this->handleMutex->unlock(); |
|
494 | this->handleMutex->unlock(); | |
493 | } |
|
495 | } | |
494 | } |
|
496 | } | |
495 | else |
|
497 | else | |
496 | { |
|
498 | { | |
497 | //do some sanity checks! |
|
499 | //do some sanity checks! | |
498 | int list = USBSpaceWire_ListDevices(); |
|
500 | int list = USBSpaceWire_ListDevices(); | |
499 | if(this->brickList!=list) |
|
501 | if(this->brickList!=list) | |
500 | { |
|
502 | { | |
501 | this->brickList = list; |
|
503 | this->brickList = list; | |
502 | emit updateAvailableBrickCount(this->brickList); |
|
504 | emit updateAvailableBrickCount(this->brickList); | |
503 | } |
|
505 | } | |
504 | usleep(RMAPtimeout/2); |
|
506 | usleep(RMAPtimeout/2); | |
505 | } |
|
507 | } | |
506 | usleep(1000); |
|
508 | usleep(1000); | |
507 | } |
|
509 | } | |
508 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
510 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
509 | } |
|
511 | } | |
510 |
|
512 | |||
511 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
513 | bool stardundeeSPW_USB_Manager::connectBridge() | |
512 | { |
|
514 | { | |
513 | bool ret; |
|
515 | bool ret; | |
514 |
|
516 | |||
515 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) |
|
517 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) | |
516 | { |
|
518 | { | |
517 | ret = connectBridgeAsInterface(); |
|
519 | ret = connectBridgeAsInterface(); | |
518 | } |
|
520 | } | |
519 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) |
|
521 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) | |
520 | { |
|
522 | { | |
521 | ret = connectBridgeAsRouter(); |
|
523 | ret = connectBridgeAsRouter(); | |
522 | } |
|
524 | } | |
523 | else |
|
525 | else | |
524 | { |
|
526 | { | |
525 | ret = false; |
|
527 | ret = false; | |
526 | } |
|
528 | } | |
527 |
|
529 | |||
528 | return ret; |
|
530 | return ret; | |
529 | } |
|
531 | } | |
530 |
|
532 | |||
531 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() |
|
533 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() | |
532 | { |
|
534 | { | |
533 | this->handleMutex->lock(); |
|
535 | this->handleMutex->lock(); | |
534 | int status; |
|
536 | int status; | |
535 | U32 statusControl; |
|
537 | U32 statusControl; | |
536 | this->connected = false; |
|
538 | this->connected = false; | |
537 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
539 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
538 | { |
|
540 | { | |
539 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
541 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
540 | this->handleMutex->unlock(); |
|
542 | this->handleMutex->unlock(); | |
541 | return false; |
|
543 | return false; | |
542 | } |
|
544 | } | |
543 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
545 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
544 |
|
546 | |||
545 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
547 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
546 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
548 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
547 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
549 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
548 |
|
550 | |||
549 | // Set the path and return path to the device |
|
551 | // Set the path and return path to the device | |
550 | CFGSpaceWire_StackClear(); |
|
552 | CFGSpaceWire_StackClear(); | |
551 | CFGSpaceWire_AddrStackPush(0); |
|
553 | CFGSpaceWire_AddrStackPush(0); | |
552 | CFGSpaceWire_AddrStackPush(254); |
|
554 | CFGSpaceWire_AddrStackPush(254); | |
553 | CFGSpaceWire_RetAddrStackPush(254); |
|
555 | CFGSpaceWire_RetAddrStackPush(254); | |
554 | // set the base transmit rate to 100 MHz |
|
556 | // set the base transmit rate to 100 MHz | |
555 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
557 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
556 | if (status != CFG_TRANSFER_SUCCESS) |
|
558 | if (status != CFG_TRANSFER_SUCCESS) | |
557 | { |
|
559 | { | |
558 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
560 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
559 | this->handleMutex->unlock(); |
|
561 | this->handleMutex->unlock(); | |
560 | return false; |
|
562 | return false; | |
561 | } |
|
563 | } | |
562 | else |
|
564 | else | |
563 | { |
|
565 | { | |
564 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
566 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
565 | } |
|
567 | } | |
566 |
|
568 | |||
567 | // read the link status |
|
569 | // read the link status | |
568 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
570 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
569 | { |
|
571 | { | |
570 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
572 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
571 | this->handleMutex->unlock(); |
|
573 | this->handleMutex->unlock(); | |
572 | return false; |
|
574 | return false; | |
573 | } |
|
575 | } | |
574 | else |
|
576 | else | |
575 | { |
|
577 | { | |
576 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
578 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
577 |
|
579 | |||
578 | // Set the link status control register properties |
|
580 | // Set the link status control register properties | |
579 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
581 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
580 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
582 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
581 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
583 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
582 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
584 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
583 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
585 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
584 |
|
586 | |||
585 | // Set the link status control register |
|
587 | // Set the link status control register | |
586 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
588 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
587 | { |
|
589 | { | |
588 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
590 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
589 | this->handleMutex->unlock(); |
|
591 | this->handleMutex->unlock(); | |
590 | return false; |
|
592 | return false; | |
591 | } |
|
593 | } | |
592 | else |
|
594 | else | |
593 | { |
|
595 | { | |
594 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
596 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
595 | } |
|
597 | } | |
596 | } |
|
598 | } | |
597 |
|
599 | |||
598 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
600 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
599 | { |
|
601 | { | |
600 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
602 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
601 | this->handleMutex->unlock(); |
|
603 | this->handleMutex->unlock(); | |
602 | return false; |
|
604 | return false; | |
603 | } |
|
605 | } | |
604 | else |
|
606 | else | |
605 | { |
|
607 | { | |
606 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
608 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
607 | } |
|
609 | } | |
608 |
|
610 | |||
609 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
611 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
610 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
612 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
611 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
613 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
612 | this->handleMutex->unlock(); |
|
614 | this->handleMutex->unlock(); | |
613 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
615 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
614 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
616 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
615 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
617 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
616 | this->connected = true; |
|
618 | this->connected = true; | |
617 | return true; |
|
619 | return true; | |
618 | } |
|
620 | } | |
619 |
|
621 | |||
620 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() |
|
622 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() | |
621 | { |
|
623 | { | |
622 | // QMutexLocker mlock(&this->handleMutex); |
|
624 | // QMutexLocker mlock(&this->handleMutex); | |
623 | this->handleMutex->lock(); |
|
625 | this->handleMutex->lock(); | |
624 | int status; |
|
626 | int status; | |
625 | U32 statusControl; |
|
627 | U32 statusControl; | |
626 | unsigned int linkStatus1; |
|
628 | unsigned int linkStatus1; | |
627 | unsigned int linkStatus2; |
|
629 | unsigned int linkStatus2; | |
628 | unsigned char linkNumber; |
|
630 | unsigned char linkNumber; | |
629 | unsigned char deviceIsAnInterface; |
|
631 | unsigned char deviceIsAnInterface; | |
630 |
|
632 | |||
631 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
633 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
632 | { |
|
634 | { | |
633 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); |
|
635 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |
634 | this->handleMutex->unlock(); |
|
636 | this->handleMutex->unlock(); | |
635 | return false; |
|
637 | return false; | |
636 | } |
|
638 | } | |
637 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " |
|
639 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " | |
638 | + QString::number(this->selectedBrick)); |
|
640 | + QString::number(this->selectedBrick)); | |
639 |
|
641 | |||
640 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
642 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
641 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
643 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
642 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
644 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
643 |
|
645 | |||
644 | // Set the path and return path to the device |
|
646 | // Set the path and return path to the device | |
645 | // This affects just the operations performed by the Configuration Library and does not affect the packets |
|
647 | // This affects just the operations performed by the Configuration Library and does not affect the packets | |
646 | // sent and received using the driver API. |
|
648 | // sent and received using the driver API. | |
647 | CFGSpaceWire_StackClear(); |
|
649 | CFGSpaceWire_StackClear(); | |
648 | CFGSpaceWire_AddrStackPush(0); |
|
650 | CFGSpaceWire_AddrStackPush(0); | |
649 | CFGSpaceWire_AddrStackPush(254); |
|
651 | CFGSpaceWire_AddrStackPush(254); | |
650 | CFGSpaceWire_RetAddrStackPush(254); |
|
652 | CFGSpaceWire_RetAddrStackPush(254); | |
651 |
|
653 | |||
652 | // set the base transmit rate to 100 MHz |
|
654 | // set the base transmit rate to 100 MHz | |
653 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
655 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
654 | if (status != CFG_TRANSFER_SUCCESS) |
|
656 | if (status != CFG_TRANSFER_SUCCESS) | |
655 | { |
|
657 | { | |
656 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); |
|
658 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |
657 | } |
|
659 | } | |
658 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); |
|
660 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |
659 |
|
661 | |||
660 | //********************* |
|
662 | //********************* | |
661 | // LINK 1 CONFIGURATION |
|
663 | // LINK 1 CONFIGURATION | |
662 | linkNumber = 1; |
|
664 | linkNumber = 1; | |
663 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
665 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
664 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
666 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
665 | else |
|
667 | else | |
666 | { |
|
668 | { | |
667 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
669 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
668 |
|
670 | |||
669 | // Set the link status control register properties |
|
671 | // Set the link status control register properties | |
670 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
672 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
671 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
673 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
672 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
674 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
673 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
675 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
674 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
676 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
675 |
|
677 | |||
676 | // Set the link status control register |
|
678 | // Set the link status control register | |
677 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
679 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
678 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
680 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
679 | else |
|
681 | else | |
680 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); |
|
682 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); | |
681 | } |
|
683 | } | |
682 |
|
684 | |||
683 | //********************* |
|
685 | //********************* | |
684 | // LINK 2 CONFIGURATION |
|
686 | // LINK 2 CONFIGURATION | |
685 | linkNumber = 2; |
|
687 | linkNumber = 2; | |
686 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
688 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
687 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
689 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
688 | else |
|
690 | else | |
689 | { |
|
691 | { | |
690 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
692 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
691 |
|
693 | |||
692 | // Set the link status control register properties |
|
694 | // Set the link status control register properties | |
693 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
695 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
694 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
696 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
695 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
697 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
696 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
698 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
697 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
699 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
698 |
|
700 | |||
699 | // Set the link status control register |
|
701 | // Set the link status control register | |
700 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
702 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
701 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
703 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
702 | else |
|
704 | else | |
703 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); |
|
705 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); | |
704 | } |
|
706 | } | |
705 |
|
707 | |||
706 | //*************************** |
|
708 | //*************************** | |
707 | // SET THE DEVICE AS A ROUTER |
|
709 | // SET THE DEVICE AS A ROUTER | |
708 | deviceIsAnInterface = 0; // 0 = router, 1 = interface |
|
710 | deviceIsAnInterface = 0; // 0 = router, 1 = interface | |
709 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) |
|
711 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) | |
710 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); |
|
712 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); | |
711 | else |
|
713 | else | |
712 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); |
|
714 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); | |
713 |
|
715 | |||
714 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 |
|
716 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 | |
715 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 |
|
717 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 | |
716 |
|
718 | |||
717 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only |
|
719 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only | |
718 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
720 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
719 |
|
721 | |||
720 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); |
|
722 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |
721 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); |
|
723 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |
722 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); |
|
724 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |
723 |
|
725 | |||
724 | //************ |
|
726 | //************ | |
725 | // test Link 1 and Link 2 |
|
727 | // test Link 1 and Link 2 | |
726 | linkStatus1 = getLinkStatus(0x01); |
|
728 | linkStatus1 = getLinkStatus(0x01); | |
727 | linkStatus2 = getLinkStatus(0x02); |
|
729 | linkStatus2 = getLinkStatus(0x02); | |
728 | this->handleMutex->unlock(); |
|
730 | this->handleMutex->unlock(); | |
729 |
|
731 | |||
730 | if ((linkStatus1==1) || (linkStatus2==1)) |
|
732 | if ((linkStatus1==1) || (linkStatus2==1)) | |
731 | { |
|
733 | { | |
732 | initializeTimecodeGeneration(); |
|
734 | initializeTimecodeGeneration(); | |
733 | this->connected=true; |
|
735 | this->connected=true; | |
734 | return true; |
|
736 | return true; | |
735 | } |
|
737 | } | |
736 | else |
|
738 | else | |
737 | { |
|
739 | { | |
738 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
740 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |
739 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
741 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |
740 | starDundeeStatusQueryDialog->exec(); |
|
742 | starDundeeStatusQueryDialog->exec(); | |
741 | this->connected = false; |
|
743 | this->connected = false; | |
742 | return false; |
|
744 | return false; | |
743 | } |
|
745 | } | |
744 | } |
|
746 | } | |
745 |
|
747 | |||
746 | void stardundeeSPW_USB_Manager::initDialog( void ) |
|
748 | void stardundeeSPW_USB_Manager::initDialog( void ) | |
747 | { |
|
749 | { | |
748 | // STAR DUNDEE STATUS QUERY DIALOG |
|
750 | // STAR DUNDEE STATUS QUERY DIALOG | |
749 | starDundeeStatusQueryDialog = new QDialog; |
|
751 | starDundeeStatusQueryDialog = new QDialog; | |
750 | starDundeeStatusQueryDialogLayout = new QGridLayout; |
|
752 | starDundeeStatusQueryDialogLayout = new QGridLayout; | |
751 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); |
|
753 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); | |
752 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); |
|
754 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); | |
753 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); |
|
755 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); | |
754 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); |
|
756 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); | |
755 | statusLink1 = new QLabel(tr("Link 1 status code: -")); |
|
757 | statusLink1 = new QLabel(tr("Link 1 status code: -")); | |
756 | statusLink2 = new QLabel(tr("Link 2 status code: -")); |
|
758 | statusLink2 = new QLabel(tr("Link 2 status code: -")); | |
757 |
|
759 | |||
758 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); |
|
760 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); | |
759 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); |
|
761 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); | |
760 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); |
|
762 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); | |
761 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); |
|
763 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); | |
762 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); |
|
764 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); | |
763 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); |
|
765 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); | |
764 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); |
|
766 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); | |
765 | } |
|
767 | } | |
766 |
|
768 | |||
767 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) |
|
769 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) | |
768 | { |
|
770 | { | |
769 | U32 routingTableEntry; |
|
771 | U32 routingTableEntry; | |
770 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber |
|
772 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber | |
771 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) |
|
773 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) | |
772 | { |
|
774 | { | |
773 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); |
|
775 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); | |
774 | } |
|
776 | } | |
775 | // Build the routing table entry |
|
777 | // Build the routing table entry | |
776 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, |
|
778 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, | |
777 | dwOutputPorts, // route out of port dwOutputPorts |
|
779 | dwOutputPorts, // route out of port dwOutputPorts | |
778 | bDelHead, // header deletion is enabled [1] or disabled [0] |
|
780 | bDelHead, // header deletion is enabled [1] or disabled [0] | |
779 | 0); // priority normal |
|
781 | 0); // priority normal | |
780 | // Set the routing table entry for logical address tableEntry |
|
782 | // Set the routing table entry for logical address tableEntry | |
781 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
783 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
782 | { |
|
784 | { | |
783 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); |
|
785 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); | |
784 | } |
|
786 | } | |
785 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); |
|
787 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); | |
786 | return 1; |
|
788 | return 1; | |
787 | } |
|
789 | } | |
788 |
|
790 | |||
789 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) |
|
791 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) | |
790 | { |
|
792 | { | |
791 | U32 routingTableEntry, outputPorts; |
|
793 | U32 routingTableEntry, outputPorts; | |
792 | char enabled, delHead, priority; |
|
794 | char enabled, delHead, priority; | |
793 | int portNum; |
|
795 | int portNum; | |
794 |
|
796 | |||
795 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); |
|
797 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); | |
796 | // Read the routing table entry |
|
798 | // Read the routing table entry | |
797 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
799 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
798 | { |
|
800 | { | |
799 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); |
|
801 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); | |
800 | } |
|
802 | } | |
801 | else |
|
803 | else | |
802 | { |
|
804 | { | |
803 | // Display the routing table entry properties |
|
805 | // Display the routing table entry properties | |
804 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); |
|
806 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); | |
805 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); |
|
807 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); | |
806 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); |
|
808 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); | |
807 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); |
|
809 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); | |
808 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); |
|
810 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); | |
809 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); |
|
811 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); | |
810 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); |
|
812 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); | |
811 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); |
|
813 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); | |
812 | for (portNum = 0; portNum < 32; portNum++) |
|
814 | for (portNum = 0; portNum < 32; portNum++) | |
813 | { |
|
815 | { | |
814 | if (outputPorts & (1 << portNum)) |
|
816 | if (outputPorts & (1 << portNum)) | |
815 | { |
|
817 | { | |
816 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); |
|
818 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); | |
817 | } |
|
819 | } | |
818 | } |
|
820 | } | |
819 | } |
|
821 | } | |
820 |
|
822 | |||
821 | return 1; |
|
823 | return 1; | |
822 | } |
|
824 | } | |
823 |
|
825 | |||
824 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() |
|
826 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() | |
825 | { |
|
827 | { | |
826 | U32 dwTickEnableStatus; |
|
828 | U32 dwTickEnableStatus; | |
827 | U32 rtr_clk_freq; |
|
829 | U32 rtr_clk_freq; | |
828 |
|
830 | |||
829 | // (1) RESET |
|
831 | // (1) RESET | |
830 | if (!USBSpaceWire_TC_Reset(hDevice)) |
|
832 | if (!USBSpaceWire_TC_Reset(hDevice)) | |
831 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); |
|
833 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); | |
832 |
|
834 | |||
833 | // (2) Clear the tick enable register |
|
835 | // (2) Clear the tick enable register | |
834 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) |
|
836 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) | |
835 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); |
|
837 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); | |
836 | else |
|
838 | else | |
837 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); |
|
839 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); | |
838 |
|
840 | |||
839 | // (3) get the tick status |
|
841 | // (3) get the tick status | |
840 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); |
|
842 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); | |
841 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); |
|
843 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); | |
842 |
|
844 | |||
843 | // (4) enable external timecode selection |
|
845 | // (4) enable external timecode selection | |
844 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
846 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
845 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); |
|
847 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); | |
846 |
|
848 | |||
847 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
849 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
848 |
|
850 | |||
849 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); |
|
851 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); | |
850 |
|
852 | |||
851 | //************************************************** |
|
853 | //************************************************** | |
852 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
854 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
853 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) |
|
855 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) | |
854 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
856 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
855 | } |
|
857 | } | |
856 |
|
858 | |||
857 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) |
|
859 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) | |
858 | { |
|
860 | { | |
859 | U32 statusControl, errorStatus, portType; |
|
861 | U32 statusControl, errorStatus, portType; | |
860 | U32 linkStatus=0, operatingSpeed, outputPortConnection; |
|
862 | U32 linkStatus=0, operatingSpeed, outputPortConnection; | |
861 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; |
|
863 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; | |
862 |
|
864 | |||
863 | // Read the link status control register |
|
865 | // Read the link status control register | |
864 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
866 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) | |
865 | { |
|
867 | { | |
866 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); |
|
868 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); | |
867 | } |
|
869 | } | |
868 | else |
|
870 | else | |
869 | { |
|
871 | { | |
870 | // Display the link status control register properties |
|
872 | // Display the link status control register properties | |
871 | CFGSpaceWire_LSPortType(statusControl, &portType); |
|
873 | CFGSpaceWire_LSPortType(statusControl, &portType); | |
872 | if (portType == CFG_CONFIGURATION_PORT) |
|
874 | if (portType == CFG_CONFIGURATION_PORT) | |
873 | { |
|
875 | { | |
874 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); |
|
876 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); | |
875 | } |
|
877 | } | |
876 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) |
|
878 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) | |
877 | { |
|
879 | { | |
878 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); |
|
880 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); | |
879 | } |
|
881 | } | |
880 | else |
|
882 | else | |
881 | { |
|
883 | { | |
882 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); |
|
884 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); | |
883 | } |
|
885 | } | |
884 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); |
|
886 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); | |
885 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); |
|
887 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); | |
886 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); |
|
888 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); | |
887 | CFGSpaceWire_LSIsStart(statusControl, &isStart); |
|
889 | CFGSpaceWire_LSIsStart(statusControl, &isStart); | |
888 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); |
|
890 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); | |
889 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); |
|
891 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); | |
890 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); |
|
892 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); | |
891 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); |
|
893 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); | |
892 | } |
|
894 | } | |
893 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) |
|
895 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) | |
894 | +" is " + dwLinkStatusQString[linkStatus]); |
|
896 | +" is " + dwLinkStatusQString[linkStatus]); | |
895 | if (linkStatus == 5) |
|
897 | if (linkStatus == 5) | |
896 | { |
|
898 | { | |
897 | return 1; |
|
899 | return 1; | |
898 | } |
|
900 | } | |
899 | else return 0; |
|
901 | else return 0; | |
900 | } |
|
902 | } | |
901 |
|
903 | |||
902 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
904 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
903 | { |
|
905 | { | |
904 | this->handleMutex->lock(); |
|
906 | this->handleMutex->lock(); | |
905 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
907 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
906 | USBSpaceWire_Close(hDevice); // Close the device |
|
908 | USBSpaceWire_Close(hDevice); // Close the device | |
907 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
909 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
908 | this->handleMutex->unlock(); |
|
910 | this->handleMutex->unlock(); | |
909 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
911 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
910 | this->RMAP_pending_transaction_IDs.clear(); |
|
912 | this->RMAP_pending_transaction_IDs.clear(); | |
911 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
913 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
912 | this->RMAP_AnswersMtx->lock(); |
|
914 | this->RMAP_AnswersMtx->lock(); | |
913 | this->RMAP_Answers.clear(); |
|
915 | this->RMAP_Answers.clear(); | |
914 | this->RMAP_AnswersMtx->unlock(); |
|
916 | this->RMAP_AnswersMtx->unlock(); | |
915 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
917 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
|
918 | this->connected=false; | |||
916 | return true; |
|
919 | return true; | |
917 | } |
|
920 | } | |
918 |
|
921 | |||
919 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
922 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
920 | { |
|
923 | { | |
921 | char protocoleIdentifier; |
|
924 | char protocoleIdentifier; | |
922 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; |
|
925 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; | |
923 | USB_SPACEWIRE_ID pIdentifier; |
|
926 | USB_SPACEWIRE_ID pIdentifier; | |
924 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
927 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
925 | this->handleMutex->lock(); |
|
928 | this->handleMutex->lock(); | |
926 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
929 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
927 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
930 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
928 | this->handleMutex->unlock(); |
|
931 | this->handleMutex->unlock(); | |
929 | if (result != TRANSFER_SUCCESS) |
|
932 | if (result != TRANSFER_SUCCESS) | |
930 | { |
|
933 | { | |
931 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
934 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
932 | return false; |
|
935 | return false; | |
933 | } |
|
936 | } | |
934 | else |
|
937 | else | |
935 | { |
|
938 | { | |
936 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link |
|
939 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link | |
937 | // read the protocole identifier |
|
940 | // read the protocole identifier | |
938 | protocoleIdentifier = packet[2]; |
|
941 | protocoleIdentifier = packet[2]; | |
939 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) |
|
942 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) | |
940 | emit ccsdsPacketTransmittedToSpw(); |
|
943 | emit ccsdsPacketTransmittedToSpw(); | |
941 |
|
944 | |||
942 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
945 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
943 | } |
|
946 | } | |
944 | return true; |
|
947 | return true; | |
945 | } |
|
948 | } | |
946 |
|
949 | |||
947 |
|
950 | |||
948 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) |
|
951 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) | |
949 | { |
|
952 | { | |
950 | this->handleMutex->lock(); |
|
953 | this->handleMutex->lock(); | |
951 | if (onOff == true) |
|
954 | if (onOff == true) | |
952 | { |
|
955 | { | |
953 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) |
|
956 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |
954 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); |
|
957 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); | |
955 | } |
|
958 | } | |
956 | else |
|
959 | else | |
957 | { |
|
960 | { | |
958 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) |
|
961 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |
959 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); |
|
962 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); | |
960 | } |
|
963 | } | |
961 | this->handleMutex->unlock(); |
|
964 | this->handleMutex->unlock(); | |
962 | } |
|
965 | } | |
963 |
|
966 | |||
964 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) |
|
967 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) | |
965 | { |
|
968 | { | |
966 | return this->linkNumber; |
|
969 | return this->linkNumber; | |
967 | } |
|
970 | } | |
968 |
|
971 | |||
969 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) |
|
972 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) | |
970 | { |
|
973 | { | |
971 | U32 rtr_clk_freq=0; |
|
974 | U32 rtr_clk_freq=0; | |
972 | U32 freqCount=0; |
|
975 | U32 freqCount=0; | |
973 | double freqCountInDouble=0.0; |
|
976 | double freqCountInDouble=0.0; | |
974 | double currentFrequency=0.0; |
|
977 | double currentFrequency=0.0; | |
975 |
|
978 | |||
976 | this->handleMutex->lock(); |
|
979 | this->handleMutex->lock(); | |
977 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
980 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
978 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; |
|
981 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; | |
979 | freqCount = (unsigned int) freqCountInDouble; |
|
982 | freqCount = (unsigned int) freqCountInDouble; | |
980 |
|
983 | |||
981 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); |
|
984 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); | |
982 |
|
985 | |||
983 | //************************************************** |
|
986 | //************************************************** | |
984 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
987 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
985 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) |
|
988 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) | |
986 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
989 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
987 | else |
|
990 | else | |
988 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" |
|
991 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" | |
989 | + " (freqCount set to " + QString::number(freqCount) + ")" ); |
|
992 | + " (freqCount set to " + QString::number(freqCount) + ")" ); | |
990 | this->handleMutex->unlock(); |
|
993 | this->handleMutex->unlock(); | |
991 | } |
|
994 | } | |
992 |
|
995 | |||
993 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) |
|
996 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) | |
994 | { |
|
997 | { | |
995 | this->handleMutex->lock(); |
|
998 | this->handleMutex->lock(); | |
996 | // enable external timecode selection |
|
999 | // enable external timecode selection | |
997 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) |
|
1000 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) | |
998 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); |
|
1001 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); | |
999 |
|
1002 | |||
1000 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) |
|
1003 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) | |
1001 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); |
|
1004 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); | |
1002 | else |
|
1005 | else | |
1003 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); |
|
1006 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); | |
1004 |
|
1007 | |||
1005 | // disable external timecode selection |
|
1008 | // disable external timecode selection | |
1006 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
1009 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
1007 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); |
|
1010 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); | |
1008 | this->handleMutex->unlock(); |
|
1011 | this->handleMutex->unlock(); | |
1009 | } |
|
1012 | } | |
1010 |
|
1013 | |||
1011 |
|
1014 |
@@ -1,149 +1,149 | |||||
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 STARDUNDEESPW_USB_H |
|
22 | #ifndef STARDUNDEESPW_USB_H | |
23 | #define STARDUNDEESPW_USB_H |
|
23 | #define STARDUNDEESPW_USB_H | |
24 |
|
24 | |||
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | //#include <spw_usb_api.h> |
|
26 | //#include <spw_usb_api.h> | |
27 | //#include <spw_config_library.h> |
|
27 | //#include <spw_config_library.h> | |
28 |
|
28 | |||
29 | #include "fakestardundeespwusb_lib.h" |
|
29 | #include "fakestardundeespwusb_lib.h" | |
30 | #include <socexplorerplugin.h> |
|
30 | #include <socexplorerplugin.h> | |
31 | #include <abstractspwbridge.h> |
|
31 | #include <abstractspwbridge.h> | |
32 | #include <QThread> |
|
32 | #include <QThread> | |
33 | #include <QMutex> |
|
33 | #include <QMutex> | |
34 | #include <QSemaphore> |
|
34 | #include <QSemaphore> | |
35 | #include <QGridLayout> |
|
35 | #include <QGridLayout> | |
36 | #include <QPushButton> |
|
36 | #include <QPushButton> | |
37 | #include <QComboBox> |
|
37 | #include <QComboBox> | |
38 | #include <QLabel> |
|
38 | #include <QLabel> | |
39 | #include "stardundeegui.h" |
|
39 | #include "stardundeegui.h" | |
40 |
|
40 | |||
41 | #define BRICK_IS_SET_AS_AN_INTERFACE true |
|
41 | #define BRICK_IS_SET_AS_AN_INTERFACE true | |
42 | #define BRICK_IS_SET_AS_A_ROUTER false |
|
42 | #define BRICK_IS_SET_AS_A_ROUTER false | |
43 |
|
43 | |||
44 | class stardundeeSPW_USB_Manager: public abstractSpwManager |
|
44 | class stardundeeSPW_USB_Manager: public abstractSpwManager | |
45 | { |
|
45 | { | |
46 | Q_OBJECT |
|
46 | Q_OBJECT | |
47 | public: |
|
47 | public: | |
48 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
48 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
49 | ~stardundeeSPW_USB_Manager(); |
|
49 | ~stardundeeSPW_USB_Manager(); | |
50 | void run(); |
|
50 | virtual void run(); | |
51 | bool connectBridge(); |
|
51 | virtual bool connectBridge(); | |
52 | bool connectBridgeAsInterface(); |
|
52 | bool connectBridgeAsInterface(); | |
53 | bool connectBridgeAsRouter(); |
|
53 | bool connectBridgeAsRouter(); | |
54 | void initDialog( void ); |
|
54 | void initDialog( void ); | |
55 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); |
|
55 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); | |
56 | unsigned int getRoutingTableEntry(int tableEntry); |
|
56 | unsigned int getRoutingTableEntry(int tableEntry); | |
57 | void initializeTimecodeGeneration(); |
|
57 | void initializeTimecodeGeneration(); | |
58 | void setTimecodeFrequency(double requestedFrequency); |
|
58 | void setTimecodeFrequency(double requestedFrequency); | |
59 | unsigned int getLinkStatus(unsigned char link); |
|
59 | unsigned int getLinkStatus(unsigned char link); | |
60 | bool disconnectBridge(); |
|
60 | virtual bool disconnectBridge(); | |
61 | bool sendPacket(char* packet,int size); |
|
61 | virtual bool sendPacket(char* packet,int size); | |
62 |
|
62 | |||
63 | signals: |
|
63 | signals: | |
64 | void updateAvailableBrickCount(int count); |
|
64 | void updateAvailableBrickCount(int count); | |
65 | void emitPacket(char* packet,int size); |
|
65 | void emitPacket(char* packet,int size); | |
66 | void bytesReceivedFromSpw( unsigned int ); |
|
66 | void bytesReceivedFromSpw( unsigned int ); | |
67 | void bytesTransmittedToSpw( unsigned int); |
|
67 | void bytesTransmittedToSpw( unsigned int); | |
68 | void ccsdsPacketTransmittedToSpw( void ); |
|
68 | void ccsdsPacketTransmittedToSpw( void ); | |
69 |
|
69 | |||
70 | public slots: |
|
70 | public slots: | |
71 | void sendTimecodePeriodically( bool onOff ); |
|
71 | void sendTimecodePeriodically( bool onOff ); | |
72 | void sendOneTimecode(unsigned char nTimein); |
|
72 | void sendOneTimecode(unsigned char nTimein); | |
73 | int getLinkNumber( void ); |
|
73 | int getLinkNumber( void ); | |
74 |
|
74 | |||
75 | private: |
|
75 | private: | |
76 | //QSemaphore* RMAP_AnswersSem; |
|
76 | //QSemaphore* RMAP_AnswersSem; | |
77 | star_device_handle hDevice; |
|
77 | star_device_handle hDevice; | |
78 |
|
78 | |||
79 | QLabel *starDundeeStatusQueryDialogLabel; |
|
79 | QLabel *starDundeeStatusQueryDialogLabel; | |
80 | QPushButton *starDundeeStatusQueryRetryButton; |
|
80 | QPushButton *starDundeeStatusQueryRetryButton; | |
81 | QPushButton *starDundeeStatusQueryAbortButton; |
|
81 | QPushButton *starDundeeStatusQueryAbortButton; | |
82 | QLabel *statusLink1; |
|
82 | QLabel *statusLink1; | |
83 | QLabel *statusLink2; |
|
83 | QLabel *statusLink2; | |
84 | QPushButton *starDundeeStatusQueryContinueButton; |
|
84 | QPushButton *starDundeeStatusQueryContinueButton; | |
85 | QDialog *starDundeeStatusQueryDialog; |
|
85 | QDialog *starDundeeStatusQueryDialog; | |
86 | QGridLayout *starDundeeStatusQueryDialogLayout; |
|
86 | QGridLayout *starDundeeStatusQueryDialogLayout; | |
87 |
|
87 | |||
88 | public: |
|
88 | public: | |
89 | int selectedBrick; |
|
89 | int selectedBrick; | |
90 | int brickList; |
|
90 | int brickList; | |
91 | int linkSpeed; |
|
91 | int linkSpeed; | |
92 | double timecodeFrequency; |
|
92 | double timecodeFrequency; | |
93 | bool interfaceMode; // 1 => interface mode, 0 => router mode |
|
93 | bool interfaceMode; // 1 => interface mode, 0 => router mode | |
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | class stardundeeSPW_USB : public abstractSpwBridge |
|
96 | class stardundeeSPW_USB : public abstractSpwBridge | |
97 | { |
|
97 | { | |
98 | Q_OBJECT |
|
98 | Q_OBJECT | |
99 | public: |
|
99 | public: | |
100 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); |
|
100 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); | |
101 | ~stardundeeSPW_USB(); |
|
101 | ~stardundeeSPW_USB(); | |
102 |
|
102 | |||
103 | signals: |
|
103 | signals: | |
104 |
|
104 | |||
105 | void setRmapTimeout(const QString & timeout); |
|
105 | void setRmapTimeout(const QString & timeout); | |
106 | void SelectBrick(int brickIndex); |
|
106 | void SelectBrick(int brickIndex); | |
107 | void SelectLinkNumber(int linkIndex); |
|
107 | void SelectLinkNumber(int linkIndex); | |
108 | void SelectLinkSpeed(int linkSpeed); |
|
108 | void SelectLinkSpeed(int linkSpeed); | |
109 | void SetDestinationKey(const QString & destKey); |
|
109 | void SetDestinationKey(const QString & destKey); | |
110 | void SetSourceAddress(const QString & address); |
|
110 | void SetSourceAddress(const QString & address); | |
111 | void SetDestinationAddress(const QString & address); |
|
111 | void SetDestinationAddress(const QString & address); | |
112 | void SetRmapTimeout(const QString & timeout); |
|
112 | void SetRmapTimeout(const QString & timeout); | |
113 | void SetTimecodeFrequency( double ); |
|
113 | void SetTimecodeFrequency( double ); | |
114 | void SetBrickAsAnInterface( bool ); |
|
114 | void SetBrickAsAnInterface( bool ); | |
115 | void SetBrickAsARouter( bool ); |
|
115 | void SetBrickAsARouter( bool ); | |
116 | int GetAvailableBrickCount( void ); |
|
116 | int GetAvailableBrickCount( void ); | |
117 | unsigned int GetNbPacketsTransmittedToSpw( void ); |
|
117 | unsigned int GetNbPacketsTransmittedToSpw( void ); | |
118 | unsigned int GetNbCCSDSPacketsTransmittedToSpw( void ); |
|
118 | unsigned int GetNbCCSDSPacketsTransmittedToSpw( void ); | |
119 | void BytesReceivedFromSpw( unsigned int ); |
|
119 | void BytesReceivedFromSpw( unsigned int ); | |
120 | void BytesTransmittedToSpw( unsigned int ); |
|
120 | void BytesTransmittedToSpw( unsigned int ); | |
121 | void CCSDSPacketTransmittedToSpw( void ); |
|
121 | void CCSDSPacketTransmittedToSpw( void ); | |
122 | void StartSendingTimecodes( bool ); |
|
122 | void StartSendingTimecodes( bool ); | |
123 | void SendOneTimecode( unsigned char ); |
|
123 | void SendOneTimecode( unsigned char ); | |
124 | int GetLinkNumber(); |
|
124 | int GetLinkNumber(); | |
125 |
|
125 | |||
126 | public slots: |
|
126 | public slots: | |
127 | void toggleBridgeConnection(); |
|
127 | void toggleBridgeConnection(); | |
128 | bool connectBridge(); |
|
128 | bool connectBridge(); | |
129 | bool disconnectBridge(); |
|
129 | bool disconnectBridge(); | |
130 | int pushRMAPPacket(char* packet,int size); |
|
130 | int pushRMAPPacket(char* packet,int size); | |
131 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
131 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
132 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
132 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
133 | void brickSelectionChanged(int brickIndex); |
|
133 | void brickSelectionChanged(int brickIndex); | |
134 | void linkNumberSelectionChanged(int linkIndex); |
|
134 | void linkNumberSelectionChanged(int linkIndex); | |
135 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
135 | void linkSpeedSelectionChanged(const QString & linkSpeed); | |
136 | void sourceLogicalAddressChanged(const QString & destKey); |
|
136 | void sourceLogicalAddressChanged(const QString & destKey); | |
137 | void destinationAddressChanged(const QString & rmapaddress); |
|
137 | void destinationAddressChanged(const QString & rmapaddress); | |
138 | void brickModeChanged( bool interfaceMode ); |
|
138 | void brickModeChanged( bool interfaceMode ); | |
139 | void destinationKeyChanged(const QString & key); |
|
139 | void destinationKeyChanged(const QString & key); | |
140 | void rmapTimeoutChanged(const QString & timeout); |
|
140 | void rmapTimeoutChanged(const QString & timeout); | |
141 | void sendPacketComingFromTCPServer(char *packet, int size); |
|
141 | void sendPacketComingFromTCPServer(char *packet, int size); | |
142 | void timecodeFrequencyChanged(const QString &frequency); |
|
142 | void timecodeFrequencyChanged(const QString &frequency); | |
143 | void startSendingTimecodes( bool onOff ); |
|
143 | void startSendingTimecodes( bool onOff ); | |
144 | private: |
|
144 | private: | |
145 | void makeGUI(socexplorerplugin *parent); |
|
145 | void makeGUI(socexplorerplugin *parent); | |
146 | stardundeeSPW_USB_Manager* manager; |
|
146 | stardundeeSPW_USB_Manager* manager; | |
147 | }; |
|
147 | }; | |
148 |
|
148 | |||
149 | #endif // STARDUNDEESPW_USB_H |
|
149 | #endif // STARDUNDEESPW_USB_H |
@@ -1,179 +1,176 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 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 "abstractspwbridge.h" |
|
22 | #include "abstractspwbridge.h" | |
23 | #include <QTime> |
|
23 | #include <QTime> | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 |
|
25 | |||
26 | abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) |
|
26 | abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) | |
27 | :QObject((QObject*)parent) |
|
27 | :QObject((QObject*)parent) | |
28 | { |
|
28 | { | |
29 | this->plugin = parent; |
|
29 | this->plugin = parent; | |
30 | this->p_GUI=NULL; |
|
30 | this->p_GUI=NULL; | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | abstractSpwBridge::~abstractSpwBridge() |
|
33 | abstractSpwBridge::~abstractSpwBridge() | |
34 | { |
|
34 | { | |
35 | // delete this->p_GUI; |
|
35 | // delete this->p_GUI; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QWidget *abstractSpwBridge::getGUI() |
|
38 | QWidget *abstractSpwBridge::getGUI() | |
39 | { |
|
39 | { | |
40 | return this->p_GUI; |
|
40 | return this->p_GUI; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | bool abstractSpwBridge::connectBridge() |
|
43 | bool abstractSpwBridge::connectBridge() | |
44 | { |
|
44 | { | |
45 | return false; |
|
45 | return false; | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | bool abstractSpwBridge::disconnectBridge() |
|
48 | bool abstractSpwBridge::disconnectBridge() | |
49 | { |
|
49 | { | |
50 | return false; |
|
50 | return false; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 |
|
53 | |||
54 |
|
54 | |||
55 |
|
55 | |||
56 |
|
56 | |||
57 |
|
57 | |||
58 |
|
58 | |||
59 |
|
59 | |||
60 |
|
60 | |||
61 |
|
61 | |||
62 | abstractSpwManager::abstractSpwManager(socexplorerplugin *plugin, QObject *parent) |
|
62 | abstractSpwManager::abstractSpwManager(socexplorerplugin *plugin, QObject *parent) | |
63 | :QThread((QObject*)parent) |
|
63 | :QThread((QObject*)parent) | |
64 | { |
|
64 | { | |
65 | this->RMAPtimeout = 2000; |
|
65 | this->RMAPtimeout = 2000; | |
66 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
66 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
67 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
67 | this->RMAP_AnswersSem = new QSemaphore(0); | |
68 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
68 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
69 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
69 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
70 | this->plugin = plugin; |
|
70 | this->plugin = plugin; | |
71 | connected = false; |
|
71 | connected = false; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | abstractSpwManager::~abstractSpwManager() |
|
74 | abstractSpwManager::~abstractSpwManager() | |
75 | { |
|
75 | { | |
76 |
this-> |
|
76 | this->requestInterruption(); | |
77 |
while |
|
77 | while(!this->isFinished()); | |
78 | { |
|
|||
79 | this->usleep(1000); |
|
|||
80 | } |
|
|||
81 | } |
|
78 | } | |
82 |
|
79 | |||
83 | int abstractSpwManager::getRMAPtransactionID() |
|
80 | int abstractSpwManager::getRMAPtransactionID() | |
84 | { |
|
81 | { | |
85 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
82 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
86 | int ID=0; |
|
83 | int ID=0; | |
87 | bool found=true; |
|
84 | bool found=true; | |
88 | while(ID<511) |
|
85 | while(ID<511) | |
89 | { |
|
86 | { | |
90 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
87 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
91 | { |
|
88 | { | |
92 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
89 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
93 | } |
|
90 | } | |
94 | if(found==true)break; |
|
91 | if(found==true)break; | |
95 | ID++; |
|
92 | ID++; | |
96 | found = true; |
|
93 | found = true; | |
97 | } |
|
94 | } | |
98 | if(found) |
|
95 | if(found) | |
99 | { |
|
96 | { | |
100 | RMAP_pending_transaction_IDs.append(ID); |
|
97 | RMAP_pending_transaction_IDs.append(ID); | |
101 | } |
|
98 | } | |
102 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
99 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
103 | return ID; |
|
100 | return ID; | |
104 | } |
|
101 | } | |
105 |
|
102 | |||
106 | int abstractSpwManager::getRMAPanswer(int transactionID, char **buffer) |
|
103 | int abstractSpwManager::getRMAPanswer(int transactionID, char **buffer) | |
107 | { |
|
104 | { | |
108 |
|
105 | |||
109 | QTime timeout; |
|
106 | QTime timeout; | |
110 | *buffer=NULL; |
|
107 | *buffer=NULL; | |
111 | int count=0; |
|
108 | int count=0; | |
112 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
109 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
113 | qApp->processEvents(); |
|
110 | qApp->processEvents(); | |
114 | timeout.start(); |
|
111 | timeout.start(); | |
115 | while (*buffer==NULL) |
|
112 | while (*buffer==NULL) | |
116 | { |
|
113 | { | |
117 | this->RMAP_AnswersMtx->lock(); |
|
114 | this->RMAP_AnswersMtx->lock(); | |
118 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
115 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
119 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
116 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
120 | for(int i=0;i<RMAP_Answers.count();i++) |
|
117 | for(int i=0;i<RMAP_Answers.count();i++) | |
121 | { |
|
118 | { | |
122 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
119 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); | |
123 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
120 | if(RMAP_Answers[i]->transactionID==transactionID) | |
124 | { |
|
121 | { | |
125 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
122 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
126 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
123 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
127 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
124 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
128 | { |
|
125 | { | |
129 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
126 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
130 | { |
|
127 | { | |
131 | RMAP_pending_transaction_IDs.removeAt(j); |
|
128 | RMAP_pending_transaction_IDs.removeAt(j); | |
132 | } |
|
129 | } | |
133 | } |
|
130 | } | |
134 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
131 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
135 | *buffer = RMAP_Answers[i]->data; |
|
132 | *buffer = RMAP_Answers[i]->data; | |
136 | count = RMAP_Answers[i]->len; |
|
133 | count = RMAP_Answers[i]->len; | |
137 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
134 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
138 | RMAP_Answers.removeAt(i); |
|
135 | RMAP_Answers.removeAt(i); | |
139 | delete tmp; |
|
136 | delete tmp; | |
140 | } |
|
137 | } | |
141 | } |
|
138 | } | |
142 | this->RMAP_AnswersMtx->unlock(); |
|
139 | this->RMAP_AnswersMtx->unlock(); | |
143 | //if no answer found in the stack wait until a new packet is pushed |
|
140 | //if no answer found in the stack wait until a new packet is pushed | |
144 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
141 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
145 | if(*buffer==NULL) |
|
142 | if(*buffer==NULL) | |
146 | { |
|
143 | { | |
147 | while (0==this->RMAP_AnswersSem->available()) |
|
144 | while (0==this->RMAP_AnswersSem->available()) | |
148 | { |
|
145 | { | |
149 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
146 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
150 | if(timeout.elapsed()>=RMAPtimeout) |
|
147 | if(timeout.elapsed()>=RMAPtimeout) | |
151 | { |
|
148 | { | |
152 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
149 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
153 | return -1; |
|
150 | return -1; | |
154 | } |
|
151 | } | |
155 | usleep(1000); |
|
152 | usleep(1000); | |
156 | qApp->processEvents(); |
|
153 | qApp->processEvents(); | |
157 | } |
|
154 | } | |
158 | this->RMAP_AnswersSem->acquire(); |
|
155 | this->RMAP_AnswersSem->acquire(); | |
159 | } |
|
156 | } | |
160 | } |
|
157 | } | |
161 | return count; |
|
158 | return count; | |
162 | } |
|
159 | } | |
163 |
|
160 | |||
164 | int abstractSpwManager::getLinkNumber() |
|
161 | int abstractSpwManager::getLinkNumber() | |
165 | { |
|
162 | { | |
166 | return this->linkNumber; |
|
163 | return this->linkNumber; | |
167 | } |
|
164 | } | |
168 |
|
165 | |||
169 | void abstractSpwManager::pushRmapPacket(char *packet, int len) |
|
166 | void abstractSpwManager::pushRmapPacket(char *packet, int len) | |
170 | { |
|
167 | { | |
171 | char* packetbuffer = (char*)malloc(len); |
|
168 | char* packetbuffer = (char*)malloc(len); | |
172 | memcpy(packetbuffer,packet,len); |
|
169 | memcpy(packetbuffer,packet,len); | |
173 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
170 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
174 | RMAP_AnswersMtx->lock(); |
|
171 | RMAP_AnswersMtx->lock(); | |
175 | RMAP_Answers.append(RMPAPpacket); |
|
172 | RMAP_Answers.append(RMPAPpacket); | |
176 | RMAP_AnswersMtx->unlock(); |
|
173 | RMAP_AnswersMtx->unlock(); | |
177 | } |
|
174 | } | |
178 |
|
175 | |||
179 |
|
176 |
@@ -1,110 +1,110 | |||||
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 ABSTRACTSPWBRIDGE_H |
|
22 | #ifndef ABSTRACTSPWBRIDGE_H | |
23 | #define ABSTRACTSPWBRIDGE_H |
|
23 | #define ABSTRACTSPWBRIDGE_H | |
24 |
|
24 | |||
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <QThread> |
|
26 | #include <QThread> | |
27 | #include <QMutex> |
|
27 | #include <QMutex> | |
28 | #include <QSemaphore> |
|
28 | #include <QSemaphore> | |
29 | #include <socexplorerplugin.h> |
|
29 | #include <socexplorerplugin.h> | |
30 | #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes |
|
30 | #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes | |
31 | #include <spw.h> |
|
31 | #include <spw.h> | |
32 |
|
32 | |||
33 | class RMAP_Answer |
|
33 | class RMAP_Answer | |
34 | { |
|
34 | { | |
35 | public: |
|
35 | public: | |
36 | RMAP_Answer(int ID,char* data,int len) |
|
36 | RMAP_Answer(int ID,char* data,int len) | |
37 | { |
|
37 | { | |
38 | transactionID = ID; |
|
38 | transactionID = ID; | |
39 | this->data = data; |
|
39 | this->data = data; | |
40 | this->len = len; |
|
40 | this->len = len; | |
41 | } |
|
41 | } | |
42 | int transactionID; |
|
42 | int transactionID; | |
43 | char* data; |
|
43 | char* data; | |
44 | int len; |
|
44 | int len; | |
45 | }; |
|
45 | }; | |
46 |
|
46 | |||
47 | class abstractSpwBridge : public QObject |
|
47 | class abstractSpwBridge : public QObject | |
48 | { |
|
48 | { | |
49 | Q_OBJECT |
|
49 | Q_OBJECT | |
50 | public: |
|
50 | public: | |
51 | explicit abstractSpwBridge(socexplorerplugin *parent); |
|
51 | explicit abstractSpwBridge(socexplorerplugin *parent); | |
52 | ~abstractSpwBridge(); |
|
52 | ~abstractSpwBridge(); | |
53 | QWidget *getGUI(); |
|
53 | QWidget *getGUI(); | |
54 |
|
54 | |||
55 | public slots: |
|
55 | public slots: | |
56 | virtual bool connectBridge(); |
|
56 | virtual bool connectBridge(); | |
57 | virtual bool disconnectBridge(); |
|
57 | virtual bool disconnectBridge(); | |
58 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
58 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
59 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
59 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
60 | virtual int pushRMAPPacket(char* packet,int size)=0; |
|
60 | virtual int pushRMAPPacket(char* packet,int size)=0; | |
61 | signals: |
|
61 | signals: | |
62 | void setConnected(bool connected); |
|
62 | void setConnected(bool connected); | |
63 | void pushPacketOverTCP(char* packet,int size); |
|
63 | void pushPacketOverTCP(char* packet,int size); | |
64 | protected: |
|
64 | protected: | |
65 | socexplorerplugin* plugin; |
|
65 | socexplorerplugin* plugin; | |
66 | QWidget* p_GUI; |
|
66 | QWidget* p_GUI; | |
67 | private: |
|
67 | private: | |
68 |
|
68 | |||
69 | }; |
|
69 | }; | |
70 |
|
70 | |||
71 | class abstractSpwManager: public QThread |
|
71 | class abstractSpwManager: public QThread | |
72 | { |
|
72 | { | |
73 | Q_OBJECT |
|
73 | Q_OBJECT | |
74 | public: |
|
74 | public: | |
75 | explicit abstractSpwManager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
75 | explicit abstractSpwManager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
76 | ~abstractSpwManager(); |
|
76 | ~abstractSpwManager(); | |
77 | virtual void run(){} |
|
77 | virtual void run(){}; | |
78 | virtual bool connectBridge()=0; |
|
78 | virtual bool connectBridge()=0; | |
79 | virtual bool disconnectBridge()=0; |
|
79 | virtual bool disconnectBridge()=0; | |
80 | int getRMAPtransactionID(); |
|
80 | int getRMAPtransactionID(); | |
81 | int getRMAPanswer(int transactionID,char** buffer); |
|
81 | int getRMAPanswer(int transactionID,char** buffer); | |
82 | virtual bool sendPacket(char* packet,int size)=0; |
|
82 | virtual bool sendPacket(char* packet,int size)=0; | |
83 | int RMAPtimeout; |
|
83 | int RMAPtimeout; | |
84 | int linkNumber; |
|
84 | int linkNumber; | |
85 | int sourceLogicalAddress; |
|
85 | int sourceLogicalAddress; | |
86 | int destinationLogicalAddress; |
|
86 | int destinationLogicalAddress; | |
87 | int destinationKey; |
|
87 | int destinationKey; | |
88 | signals: |
|
88 | signals: | |
89 | void emitPacket(char* packet,int size); |
|
89 | void emitPacket(char* packet,int size); | |
90 | void bytesReceivedFromSpw( unsigned int ); |
|
90 | void bytesReceivedFromSpw( unsigned int ); | |
91 | void bytesTransmittedToSpw( unsigned int); |
|
91 | void bytesTransmittedToSpw( unsigned int); | |
92 | void ccsdsPacketTransmittedToSpw( void ); |
|
92 | void ccsdsPacketTransmittedToSpw( void ); | |
93 |
|
93 | |||
94 | public slots: |
|
94 | public slots: | |
95 | int getLinkNumber(); |
|
95 | int getLinkNumber(); | |
96 |
|
96 | |||
97 | protected: |
|
97 | protected: | |
98 | QList<RMAP_Answer*> RMAP_Answers; |
|
98 | QList<RMAP_Answer*> RMAP_Answers; | |
99 | QList<int> RMAP_pending_transaction_IDs; |
|
99 | QList<int> RMAP_pending_transaction_IDs; | |
100 | QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; |
|
100 | QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; | |
101 | QSemaphore* RMAP_AnswersSem; |
|
101 | QSemaphore* RMAP_AnswersSem; | |
102 | socexplorerplugin* plugin; |
|
102 | socexplorerplugin* plugin; | |
103 | bool connected; |
|
103 | bool connected; | |
104 | void pushRmapPacket(char* packet,int len); |
|
104 | void pushRmapPacket(char* packet,int len); | |
105 |
|
105 | |||
106 | }; |
|
106 | }; | |
107 |
|
107 | |||
108 |
|
108 | |||
109 |
|
109 | |||
110 | #endif // ABSTRACTSPWBRIDGE_H |
|
110 | #endif // ABSTRACTSPWBRIDGE_H |
@@ -1,186 +1,187 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "spwplugin.h" |
|
23 | #include "spwplugin.h" | |
24 | #include "stardundeespw_usb.h" |
|
24 | #include "stardundeespw_usb.h" | |
25 | #include "gr_esb_bridge.h" |
|
25 | #include "gr_esb_bridge.h" | |
26 | #include <socexplorerproxy.h> |
|
26 | #include <socexplorerproxy.h> | |
27 | #include "fakestardundeespwusb_lib.h" |
|
27 | #include "fakestardundeespwusb_lib.h" | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) | |
31 | { |
|
31 | { | |
32 | Q_UNUSED(parent) |
|
32 | Q_UNUSED(parent) | |
33 | FakeStarDundeeSpwUSB_Lib::resolve(); |
|
33 | FakeStarDundeeSpwUSB_Lib::resolve(); | |
34 | this->bridge = NULL; |
|
34 | this->bridge = Q_NULLPTR; | |
35 | this->scanDone = false; |
|
35 | this->scanDone = false; | |
36 | // this->pyObject = new spwPyWrapper(this); |
|
36 | // this->pyObject = new spwPyWrapper(this); | |
37 | this->tcpServer = new SpwTcpPacketServer(this); |
|
37 | this->tcpServer = new SpwTcpPacketServer(this); | |
38 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
38 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); | |
39 | this->bridgeSelector = new QComboBox(this); |
|
39 | this->bridgeSelector = new QComboBox(this); | |
40 | this->mainTabWidgt = new QTabWidget(this); |
|
40 | this->mainTabWidgt = new QTabWidget(this); | |
41 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
41 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); | |
42 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
42 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); | |
43 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
43 | this->mainLayout = new QGridLayout(this->mainGroupBox); | |
44 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
44 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); | |
45 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
45 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); | |
46 | this->setWidget(this->mainTabWidgt); |
|
46 | this->setWidget(this->mainTabWidgt); | |
47 | this->bridgeSelector->addItem("none"); |
|
47 | this->bridgeSelector->addItem("none"); | |
48 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
48 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); | |
49 | this->bridgeSelector->addItem("GR-ESB"); |
|
49 | this->bridgeSelector->addItem("GR-ESB"); | |
50 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
50 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); | |
51 | connect(this,SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
51 | connect(this,SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); | |
52 | connect(this,SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
52 | connect(this,SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); | |
53 | connect(this,SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
53 | connect(this,SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); | |
54 | connect(this,SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); |
|
54 | connect(this,SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); | |
55 | connect(this,SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); |
|
55 | connect(this,SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | spwplugin::~spwplugin() |
|
59 | spwplugin::~spwplugin() | |
60 | { |
|
60 | { | |
61 |
|
61 | if(this->bridge!=Q_NULLPTR) | ||
|
62 | delete this->bridge; | |||
62 | } |
|
63 | } | |
63 |
|
64 | |||
64 |
|
65 | |||
65 |
|
66 | |||
66 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
67 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
67 | { |
|
68 | { | |
68 | if(Connected) |
|
69 | if(Connected) | |
69 | { |
|
70 | { | |
70 | return bridge->Read(Value,count,address); |
|
71 | return bridge->Read(Value,count,address); | |
71 | } |
|
72 | } | |
72 | return 0; |
|
73 | return 0; | |
73 | } |
|
74 | } | |
74 |
|
75 | |||
75 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
76 | void spwplugin::bridgeSelectionChanged(const QString &text) | |
76 | { |
|
77 | { | |
77 | printf("test"); |
|
78 | printf("test"); | |
78 | if(text=="none") |
|
79 | if(text=="none") | |
79 | { |
|
80 | { | |
80 | if(this->bridge!=NULL) |
|
81 | if(this->bridge!=NULL) | |
81 | { |
|
82 | { | |
82 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
83 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
83 | this->bridge->getGUI()->hide(); |
|
84 | this->bridge->getGUI()->hide(); | |
84 | this->disconnect(this,SLOT(setConnected(bool))); |
|
85 | this->disconnect(this,SLOT(setConnected(bool))); | |
85 | delete this->bridge; |
|
86 | delete this->bridge; | |
86 | this->bridge= NULL; |
|
87 | this->bridge= NULL; | |
87 | } |
|
88 | } | |
88 | } |
|
89 | } | |
89 | if(text=="STAR-Dundee Spw USB Brick") |
|
90 | if(text=="STAR-Dundee Spw USB Brick") | |
90 | { |
|
91 | { | |
91 | if(this->bridge!=NULL) |
|
92 | if(this->bridge!=NULL) | |
92 | { |
|
93 | { | |
93 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
94 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
94 | this->bridge->getGUI()->hide(); |
|
95 | this->bridge->getGUI()->hide(); | |
95 | this->disconnect(this,SLOT(setConnected(bool))); |
|
96 | this->disconnect(this,SLOT(setConnected(bool))); | |
96 | delete this->bridge; |
|
97 | delete this->bridge; | |
97 | } |
|
98 | } | |
98 | this->bridge = new stardundeeSPW_USB(this); |
|
99 | this->bridge = new stardundeeSPW_USB(this); | |
99 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
100 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
100 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
101 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
101 | connect(this,SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
102 | connect(this,SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); | |
102 | connect(this,SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
103 | connect(this,SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); | |
103 | connect(this,SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
104 | connect(this,SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); | |
104 | connect(this,SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString))); |
|
105 | connect(this,SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString))); | |
105 | connect(this,SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString))); |
|
106 | connect(this,SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString))); | |
106 | connect(this,SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
107 | connect(this,SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); | |
107 | connect(this,SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
108 | connect(this,SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); | |
108 | connect(this,SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
109 | connect(this,SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); | |
109 | connect(this,SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
110 | connect(this,SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); | |
110 | connect(this,SIGNAL(StarDundeeGetAvailableBrickCount()), |
|
111 | connect(this,SIGNAL(StarDundeeGetAvailableBrickCount()), | |
111 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); |
|
112 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); | |
112 | connect(this,SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()), |
|
113 | connect(this,SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()), | |
113 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw())); |
|
114 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw())); | |
114 | connect(this,SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()), |
|
115 | connect(this,SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()), | |
115 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw())); |
|
116 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw())); | |
116 | connect(this,SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber())); |
|
117 | connect(this,SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber())); | |
117 | connect(this,SIGNAL(StarDundeeSetBrickAsAninterface(bool)), |
|
118 | connect(this,SIGNAL(StarDundeeSetBrickAsAninterface(bool)), | |
118 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); |
|
119 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); | |
119 | connect(this,SIGNAL(StarDundeeSetBrickAsARouter(bool)), |
|
120 | connect(this,SIGNAL(StarDundeeSetBrickAsARouter(bool)), | |
120 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); |
|
121 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); | |
121 | connect(this,SIGNAL(StarDundeeStartTimecodes(bool)), |
|
122 | connect(this,SIGNAL(StarDundeeStartTimecodes(bool)), | |
122 | ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool))); |
|
123 | ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool))); | |
123 | connect(this,SIGNAL(StarDundeeSetTimecodeFrequency(double)), |
|
124 | connect(this,SIGNAL(StarDundeeSetTimecodeFrequency(double)), | |
124 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double))); |
|
125 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double))); | |
125 | connect(this,SIGNAL(StarDundeeSendOneTimecode(unsigned char)), |
|
126 | connect(this,SIGNAL(StarDundeeSendOneTimecode(unsigned char)), | |
126 | ((stardundeeSPW_USB*)bridge),SIGNAL(SendOneTimecode(unsigned char))); |
|
127 | ((stardundeeSPW_USB*)bridge),SIGNAL(SendOneTimecode(unsigned char))); | |
127 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); |
|
128 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); | |
128 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); |
|
129 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); | |
129 | } |
|
130 | } | |
130 | if(text=="GR-ESB") |
|
131 | if(text=="GR-ESB") | |
131 | { |
|
132 | { | |
132 | if(this->bridge!=NULL) |
|
133 | if(this->bridge!=NULL) | |
133 | { |
|
134 | { | |
134 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
135 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
135 | this->bridge->getGUI()->hide(); |
|
136 | this->bridge->getGUI()->hide(); | |
136 | this->disconnect(this,SLOT(setConnected(bool))); |
|
137 | this->disconnect(this,SLOT(setConnected(bool))); | |
137 | delete this->bridge; |
|
138 | delete this->bridge; | |
138 | } |
|
139 | } | |
139 | this->bridge = new GR_ESB_bridge(this); |
|
140 | this->bridge = new GR_ESB_bridge(this); | |
140 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
141 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
141 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
142 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
142 | } |
|
143 | } | |
143 | } |
|
144 | } | |
144 |
|
145 | |||
145 |
|
146 | |||
146 | void spwplugin::selectBridge(const QString &text) |
|
147 | void spwplugin::selectBridge(const QString &text) | |
147 | { |
|
148 | { | |
148 |
|
149 | |||
149 | if(text=="none") |
|
150 | if(text=="none") | |
150 | { |
|
151 | { | |
151 | this->bridgeSelector->setCurrentIndex(0); |
|
152 | this->bridgeSelector->setCurrentIndex(0); | |
152 | } |
|
153 | } | |
153 | if(text=="STAR-Dundee Spw USB Brick") |
|
154 | if(text=="STAR-Dundee Spw USB Brick") | |
154 | { |
|
155 | { | |
155 | this->bridgeSelector->setCurrentIndex(1); |
|
156 | this->bridgeSelector->setCurrentIndex(1); | |
156 | } |
|
157 | } | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | void spwplugin::setConnected(bool connected) |
|
160 | void spwplugin::setConnected(bool connected) | |
160 | { |
|
161 | { | |
161 | this->bridgeSelector->setDisabled(connected); |
|
162 | this->bridgeSelector->setDisabled(connected); | |
162 | this->Connected = connected; |
|
163 | this->Connected = connected; | |
163 | emit activateSig(connected); |
|
164 | emit activateSig(connected); | |
164 | if(!this->scanDone) |
|
165 | if(!this->scanDone) | |
165 | { |
|
166 | { | |
166 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
167 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
167 | this->scanDone=true; |
|
168 | this->scanDone=true; | |
168 | } |
|
169 | } | |
169 | } |
|
170 | } | |
170 |
|
171 | |||
171 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
172 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
172 | { |
|
173 | { | |
173 | if(Connected) |
|
174 | if(Connected) | |
174 | { |
|
175 | { | |
175 | return bridge->Write(Value,count,address); |
|
176 | return bridge->Write(Value,count,address); | |
176 | } |
|
177 | } | |
177 | return 0; |
|
178 | return 0; | |
178 | } |
|
179 | } | |
179 |
|
180 | |||
180 |
|
181 | |||
181 |
|
182 | |||
182 |
|
183 | |||
183 |
|
184 | |||
184 |
|
185 | |||
185 |
|
186 | |||
186 |
|
187 |
General Comments 0
You need to be logged in to leave comments.
Login now