@@ -1,38 +1,94 | |||||
1 | #include "gr_esb_bridge.h" |
|
1 | #include "gr_esb_bridge.h" | |
2 | #include "gr_esb_ui.h" |
|
2 | #include "gr_esb_ui.h" | |
|
3 | #include <unistd.h> | |||
3 |
|
4 | |||
4 | GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) : |
|
5 | GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) : | |
5 | abstractSpwBridge(parent) |
|
6 | abstractSpwBridge(parent) | |
6 | { |
|
7 | { | |
7 | this->p_GUI = new GR_ESB_ui(); |
|
8 | this->p_GUI = new GR_ESB_ui(); | |
8 | this->soc = new QTcpSocket(this); |
|
9 | this->Read_soc = new QTcpSocket(this); | |
|
10 | this->Write_soc = new QTcpSocket(this); | |||
|
11 | connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString))); | |||
|
12 | connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setPort(QString))); | |||
9 | } |
|
13 | } | |
10 |
|
14 | |||
11 | GR_ESB_bridge::~GR_ESB_bridge() |
|
15 | GR_ESB_bridge::~GR_ESB_bridge() | |
12 | { |
|
16 | { | |
13 | } |
|
17 | } | |
14 |
|
18 | |||
15 | bool GR_ESB_bridge::connectBridge() |
|
19 | bool GR_ESB_bridge::connectBridge() | |
16 | { |
|
20 | { | |
17 |
|
21 | int timeout=60; | ||
|
22 | if(this->Read_soc->state()==QTcpSocket::UnconnectedState) | |||
|
23 | { | |||
|
24 | this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port); | |||
|
25 | this->Read_soc->waitForConnected(30000); | |||
|
26 | } | |||
|
27 | if(this->Write_soc->state()==QTcpSocket::UnconnectedState) | |||
|
28 | { | |||
|
29 | this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port); | |||
|
30 | this->Write_soc->waitForConnected(30000); | |||
|
31 | } | |||
|
32 | while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState)) | |||
|
33 | { | |||
|
34 | usleep(100000); | |||
|
35 | if(timeout--==0)return false; | |||
|
36 | } | |||
|
37 | return true; | |||
18 | } |
|
38 | } | |
19 |
|
39 | |||
20 | bool GR_ESB_bridge::disconnectBridge() |
|
40 | bool GR_ESB_bridge::disconnectBridge() | |
21 | { |
|
41 | { | |
|
42 | int timeout=60; | |||
|
43 | if(this->Read_soc->state()!=QTcpSocket::UnconnectedState) | |||
|
44 | { | |||
|
45 | this->Read_soc->disconnectFromHost(); | |||
|
46 | this->Read_soc->waitForDisconnected(30000); | |||
|
47 | while(this->Read_soc->state()!=QTcpSocket::UnconnectedState) | |||
|
48 | { | |||
|
49 | usleep(100000); | |||
|
50 | if(timeout--==0)return false; | |||
|
51 | } | |||
|
52 | } | |||
|
53 | return true; | |||
|
54 | } | |||
22 |
|
55 | |||
|
56 | void GR_ESB_bridge::setIP(QString ip) | |||
|
57 | { | |||
|
58 | this->IP = ip; | |||
23 | } |
|
59 | } | |
24 |
|
60 | |||
|
61 | void GR_ESB_bridge::setVirtualLink(QString vlink) | |||
|
62 | { | |||
|
63 | vlink = vlink.section("Virtual link",0,0); | |||
|
64 | bool success; | |||
|
65 | int vlinkTmp = vlink.toInt(&success); | |||
|
66 | if(success) | |||
|
67 | { | |||
|
68 | setVirtualLink(vlinkTmp); | |||
|
69 | } | |||
|
70 | } | |||
|
71 | ||||
|
72 | void GR_ESB_bridge::setVirtualLink(qint32 vlink) | |||
|
73 | { | |||
|
74 | if(vlink<6 && vlink>=0) | |||
|
75 | { | |||
|
76 | virtualLinkIndex = vlink; | |||
|
77 | } | |||
|
78 | } | |||
|
79 | ||||
|
80 | ||||
25 | unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
81 | unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
26 | { |
|
82 | { | |
27 |
|
83 | |||
28 | } |
|
84 | } | |
29 |
|
85 | |||
30 | unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
86 | unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
31 | { |
|
87 | { | |
32 |
|
88 | |||
33 | } |
|
89 | } | |
34 |
|
90 | |||
35 | int GR_ESB_bridge::pushRMAPPacket(char *packet, int size) |
|
91 | int GR_ESB_bridge::pushRMAPPacket(char *packet, int size) | |
36 | { |
|
92 | { | |
37 |
|
93 | |||
38 | } |
|
94 | } |
@@ -1,27 +1,50 | |||||
1 | #ifndef GR_ESB_BRIDGE_H |
|
1 | #ifndef GR_ESB_BRIDGE_H | |
2 | #define GR_ESB_BRIDGE_H |
|
2 | #define GR_ESB_BRIDGE_H | |
3 | #include "abstractspwbridge.h" |
|
3 | #include "abstractspwbridge.h" | |
4 | #include <QTcpSocket> |
|
4 | #include <QTcpSocket> | |
5 |
|
5 | |||
|
6 | struct gresb_Conf_str | |||
|
7 | { | |||
|
8 | qint32 Read_port; | |||
|
9 | qint32 Write_port; | |||
|
10 | }; | |||
|
11 | ||||
|
12 | const struct gresb_Conf_str gresb_Conf[]= | |||
|
13 | { | |||
|
14 | {3000,3001}, //Virtual link 0 | |||
|
15 | {3002,3003}, //Virtual link 1 | |||
|
16 | {3004,3005}, //Virtual link 2 | |||
|
17 | {3006,3007}, //Virtual link 3 | |||
|
18 | {3008,3009}, //Virtual link 4 | |||
|
19 | {3010,3011} //Virtual link 5 | |||
|
20 | }; | |||
|
21 | ||||
6 | class GR_ESB_bridge : public abstractSpwBridge |
|
22 | class GR_ESB_bridge : public abstractSpwBridge | |
7 | { |
|
23 | { | |
8 | Q_OBJECT |
|
24 | Q_OBJECT | |
9 | public: |
|
25 | public: | |
10 | explicit GR_ESB_bridge(socexplorerplugin *parent = 0); |
|
26 | explicit GR_ESB_bridge(socexplorerplugin *parent = 0); | |
11 | ~GR_ESB_bridge(); |
|
27 | ~GR_ESB_bridge(); | |
12 | signals: |
|
28 | signals: | |
13 |
|
29 | |||
14 |
|
30 | |||
15 | public slots: |
|
31 | public slots: | |
16 | bool connectBridge(); |
|
32 | bool connectBridge(); | |
17 | bool disconnectBridge(); |
|
33 | bool disconnectBridge(); | |
|
34 | void setIP(QString ip); | |||
|
35 | void setVirtualLink(QString vlink); | |||
|
36 | void setVirtualLink(qint32 vlink); | |||
18 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
37 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
19 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
38 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
20 | int pushRMAPPacket(char* packet,int size); |
|
39 | int pushRMAPPacket(char* packet,int size); | |
21 | void packetReceived(); |
|
40 | void packetReceived(); | |
22 |
|
41 | |||
23 | QTcpSocket* soc; |
|
42 | private: | |
|
43 | QTcpSocket* Read_soc; | |||
|
44 | QTcpSocket* Write_soc; | |||
|
45 | QString IP; | |||
|
46 | int virtualLinkIndex; | |||
24 |
|
47 | |||
25 | }; |
|
48 | }; | |
26 |
|
49 | |||
27 | #endif // GR_ESB_BRIDGE_H |
|
50 | #endif // GR_ESB_BRIDGE_H |
@@ -1,14 +1,19 | |||||
1 | #include "gr_esb_ui.h" |
|
1 | #include "gr_esb_ui.h" | |
2 | #include "ui_gr_esb_ui.h" |
|
2 | #include "ui_gr_esb_ui.h" | |
|
3 | #include <QWebView> | |||
3 |
|
4 | |||
4 | GR_ESB_ui::GR_ESB_ui(QWidget *parent) : |
|
5 | GR_ESB_ui::GR_ESB_ui(QWidget *parent) : | |
5 | QWidget(parent), |
|
6 | QWidget(parent), | |
6 | ui(new Ui::GR_ESB_ui) |
|
7 | ui(new Ui::GR_ESB_ui) | |
7 | { |
|
8 | { | |
8 | ui->setupUi(this); |
|
9 | ui->setupUi(this); | |
|
10 | connect(this->ui->GRESB_IP_lineEdit,SIGNAL(textChanged(QString)),this,SLOT(changeIp(QString))); | |||
|
11 | connect(this->ui->GRESB_Vlink_CmBx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(vlinkchanged(QString))); | |||
9 | } |
|
12 | } | |
10 |
|
13 | |||
11 | GR_ESB_ui::~GR_ESB_ui() |
|
14 | void GR_ESB_ui::changeIp(QString ip) | |
12 | { |
|
15 | { | |
13 | delete ui; |
|
16 | this->ui->WebView->load(QUrl("http://"+ip)); | |
|
17 | emit this->ipchanged(ip); | |||
14 | } |
|
18 | } | |
|
19 |
@@ -1,22 +1,27 | |||||
1 | #ifndef GR_ESB_UI_H |
|
1 | #ifndef GR_ESB_UI_H | |
2 | #define GR_ESB_UI_H |
|
2 | #define GR_ESB_UI_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
5 |
|
5 | |||
6 | namespace Ui { |
|
6 | namespace Ui { | |
7 | class GR_ESB_ui; |
|
7 | class GR_ESB_ui; | |
8 | } |
|
8 | } | |
9 |
|
9 | |||
10 | class GR_ESB_ui : public QWidget |
|
10 | class GR_ESB_ui : public QWidget | |
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 |
|
13 | |||
14 | public: |
|
14 | public: | |
15 | explicit GR_ESB_ui(QWidget *parent = 0); |
|
15 | explicit GR_ESB_ui(QWidget *parent = 0); | |
16 | ~GR_ESB_ui(); |
|
16 | ||
|
17 | public slots: | |||
|
18 | void changeIp(QString ip); | |||
17 |
|
19 | |||
|
20 | signals: | |||
|
21 | void ipchanged(QString ip); | |||
|
22 | void vlinkchanged(QString vlink); | |||
18 | private: |
|
23 | private: | |
19 | Ui::GR_ESB_ui *ui; |
|
24 | Ui::GR_ESB_ui *ui; | |
20 | }; |
|
25 | }; | |
21 |
|
26 | |||
22 | #endif // GR_ESB_UI_H |
|
27 | #endif // GR_ESB_UI_H |
@@ -1,67 +1,139 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>GR_ESB_ui</class> |
|
3 | <class>GR_ESB_ui</class> | |
4 | <widget class="QWidget" name="GR_ESB_ui"> |
|
4 | <widget class="QWidget" name="GR_ESB_ui"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>489</width> |
|
9 | <width>489</width> | |
10 | <height>295</height> |
|
10 | <height>295</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 |
<layout class="Q |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <item row="1" column="2"> |
|
17 | <item> | |
18 |
<widget class="Q |
|
18 | <widget class="QTabWidget" name="tabWidget"> | |
19 | </item> |
|
19 | <property name="toolTip"> | |
20 | <item row="1" column="0"> |
|
20 | <string/> | |
21 | <widget class="QLabel" name="GRESB_Port_Lbl"> |
|
|||
22 | <property name="text"> |
|
|||
23 | <string>GR-ESB Port</string> |
|
|||
24 | </property> |
|
21 | </property> | |
25 | </widget> |
|
22 | <property name="currentIndex"> | |
26 | </item> |
|
23 | <number>0</number> | |
27 | <item row="0" column="2"> |
|
|||
28 | <widget class="QLineEdit" name="GRESB_IP_lineEdit"/> |
|
|||
29 | </item> |
|
|||
30 | <item row="0" column="0"> |
|
|||
31 | <widget class="QLabel" name="GRESB_IP_Lbl"> |
|
|||
32 | <property name="text"> |
|
|||
33 | <string>GR-ESB IP Address</string> |
|
|||
34 | </property> |
|
24 | </property> | |
35 | </widget> |
|
25 | <widget class="QWidget" name="Config"> | |
36 | </item> |
|
26 | <property name="toolTip"> | |
37 | <item row="2" column="0"> |
|
27 | <string><html><head/><body><p>The Config tab allows you to configure the Ethernet conncetion to the GR-ESB and some spacewire parameters.</p></body></html></string> | |
38 | <widget class="QLabel" name="GRESB_LinkNum_Lbl"> |
|
|||
39 | <property name="text"> |
|
|||
40 | <string>Select link number</string> |
|
|||
41 | </property> |
|
|||
42 | </widget> |
|
|||
43 | </item> |
|
|||
44 | <item row="2" column="2"> |
|
|||
45 | <widget class="QComboBox" name="GRESB_LinkNum_CmBx"> |
|
|||
46 | <item> |
|
|||
47 | <property name="text"> |
|
|||
48 | <string>SPW0</string> |
|
|||
49 | </property> |
|
28 | </property> | |
50 | </item> |
|
29 | <attribute name="title"> | |
51 | <item> |
|
30 | <string>Config</string> | |
52 | <property name="text"> |
|
31 | </attribute> | |
53 | <string>SPW1</string> |
|
32 | <layout class="QGridLayout" name="gridLayout_2"> | |
|
33 | <item row="1" column="1"> | |||
|
34 | <widget class="QComboBox" name="GRESB_Vlink_CmBx"> | |||
|
35 | <item> | |||
|
36 | <property name="text"> | |||
|
37 | <string>Virtual link 0</string> | |||
|
38 | </property> | |||
|
39 | </item> | |||
|
40 | <item> | |||
|
41 | <property name="text"> | |||
|
42 | <string>Virtual link 1</string> | |||
|
43 | </property> | |||
|
44 | </item> | |||
|
45 | <item> | |||
|
46 | <property name="text"> | |||
|
47 | <string>Virtual link 2</string> | |||
|
48 | </property> | |||
|
49 | </item> | |||
|
50 | <item> | |||
|
51 | <property name="text"> | |||
|
52 | <string>Virtual link 3</string> | |||
|
53 | </property> | |||
|
54 | </item> | |||
|
55 | <item> | |||
|
56 | <property name="text"> | |||
|
57 | <string>Virtual link 4</string> | |||
|
58 | </property> | |||
|
59 | </item> | |||
|
60 | <item> | |||
|
61 | <property name="text"> | |||
|
62 | <string>Virtual link 5</string> | |||
|
63 | </property> | |||
|
64 | </item> | |||
|
65 | </widget> | |||
|
66 | </item> | |||
|
67 | <item row="1" column="0"> | |||
|
68 | <widget class="QLabel" name="GRESB_Vlink_Lbl"> | |||
|
69 | <property name="text"> | |||
|
70 | <string>GR-ESB Virtual link</string> | |||
|
71 | </property> | |||
|
72 | </widget> | |||
|
73 | </item> | |||
|
74 | <item row="2" column="1"> | |||
|
75 | <widget class="QComboBox" name="GRESB_LinkNum_CmBx"> | |||
|
76 | <item> | |||
|
77 | <property name="text"> | |||
|
78 | <string>SPW0</string> | |||
|
79 | </property> | |||
|
80 | </item> | |||
|
81 | <item> | |||
|
82 | <property name="text"> | |||
|
83 | <string>SPW1</string> | |||
|
84 | </property> | |||
|
85 | </item> | |||
|
86 | <item> | |||
|
87 | <property name="text"> | |||
|
88 | <string>SPW2</string> | |||
|
89 | </property> | |||
|
90 | </item> | |||
|
91 | </widget> | |||
|
92 | </item> | |||
|
93 | <item row="0" column="1"> | |||
|
94 | <widget class="QLineEdit" name="GRESB_IP_lineEdit"/> | |||
|
95 | </item> | |||
|
96 | <item row="2" column="0"> | |||
|
97 | <widget class="QLabel" name="GRESB_LinkNum_Lbl"> | |||
|
98 | <property name="text"> | |||
|
99 | <string>Select link number</string> | |||
|
100 | </property> | |||
|
101 | </widget> | |||
|
102 | </item> | |||
|
103 | <item row="0" column="0"> | |||
|
104 | <widget class="QLabel" name="GRESB_IP_Lbl"> | |||
|
105 | <property name="text"> | |||
|
106 | <string>GR-ESB IP Address</string> | |||
|
107 | </property> | |||
|
108 | </widget> | |||
|
109 | </item> | |||
|
110 | </layout> | |||
|
111 | </widget> | |||
|
112 | <widget class="QWidget" name="Web"> | |||
|
113 | <property name="toolTip"> | |||
|
114 | <string><html><head/><body><p>The Web tab gives access to the GR-ESB web interface.</p></body></html></string> | |||
54 | </property> |
|
115 | </property> | |
55 | </item> |
|
116 | <attribute name="title"> | |
56 | <item> |
|
117 | <string>Web</string> | |
57 | <property name="text"> |
|
118 | </attribute> | |
58 | <string>SPW2</string> |
|
119 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
59 |
|
|
120 | <item> | |
60 | </item> |
|
121 | <widget class="QWebView" name="WebView" native="true"/> | |
|
122 | </item> | |||
|
123 | </layout> | |||
|
124 | </widget> | |||
61 | </widget> |
|
125 | </widget> | |
62 | </item> |
|
126 | </item> | |
63 | </layout> |
|
127 | </layout> | |
64 | </widget> |
|
128 | </widget> | |
|
129 | <customwidgets> | |||
|
130 | <customwidget> | |||
|
131 | <class>QWebView</class> | |||
|
132 | <extends>QWidget</extends> | |||
|
133 | <header location="global">QWebView</header> | |||
|
134 | <container>1</container> | |||
|
135 | </customwidget> | |||
|
136 | </customwidgets> | |||
65 | <resources/> |
|
137 | <resources/> | |
66 | <connections/> |
|
138 | <connections/> | |
67 | </ui> |
|
139 | </ui> |
@@ -1,79 +1,86 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>SpwTcpPacketServer</class> |
|
3 | <class>SpwTcpPacketServer</class> | |
4 | <widget class="QWidget" name="SpwTcpPacketServer"> |
|
4 | <widget class="QWidget" name="SpwTcpPacketServer"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>671</width> |
|
9 | <width>671</width> | |
10 | <height>409</height> |
|
10 | <height>409</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
|
16 | <property name="toolTip"> | |||
|
17 | <string><html><head/><body><p>The spacewire plugin TCP server allows you to forward spacewire packets to any custom application, here you will configure the TCP connection and get some status information.</p></body></html></string> | |||
|
18 | </property> | |||
16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
19 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <item> |
|
20 | <item> | |
18 | <widget class="QGroupBox" name="configGroupBox"> |
|
21 | <widget class="QGroupBox" name="configGroupBox"> | |
19 | <property name="title"> |
|
22 | <property name="title"> | |
20 | <string>Configuration</string> |
|
23 | <string>Configuration</string> | |
21 | </property> |
|
24 | </property> | |
22 | <layout class="QFormLayout" name="formLayout_2"> |
|
25 | <layout class="QFormLayout" name="formLayout_2"> | |
23 | <item row="0" column="0"> |
|
26 | <item row="0" column="0"> | |
24 | <widget class="QLabel" name="IPLbl"> |
|
27 | <widget class="QLabel" name="IPLbl"> | |
25 | <property name="text"> |
|
28 | <property name="text"> | |
26 | <string>Server IP</string> |
|
29 | <string>Server IP</string> | |
27 | </property> |
|
30 | </property> | |
28 | </widget> |
|
31 | </widget> | |
29 | </item> |
|
32 | </item> | |
30 | <item row="0" column="1"> |
|
33 | <item row="0" column="1"> | |
31 | <widget class="QLineEdit" name="IPLineEdit"> |
|
34 | <widget class="QLineEdit" name="IPLineEdit"> | |
32 | <property name="maxLength"> |
|
35 | <property name="maxLength"> | |
33 | <number>15</number> |
|
36 | <number>15</number> | |
34 | </property> |
|
37 | </property> | |
35 | <property name="readOnly"> |
|
38 | <property name="readOnly"> | |
36 | <bool>true</bool> |
|
39 | <bool>true</bool> | |
37 | </property> |
|
40 | </property> | |
38 | </widget> |
|
41 | </widget> | |
39 | </item> |
|
42 | </item> | |
40 | <item row="1" column="0"> |
|
43 | <item row="1" column="0"> | |
41 | <widget class="QLabel" name="PortLbl"> |
|
44 | <widget class="QLabel" name="PortLbl"> | |
42 | <property name="text"> |
|
45 | <property name="text"> | |
43 | <string>Server Port</string> |
|
46 | <string>Server Port</string> | |
44 | </property> |
|
47 | </property> | |
45 | </widget> |
|
48 | </widget> | |
46 | </item> |
|
49 | </item> | |
47 | <item row="1" column="1"> |
|
50 | <item row="1" column="1"> | |
48 |
<widget class="QLineEdit" name="PortLineEdit" |
|
51 | <widget class="QLineEdit" name="PortLineEdit"> | |
|
52 | <property name="toolTip"> | |||
|
53 | <string><html><head/><body><p>Set the port on which the server will listen and accept client connections.</p></body></html></string> | |||
|
54 | </property> | |||
|
55 | </widget> | |||
49 | </item> |
|
56 | </item> | |
50 | <item row="2" column="1"> |
|
57 | <item row="2" column="1"> | |
51 | <widget class="QPushButton" name="startServeQpb"> |
|
58 | <widget class="QPushButton" name="startServeQpb"> | |
52 | <property name="text"> |
|
59 | <property name="text"> | |
53 | <string>Start Server</string> |
|
60 | <string>Start Server</string> | |
54 | </property> |
|
61 | </property> | |
55 | </widget> |
|
62 | </widget> | |
56 | </item> |
|
63 | </item> | |
57 | </layout> |
|
64 | </layout> | |
58 | </widget> |
|
65 | </widget> | |
59 | </item> |
|
66 | </item> | |
60 | <item> |
|
67 | <item> | |
61 | <widget class="QGroupBox" name="clientListGroupBox_2"> |
|
68 | <widget class="QGroupBox" name="clientListGroupBox_2"> | |
62 | <property name="title"> |
|
69 | <property name="title"> | |
63 | <string>Connected clients</string> |
|
70 | <string>Connected clients</string> | |
64 | </property> |
|
71 | </property> | |
65 | <property name="flat"> |
|
72 | <property name="flat"> | |
66 | <bool>false</bool> |
|
73 | <bool>false</bool> | |
67 | </property> |
|
74 | </property> | |
68 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
75 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
69 | <item> |
|
76 | <item> | |
70 | <widget class="QListWidget" name="listWidget"/> |
|
77 | <widget class="QListWidget" name="listWidget"/> | |
71 | </item> |
|
78 | </item> | |
72 | </layout> |
|
79 | </layout> | |
73 | </widget> |
|
80 | </widget> | |
74 | </item> |
|
81 | </item> | |
75 | </layout> |
|
82 | </layout> | |
76 | </widget> |
|
83 | </widget> | |
77 | <resources/> |
|
84 | <resources/> | |
78 | <connections/> |
|
85 | <connections/> | |
79 | </ui> |
|
86 | </ui> |
@@ -1,647 +1,646 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "stardundeespw_usb.h" |
|
23 | #include "stardundeespw_usb.h" | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 | #include <qhexedit.h> |
|
25 | #include <qhexedit.h> | |
26 |
|
26 | |||
27 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
27 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
28 | abstractSpwBridge(parent) |
|
28 | abstractSpwBridge(parent) | |
29 | { |
|
29 | { | |
30 | Q_UNUSED(parent) |
|
30 | Q_UNUSED(parent) | |
31 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
31 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
32 | makeGUI(parent); |
|
32 | makeGUI(parent); | |
33 | this->manager->start(); |
|
33 | this->manager->start(); | |
34 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); |
|
34 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
37 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
38 | { |
|
38 | { | |
39 | this->manager->requestInterruption(); |
|
39 | this->manager->requestInterruption(); | |
40 | delete this->p_GUI; |
|
|||
41 | } |
|
40 | } | |
42 |
|
41 | |||
43 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
42 | void stardundeeSPW_USB::toggleBridgeConnection() | |
44 | { |
|
43 | { | |
45 | if(this->plugin->isConnected()) |
|
44 | if(this->plugin->isConnected()) | |
46 | { |
|
45 | { | |
47 | this->disconnectBridge(); |
|
46 | this->disconnectBridge(); | |
48 | } |
|
47 | } | |
49 | else |
|
48 | else | |
50 | { |
|
49 | { | |
51 | this->connectBridge(); |
|
50 | this->connectBridge(); | |
52 | } |
|
51 | } | |
53 | } |
|
52 | } | |
54 |
|
53 | |||
55 | bool stardundeeSPW_USB::connectBridge() |
|
54 | bool stardundeeSPW_USB::connectBridge() | |
56 | { |
|
55 | { | |
57 | if(this->manager->connectBridge()) |
|
56 | if(this->manager->connectBridge()) | |
58 | { |
|
57 | { | |
59 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
58 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
60 | emit setConnected(true); |
|
59 | emit setConnected(true); | |
61 | return true; |
|
60 | return true; | |
62 | } |
|
61 | } | |
63 | return false; |
|
62 | return false; | |
64 | } |
|
63 | } | |
65 |
|
64 | |||
66 | bool stardundeeSPW_USB::disconnectBridge() |
|
65 | bool stardundeeSPW_USB::disconnectBridge() | |
67 | { |
|
66 | { | |
68 | if(this->manager->disconnectBridge()) |
|
67 | if(this->manager->disconnectBridge()) | |
69 | { |
|
68 | { | |
70 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
69 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
71 | emit setConnected(false); |
|
70 | emit setConnected(false); | |
72 | return true; |
|
71 | return true; | |
73 | } |
|
72 | } | |
74 | return false; |
|
73 | return false; | |
75 | } |
|
74 | } | |
76 |
|
75 | |||
77 |
|
76 | |||
78 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
77 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
79 | { |
|
78 | { | |
80 | return this->manager->sendPacket(packet,size); |
|
79 | return this->manager->sendPacket(packet,size); | |
81 | } |
|
80 | } | |
82 |
|
81 | |||
83 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
82 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
84 | { |
|
83 | { | |
85 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
84 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; | |
86 | char *RMAPAckBuff; |
|
85 | char *RMAPAckBuff; | |
87 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
86 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
88 | int transactionID = 0; |
|
87 | int transactionID = 0; | |
89 | int written=0; |
|
88 | int written=0; | |
90 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
89 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
91 | QProgressBar* progress=NULL; |
|
90 | QProgressBar* progress=NULL; | |
92 | SocExplorerAutoProgressBar autopb; |
|
91 | SocExplorerAutoProgressBar autopb; | |
93 | if(count>RMAP_MAX_XFER_SIZE) |
|
92 | if(count>RMAP_MAX_XFER_SIZE) | |
94 | { |
|
93 | { | |
95 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
94 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
96 | autopb.setProgressBar(progress); |
|
95 | autopb.setProgressBar(progress); | |
97 | } |
|
96 | } | |
98 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
97 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
99 | while(count>=RMAP_MAX_XFER_SIZE) |
|
98 | while(count>=RMAP_MAX_XFER_SIZE) | |
100 | { |
|
99 | { | |
101 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
100 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
102 | { |
|
101 | { | |
103 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
102 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
104 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
103 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
105 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
104 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
106 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
105 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
107 | } |
|
106 | } | |
108 | transactionID=manager->getRMAPtransactionID(); |
|
107 | transactionID=manager->getRMAPtransactionID(); | |
109 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
108 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
110 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); |
|
109 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); | |
111 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
110 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
112 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
111 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
113 | free(RMAPAckBuff); |
|
112 | free(RMAPAckBuff); | |
114 | written+=RMAP_MAX_XFER_SIZE; |
|
113 | written+=RMAP_MAX_XFER_SIZE; | |
115 | count-=RMAP_MAX_XFER_SIZE; |
|
114 | count-=RMAP_MAX_XFER_SIZE; | |
116 | progress->setValue(written); |
|
115 | progress->setValue(written); | |
117 | qApp->processEvents(); |
|
116 | qApp->processEvents(); | |
118 | } |
|
117 | } | |
119 | if(count>0) |
|
118 | if(count>0) | |
120 | { |
|
119 | { | |
121 | for(int i=0;i<((int)count);i++) |
|
120 | for(int i=0;i<((int)count);i++) | |
122 | { |
|
121 | { | |
123 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
122 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
124 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
123 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
125 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
124 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
126 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
125 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
127 | } |
|
126 | } | |
128 | transactionID=manager->getRMAPtransactionID(); |
|
127 | transactionID=manager->getRMAPtransactionID(); | |
129 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
128 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
130 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); |
|
129 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); | |
131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
130 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
131 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
133 | free(RMAPAckBuff); |
|
132 | free(RMAPAckBuff); | |
134 | written+=count; |
|
133 | written+=count; | |
135 | if(progress!=NULL) |
|
134 | if(progress!=NULL) | |
136 | { |
|
135 | { | |
137 | progress->setValue(written); |
|
136 | progress->setValue(written); | |
138 | qApp->processEvents(); |
|
137 | qApp->processEvents(); | |
139 | } |
|
138 | } | |
140 | } |
|
139 | } | |
141 | return written; |
|
140 | return written; | |
142 | } |
|
141 | } | |
143 |
|
142 | |||
144 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
143 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
145 | { |
|
144 | { | |
146 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
145 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
147 | char* RMAP_AnswerBuffer; |
|
146 | char* RMAP_AnswerBuffer; | |
148 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
147 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
149 | int transactionID = 0; |
|
148 | int transactionID = 0; | |
150 | int read=0; |
|
149 | int read=0; | |
151 | QProgressBar* progress=NULL; |
|
150 | QProgressBar* progress=NULL; | |
152 | SocExplorerAutoProgressBar autopb; |
|
151 | SocExplorerAutoProgressBar autopb; | |
153 | if(count>RMAP_MAX_XFER_SIZE) |
|
152 | if(count>RMAP_MAX_XFER_SIZE) | |
154 | { |
|
153 | { | |
155 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
154 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
156 | autopb.setProgressBar(progress); |
|
155 | autopb.setProgressBar(progress); | |
157 | } |
|
156 | } | |
158 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
157 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); | |
159 |
|
158 | |||
160 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
159 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
161 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
160 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
162 | { |
|
161 | { | |
163 | transactionID = manager->getRMAPtransactionID(); |
|
162 | transactionID = manager->getRMAPtransactionID(); | |
164 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
163 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
165 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); |
|
164 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); | |
166 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
165 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
167 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
166 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
168 | if(len==-1) |
|
167 | if(len==-1) | |
169 | { |
|
168 | { | |
170 | this->toggleBridgeConnection(); |
|
169 | this->toggleBridgeConnection(); | |
171 | return 0; |
|
170 | return 0; | |
172 | } |
|
171 | } | |
173 | for(int i=0;i<((len-13)/4);i++) |
|
172 | for(int i=0;i<((len-13)/4);i++) | |
174 | { |
|
173 | { | |
175 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
174 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
176 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
175 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
177 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
176 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
178 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
177 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
179 | } |
|
178 | } | |
180 | free(RMAP_AnswerBuffer); |
|
179 | free(RMAP_AnswerBuffer); | |
181 | read+=RMAP_MAX_XFER_SIZE; |
|
180 | read+=RMAP_MAX_XFER_SIZE; | |
182 | count-=RMAP_MAX_XFER_SIZE; |
|
181 | count-=RMAP_MAX_XFER_SIZE; | |
183 | progress->setValue(read); |
|
182 | progress->setValue(read); | |
184 | qApp->processEvents(); |
|
183 | qApp->processEvents(); | |
185 | } |
|
184 | } | |
186 | if((int)count>0) |
|
185 | if((int)count>0) | |
187 | { |
|
186 | { | |
188 | transactionID = manager->getRMAPtransactionID(); |
|
187 | transactionID = manager->getRMAPtransactionID(); | |
189 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
188 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
190 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
189 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
191 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
190 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
192 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
191 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
193 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
192 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
194 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1); |
|
193 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1); | |
195 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
194 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
196 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
195 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
197 | if(len==-1) |
|
196 | if(len==-1) | |
198 | { |
|
197 | { | |
199 | this->toggleBridgeConnection(); |
|
198 | this->toggleBridgeConnection(); | |
200 | return 0; |
|
199 | return 0; | |
201 | } |
|
200 | } | |
202 | for(int i=0;i<((len-13)/4);i++) |
|
201 | for(int i=0;i<((len-13)/4);i++) | |
203 | { |
|
202 | { | |
204 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
203 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
205 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
204 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
206 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
205 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
207 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
206 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
208 | } |
|
207 | } | |
209 | free(RMAP_AnswerBuffer); |
|
208 | free(RMAP_AnswerBuffer); | |
210 | read+=count; |
|
209 | read+=count; | |
211 | if(progress!=NULL) |
|
210 | if(progress!=NULL) | |
212 | { |
|
211 | { | |
213 | progress->setValue(read); |
|
212 | progress->setValue(read); | |
214 | qApp->processEvents(); |
|
213 | qApp->processEvents(); | |
215 | } |
|
214 | } | |
216 | } |
|
215 | } | |
217 | return read; |
|
216 | return read; | |
218 | } |
|
217 | } | |
219 |
|
218 | |||
220 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
219 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
221 | { |
|
220 | { | |
222 | this->manager->selectedBrick = brickIndex-1; |
|
221 | this->manager->selectedBrick = brickIndex-1; | |
223 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
222 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); | |
224 | } |
|
223 | } | |
225 |
|
224 | |||
226 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
225 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
227 | { |
|
226 | { | |
228 | this->manager->linkNumber = linkIndex + 1; |
|
227 | this->manager->linkNumber = linkIndex + 1; | |
229 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
228 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); | |
230 | } |
|
229 | } | |
231 |
|
230 | |||
232 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
231 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
233 | { |
|
232 | { | |
234 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
233 | this->manager->linkSpeed = linkSpeed.toInt(); | |
235 |
|
234 | |||
236 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
235 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); | |
237 | } |
|
236 | } | |
238 |
|
237 | |||
239 | void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey) |
|
238 | void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey) | |
240 | { |
|
239 | { | |
241 | this->manager->destinationKey = destKey.toInt(); |
|
240 | this->manager->destinationKey = destKey.toInt(); | |
242 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey),1); |
|
241 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey),1); | |
243 | } |
|
242 | } | |
244 |
|
243 | |||
245 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) |
|
244 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) | |
246 | { |
|
245 | { | |
247 | this->manager->rmapAddress = rmapaddress.toInt(); |
|
246 | this->manager->rmapAddress = rmapaddress.toInt(); | |
248 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress),1); |
|
247 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress),1); | |
249 | } |
|
248 | } | |
250 |
|
249 | |||
251 | void stardundeeSPW_USB::rmapKeyChanged(const QString &key) |
|
250 | void stardundeeSPW_USB::rmapKeyChanged(const QString &key) | |
252 | { |
|
251 | { | |
253 | this->manager->rmapKey = key.toInt(); |
|
252 | this->manager->rmapKey = key.toInt(); | |
254 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey),1); |
|
253 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey),1); | |
255 | } |
|
254 | } | |
256 |
|
255 | |||
257 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
256 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) | |
258 | { |
|
257 | { | |
259 | int tim=timeout.toInt(); |
|
258 | int tim=timeout.toInt(); | |
260 | if(tim<50) |
|
259 | if(tim<50) | |
261 | { |
|
260 | { | |
262 | tim = 50; |
|
261 | tim = 50; | |
263 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
262 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); | |
264 | } |
|
263 | } | |
265 | this->manager->RMAPtimeout = tim; |
|
264 | this->manager->RMAPtimeout = tim; | |
266 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
265 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); | |
267 | } |
|
266 | } | |
268 |
|
267 | |||
269 |
|
268 | |||
270 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
269 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
271 | { |
|
270 | { | |
272 | this->p_GUI = new StarDundeeGUI(); |
|
271 | this->p_GUI = new StarDundeeGUI(); | |
273 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
272 | // this->mainLayout = new QGridLayout(this->p_GUI); | |
274 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
273 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
275 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
274 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
276 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
275 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
277 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
276 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
278 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
277 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
279 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
278 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
280 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); |
|
279 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); | |
281 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString))); |
|
280 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString))); | |
282 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
281 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); | |
283 |
|
282 | |||
284 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
283 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
285 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
284 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
286 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
285 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
287 | this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); |
|
286 | this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
288 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); |
|
287 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); | |
289 | this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey()); |
|
288 | this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey()); | |
290 | this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); |
|
289 | this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
291 |
|
290 | |||
292 | connect(this,SIGNAL(SelectBrick(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
291 | connect(this,SIGNAL(SelectBrick(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
293 | connect(this,SIGNAL(SelectLinkNumber(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
292 | connect(this,SIGNAL(SelectLinkNumber(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
294 | connect(this,SIGNAL(SelectLinkSpeed(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); |
|
293 | connect(this,SIGNAL(SelectLinkSpeed(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
295 | connect(this,SIGNAL(SetDestinationKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); |
|
294 | connect(this,SIGNAL(SetDestinationKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
296 | connect(this,SIGNAL(SetRmapAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); |
|
295 | connect(this,SIGNAL(SetRmapAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); | |
297 | connect(this,SIGNAL(SetRmapKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); |
|
296 | connect(this,SIGNAL(SetRmapKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); | |
298 | connect(this,SIGNAL(SetRmapTimeout(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); |
|
297 | connect(this,SIGNAL(SetRmapTimeout(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
299 |
|
298 | |||
300 | } |
|
299 | } | |
301 |
|
300 | |||
302 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
301 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
303 | :QThread((QObject*)parent) |
|
302 | :QThread((QObject*)parent) | |
304 | { |
|
303 | { | |
305 | this->RMAPtimeout = 2000; |
|
304 | this->RMAPtimeout = 2000; | |
306 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
305 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
307 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
306 | this->RMAP_AnswersSem = new QSemaphore(0); | |
308 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
307 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
309 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
308 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
310 | this->plugin = plugin; |
|
309 | this->plugin = plugin; | |
311 | connected = false; |
|
310 | connected = false; | |
312 | this->moveToThread(this); |
|
311 | this->moveToThread(this); | |
313 | } |
|
312 | } | |
314 |
|
313 | |||
315 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
314 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
316 | { |
|
315 | { | |
317 | this->terminate(); |
|
316 | this->terminate(); | |
318 | while (!this->isFinished()) { |
|
317 | while (!this->isFinished()) { | |
319 | this->usleep(1000); |
|
318 | this->usleep(1000); | |
320 | } |
|
319 | } | |
321 | } |
|
320 | } | |
322 |
|
321 | |||
323 |
|
322 | |||
324 | void stardundeeSPW_USB_Manager::run() |
|
323 | void stardundeeSPW_USB_Manager::run() | |
325 | { |
|
324 | { | |
326 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
325 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
327 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
326 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
328 | USB_SPACEWIRE_STATUS stat; |
|
327 | USB_SPACEWIRE_STATUS stat; | |
329 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
328 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
330 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
329 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
331 | while (!this->isInterruptionRequested()) |
|
330 | while (!this->isInterruptionRequested()) | |
332 | { |
|
331 | { | |
333 | if(this->connected) |
|
332 | if(this->connected) | |
334 | { |
|
333 | { | |
335 | handleMutex->lock(); |
|
334 | handleMutex->lock(); | |
336 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
335 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
337 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
336 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
338 | { |
|
337 | { | |
339 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
338 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
340 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
339 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
341 | if (stat == TRANSFER_SUCCESS) |
|
340 | if (stat == TRANSFER_SUCCESS) | |
342 | { |
|
341 | { | |
343 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
342 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
344 | { |
|
343 | { | |
345 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
344 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
346 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
345 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
347 | { |
|
346 | { | |
348 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
347 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); | |
349 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
348 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
350 | { |
|
349 | { | |
351 | RMAP_Answer* packet; |
|
350 | RMAP_Answer* packet; | |
352 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
351 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
353 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
352 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
354 | char* packetbuffer = (char*)malloc(properties.len); |
|
353 | char* packetbuffer = (char*)malloc(properties.len); | |
355 | memcpy(packetbuffer,buffer,properties.len); |
|
354 | memcpy(packetbuffer,buffer,properties.len); | |
356 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
355 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
357 | pIdentifier = NULL; |
|
356 | pIdentifier = NULL; | |
358 | handleMutex->unlock(); |
|
357 | handleMutex->unlock(); | |
359 | if(properties.len==8) |
|
358 | if(properties.len==8) | |
360 | { |
|
359 | { | |
361 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
360 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); | |
362 | } |
|
361 | } | |
363 | else |
|
362 | else | |
364 | { |
|
363 | { | |
365 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
364 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
366 | } |
|
365 | } | |
367 | RMAP_AnswersMtx->lock(); |
|
366 | RMAP_AnswersMtx->lock(); | |
368 | RMAP_Answers.append(packet); |
|
367 | RMAP_Answers.append(packet); | |
369 | RMAP_AnswersMtx->unlock(); |
|
368 | RMAP_AnswersMtx->unlock(); | |
370 | RMAP_AnswersSem->release(); |
|
369 | RMAP_AnswersSem->release(); | |
371 | } |
|
370 | } | |
372 | else //any non-rmap packet will be pushed to the network |
|
371 | else //any non-rmap packet will be pushed to the network | |
373 | { |
|
372 | { | |
374 | char* packetbuffer = (char*)malloc(properties.len); |
|
373 | char* packetbuffer = (char*)malloc(properties.len); | |
375 | memcpy(packetbuffer,buffer,properties.len); |
|
374 | memcpy(packetbuffer,buffer,properties.len); | |
376 | emit emitPacket(packetbuffer,properties.len); |
|
375 | emit emitPacket(packetbuffer,properties.len); | |
377 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
376 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
378 | handleMutex->unlock(); |
|
377 | handleMutex->unlock(); | |
379 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
378 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
380 | } |
|
379 | } | |
381 | } |
|
380 | } | |
382 | else |
|
381 | else | |
383 | { |
|
382 | { | |
384 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
383 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
385 | } |
|
384 | } | |
386 | } |
|
385 | } | |
387 |
|
386 | |||
388 | } |
|
387 | } | |
389 | else |
|
388 | else | |
390 | { |
|
389 | { | |
391 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
390 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
392 | handleMutex->unlock(); |
|
391 | handleMutex->unlock(); | |
393 | } |
|
392 | } | |
394 | } |
|
393 | } | |
395 | else |
|
394 | else | |
396 | { |
|
395 | { | |
397 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
396 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
398 | handleMutex->unlock(); |
|
397 | handleMutex->unlock(); | |
399 | } |
|
398 | } | |
400 | } |
|
399 | } | |
401 | else |
|
400 | else | |
402 | { |
|
401 | { | |
403 | //do some sanity checks! |
|
402 | //do some sanity checks! | |
404 | int list = USBSpaceWire_ListDevices(); |
|
403 | int list = USBSpaceWire_ListDevices(); | |
405 | if(this->brickList!=list) |
|
404 | if(this->brickList!=list) | |
406 | { |
|
405 | { | |
407 | this->brickList = list; |
|
406 | this->brickList = list; | |
408 | emit updateAvailableBrickCount(this->brickList); |
|
407 | emit updateAvailableBrickCount(this->brickList); | |
409 | } |
|
408 | } | |
410 | usleep(RMAPtimeout/2); |
|
409 | usleep(RMAPtimeout/2); | |
411 | } |
|
410 | } | |
412 | usleep(1000); |
|
411 | usleep(1000); | |
413 | } |
|
412 | } | |
414 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
413 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
415 | } |
|
414 | } | |
416 |
|
415 | |||
417 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
416 | bool stardundeeSPW_USB_Manager::connectBridge() | |
418 | { |
|
417 | { | |
419 | QMutexLocker mlock(this->handleMutex); |
|
418 | QMutexLocker mlock(this->handleMutex); | |
420 | int status; |
|
419 | int status; | |
421 | U32 statusControl; |
|
420 | U32 statusControl; | |
422 | this->connected = false; |
|
421 | this->connected = false; | |
423 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
422 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
424 | { |
|
423 | { | |
425 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
424 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
426 | return false; |
|
425 | return false; | |
427 | } |
|
426 | } | |
428 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
427 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
429 |
|
428 | |||
430 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
429 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
431 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
430 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
432 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
431 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
433 |
|
432 | |||
434 | // Set the path and return path to the device |
|
433 | // Set the path and return path to the device | |
435 | CFGSpaceWire_StackClear(); |
|
434 | CFGSpaceWire_StackClear(); | |
436 | CFGSpaceWire_AddrStackPush(0); |
|
435 | CFGSpaceWire_AddrStackPush(0); | |
437 | CFGSpaceWire_AddrStackPush(254); |
|
436 | CFGSpaceWire_AddrStackPush(254); | |
438 | CFGSpaceWire_RetAddrStackPush(254); |
|
437 | CFGSpaceWire_RetAddrStackPush(254); | |
439 | // set the base transmit rate to 100 MHz |
|
438 | // set the base transmit rate to 100 MHz | |
440 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
439 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
441 | if (status != CFG_TRANSFER_SUCCESS) |
|
440 | if (status != CFG_TRANSFER_SUCCESS) | |
442 | { |
|
441 | { | |
443 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
442 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
444 | return false; |
|
443 | return false; | |
445 | } |
|
444 | } | |
446 | else |
|
445 | else | |
447 | { |
|
446 | { | |
448 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
447 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
449 | } |
|
448 | } | |
450 |
|
449 | |||
451 | // read the link status |
|
450 | // read the link status | |
452 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
451 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
453 | { |
|
452 | { | |
454 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
453 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
455 | return false; |
|
454 | return false; | |
456 | } |
|
455 | } | |
457 | else |
|
456 | else | |
458 | { |
|
457 | { | |
459 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
458 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
460 |
|
459 | |||
461 | // Set the link status control register properties |
|
460 | // Set the link status control register properties | |
462 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
461 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
463 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
462 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
464 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
463 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
465 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
464 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
466 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
465 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
467 |
|
466 | |||
468 | // Set the link status control register |
|
467 | // Set the link status control register | |
469 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
468 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
470 | { |
|
469 | { | |
471 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
470 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
472 | return false; |
|
471 | return false; | |
473 | } |
|
472 | } | |
474 | else |
|
473 | else | |
475 | { |
|
474 | { | |
476 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
475 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
477 | } |
|
476 | } | |
478 | } |
|
477 | } | |
479 |
|
478 | |||
480 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
479 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
481 | { |
|
480 | { | |
482 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
481 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
483 | return false; |
|
482 | return false; | |
484 | } |
|
483 | } | |
485 | else |
|
484 | else | |
486 | { |
|
485 | { | |
487 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
486 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
488 | } |
|
487 | } | |
489 |
|
488 | |||
490 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
489 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
491 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
490 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
492 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
491 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
493 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
492 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
494 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
493 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
495 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
494 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
496 | this->connected = true; |
|
495 | this->connected = true; | |
497 | return true; |
|
496 | return true; | |
498 | } |
|
497 | } | |
499 |
|
498 | |||
500 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
499 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
501 | { |
|
500 | { | |
502 | this->handleMutex->lock(); |
|
501 | this->handleMutex->lock(); | |
503 | USBSpaceWire_Close(hDevice); // Close the device |
|
502 | USBSpaceWire_Close(hDevice); // Close the device | |
504 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
503 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
505 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
504 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
506 | this->handleMutex->unlock(); |
|
505 | this->handleMutex->unlock(); | |
507 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
506 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
508 | this->RMAP_pending_transaction_IDs.clear(); |
|
507 | this->RMAP_pending_transaction_IDs.clear(); | |
509 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
508 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
510 | this->RMAP_AnswersMtx->lock(); |
|
509 | this->RMAP_AnswersMtx->lock(); | |
511 | this->RMAP_Answers.clear(); |
|
510 | this->RMAP_Answers.clear(); | |
512 | this->RMAP_AnswersMtx->unlock(); |
|
511 | this->RMAP_AnswersMtx->unlock(); | |
513 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
512 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
514 | return true; |
|
513 | return true; | |
515 | } |
|
514 | } | |
516 |
|
515 | |||
517 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
516 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
518 | { |
|
517 | { | |
519 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
518 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
520 | int ID=0; |
|
519 | int ID=0; | |
521 | bool found=true; |
|
520 | bool found=true; | |
522 | while(ID<511) |
|
521 | while(ID<511) | |
523 | { |
|
522 | { | |
524 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
523 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
525 | { |
|
524 | { | |
526 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
525 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
527 | } |
|
526 | } | |
528 | if(found==true)break; |
|
527 | if(found==true)break; | |
529 | ID++; |
|
528 | ID++; | |
530 | found = true; |
|
529 | found = true; | |
531 | } |
|
530 | } | |
532 | if(found) |
|
531 | if(found) | |
533 | { |
|
532 | { | |
534 | RMAP_pending_transaction_IDs.append(ID); |
|
533 | RMAP_pending_transaction_IDs.append(ID); | |
535 | } |
|
534 | } | |
536 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
535 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
537 | return ID; |
|
536 | return ID; | |
538 | } |
|
537 | } | |
539 |
|
538 | |||
540 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
539 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
541 | { |
|
540 | { | |
542 | QTime timeout; |
|
541 | QTime timeout; | |
543 | *buffer=NULL; |
|
542 | *buffer=NULL; | |
544 | int count=0; |
|
543 | int count=0; | |
545 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
544 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
546 | timeout.start(); |
|
545 | timeout.start(); | |
547 | while (*buffer==NULL) |
|
546 | while (*buffer==NULL) | |
548 | { |
|
547 | { | |
549 | this->RMAP_AnswersMtx->lock(); |
|
548 | this->RMAP_AnswersMtx->lock(); | |
550 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
549 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
551 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
550 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
552 | for(int i=0;i<RMAP_Answers.count();i++) |
|
551 | for(int i=0;i<RMAP_Answers.count();i++) | |
553 | { |
|
552 | { | |
554 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
553 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); | |
555 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
554 | if(RMAP_Answers[i]->transactionID==transactionID) | |
556 | { |
|
555 | { | |
557 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
556 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
558 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
557 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
559 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
558 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
560 | { |
|
559 | { | |
561 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
560 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
562 | { |
|
561 | { | |
563 | RMAP_pending_transaction_IDs.removeAt(j); |
|
562 | RMAP_pending_transaction_IDs.removeAt(j); | |
564 | } |
|
563 | } | |
565 | } |
|
564 | } | |
566 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
565 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
567 | *buffer = RMAP_Answers[i]->data; |
|
566 | *buffer = RMAP_Answers[i]->data; | |
568 | count = RMAP_Answers[i]->len; |
|
567 | count = RMAP_Answers[i]->len; | |
569 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
568 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
570 | RMAP_Answers.removeAt(i); |
|
569 | RMAP_Answers.removeAt(i); | |
571 | delete tmp; |
|
570 | delete tmp; | |
572 | } |
|
571 | } | |
573 | } |
|
572 | } | |
574 | this->RMAP_AnswersMtx->unlock(); |
|
573 | this->RMAP_AnswersMtx->unlock(); | |
575 | //if no answer found in the stack wait until a new packet is pushed |
|
574 | //if no answer found in the stack wait until a new packet is pushed | |
576 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
575 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
577 | if(*buffer==NULL) |
|
576 | if(*buffer==NULL) | |
578 | { |
|
577 | { | |
579 | while (0==this->RMAP_AnswersSem->available()) |
|
578 | while (0==this->RMAP_AnswersSem->available()) | |
580 | { |
|
579 | { | |
581 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
580 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
582 | if(timeout.elapsed()>=RMAPtimeout) |
|
581 | if(timeout.elapsed()>=RMAPtimeout) | |
583 | { |
|
582 | { | |
584 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
583 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
585 | return -1; |
|
584 | return -1; | |
586 | } |
|
585 | } | |
587 | usleep(1000); |
|
586 | usleep(1000); | |
588 | } |
|
587 | } | |
589 | this->RMAP_AnswersSem->acquire(); |
|
588 | this->RMAP_AnswersSem->acquire(); | |
590 | } |
|
589 | } | |
591 | } |
|
590 | } | |
592 | return count; |
|
591 | return count; | |
593 | } |
|
592 | } | |
594 |
|
593 | |||
595 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
594 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
596 | { |
|
595 | { | |
597 | USB_SPACEWIRE_STATUS result; |
|
596 | USB_SPACEWIRE_STATUS result; | |
598 | USB_SPACEWIRE_ID pIdentifier; |
|
597 | USB_SPACEWIRE_ID pIdentifier; | |
599 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
598 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
600 | this->handleMutex->lock(); |
|
599 | this->handleMutex->lock(); | |
601 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
600 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
602 | if (result != TRANSFER_SUCCESS) |
|
601 | if (result != TRANSFER_SUCCESS) | |
603 | { |
|
602 | { | |
604 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
603 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
605 | this->handleMutex->unlock(); |
|
604 | this->handleMutex->unlock(); | |
606 | return false; |
|
605 | return false; | |
607 | } |
|
606 | } | |
608 | else |
|
607 | else | |
609 | { |
|
608 | { | |
610 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
609 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
611 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
610 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
612 | } |
|
611 | } | |
613 | this->handleMutex->unlock(); |
|
612 | this->handleMutex->unlock(); | |
614 | return true; |
|
613 | return true; | |
615 | } |
|
614 | } | |
616 |
|
615 | |||
617 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
616 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
618 | { |
|
617 | { | |
619 | char* packetbuffer = (char*)malloc(len); |
|
618 | char* packetbuffer = (char*)malloc(len); | |
620 | memcpy(packetbuffer,packet,len); |
|
619 | memcpy(packetbuffer,packet,len); | |
621 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
620 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
622 | RMAP_AnswersMtx->lock(); |
|
621 | RMAP_AnswersMtx->lock(); | |
623 | RMAP_Answers.append(RMPAPpacket); |
|
622 | RMAP_Answers.append(RMPAPpacket); | |
624 | RMAP_AnswersMtx->unlock(); |
|
623 | RMAP_AnswersMtx->unlock(); | |
625 | } |
|
624 | } | |
626 |
|
625 | |||
627 |
|
626 | |||
628 |
|
627 | |||
629 |
|
628 | |||
630 |
|
629 | |||
631 |
|
630 | |||
632 |
|
631 | |||
633 |
|
632 | |||
634 |
|
633 | |||
635 |
|
634 | |||
636 |
|
635 | |||
637 |
|
636 | |||
638 |
|
637 | |||
639 |
|
638 | |||
640 |
|
639 | |||
641 |
|
640 | |||
642 |
|
641 | |||
643 |
|
642 | |||
644 |
|
643 | |||
645 |
|
644 | |||
646 |
|
645 | |||
647 |
|
646 |
@@ -1,51 +1,56 | |||||
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 |
|
23 | |||
24 | abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) |
|
24 | abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) | |
25 | :QObject((QObject*)parent) |
|
25 | :QObject((QObject*)parent) | |
26 | { |
|
26 | { | |
27 | this->plugin = parent; |
|
27 | this->plugin = parent; | |
28 | this->p_GUI=NULL; |
|
28 | this->p_GUI=NULL; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
|
31 | abstractSpwBridge::~abstractSpwBridge() | |||
|
32 | { | |||
|
33 | delete this->p_GUI; | |||
|
34 | } | |||
|
35 | ||||
31 | QWidget *abstractSpwBridge::getGUI() |
|
36 | QWidget *abstractSpwBridge::getGUI() | |
32 | { |
|
37 | { | |
33 | return this->p_GUI; |
|
38 | return this->p_GUI; | |
34 | } |
|
39 | } | |
35 |
|
40 | |||
36 | bool abstractSpwBridge::connectBridge() |
|
41 | bool abstractSpwBridge::connectBridge() | |
37 | { |
|
42 | { | |
38 | return false; |
|
43 | return false; | |
39 | } |
|
44 | } | |
40 |
|
45 | |||
41 | bool abstractSpwBridge::disconnectBridge() |
|
46 | bool abstractSpwBridge::disconnectBridge() | |
42 | { |
|
47 | { | |
43 | return false; |
|
48 | return false; | |
44 | } |
|
49 | } | |
45 |
|
50 | |||
46 |
|
51 | |||
47 |
|
52 | |||
48 |
|
53 | |||
49 |
|
54 | |||
50 |
|
55 | |||
51 |
|
56 |
@@ -1,53 +1,54 | |||||
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 <socexplorerplugin.h> |
|
26 | #include <socexplorerplugin.h> | |
27 | #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes |
|
27 | #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes | |
28 | #include <spw.h> |
|
28 | #include <spw.h> | |
29 |
|
29 | |||
30 | class abstractSpwBridge : public QObject |
|
30 | class abstractSpwBridge : public QObject | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | explicit abstractSpwBridge(socexplorerplugin *parent); |
|
34 | explicit abstractSpwBridge(socexplorerplugin *parent); | |
|
35 | ~abstractSpwBridge(); | |||
35 | QWidget *getGUI(); |
|
36 | QWidget *getGUI(); | |
36 |
|
37 | |||
37 | public slots: |
|
38 | public slots: | |
38 | virtual bool connectBridge(); |
|
39 | virtual bool connectBridge(); | |
39 | virtual bool disconnectBridge(); |
|
40 | virtual bool disconnectBridge(); | |
40 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
41 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
41 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
42 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; | |
42 | virtual int pushRMAPPacket(char* packet,int size)=0; |
|
43 | virtual int pushRMAPPacket(char* packet,int size)=0; | |
43 | signals: |
|
44 | signals: | |
44 | void setConnected(bool connected); |
|
45 | void setConnected(bool connected); | |
45 | void pushPacketOverTCP(char* packet,int size); |
|
46 | void pushPacketOverTCP(char* packet,int size); | |
46 | protected: |
|
47 | protected: | |
47 | socexplorerplugin* plugin; |
|
48 | socexplorerplugin* plugin; | |
48 | QWidget* p_GUI; |
|
49 | QWidget* p_GUI; | |
49 | private: |
|
50 | private: | |
50 |
|
51 | |||
51 | }; |
|
52 | }; | |
52 |
|
53 | |||
53 | #endif // ABSTRACTSPWBRIDGE_H |
|
54 | #endif // ABSTRACTSPWBRIDGE_H |
@@ -1,90 +1,92 | |||||
1 | # |
|
1 | # | |
2 | # Project created by QtCreator 2011-09-20T08:15:30 |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
3 | # |
|
3 | # | |
4 | #------------------------------------------------- |
|
4 | #------------------------------------------------- | |
5 |
|
5 | |||
6 | CONFIG += socexplorerplugin |
|
6 | CONFIG += socexplorerplugin | |
7 | QT += network |
|
7 | QT += network webkit | |
|
8 | greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets | |||
|
9 | ||||
8 | win32:CONFIG += dll |
|
10 | win32:CONFIG += dll | |
9 | win32:CONFIG -= static |
|
11 | win32:CONFIG -= static | |
10 | CONFIG(debug, debug|release) { |
|
12 | CONFIG(debug, debug|release) { | |
11 | DEBUG_EXT = _d |
|
13 | DEBUG_EXT = _d | |
12 | } else { |
|
14 | } else { | |
13 | DEBUG_EXT = |
|
15 | DEBUG_EXT = | |
14 | } |
|
16 | } | |
15 | TARGET = spwplugin$${DEBUG_EXT} |
|
17 | TARGET = spwplugin$${DEBUG_EXT} | |
16 | DEFINES += PLUGIN=spwplugin |
|
18 | DEFINES += PLUGIN=spwplugin | |
17 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" |
|
19 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" | |
18 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" |
|
20 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" | |
19 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" |
|
21 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" | |
20 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" |
|
22 | DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" | |
21 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" |
|
23 | DEFINES += driver_Description="\"\\\"Driver description"\\\"\" | |
22 | DEFINES += driver_can_be_root=1 |
|
24 | DEFINES += driver_can_be_root=1 | |
23 | DEFINES += driver_can_be_child=0 |
|
25 | DEFINES += driver_can_be_child=0 | |
24 | DEFINES += driver_VID=0 |
|
26 | DEFINES += driver_VID=0 | |
25 | DEFINES += driver_PID=0 |
|
27 | DEFINES += driver_PID=0 | |
26 |
|
28 | |||
27 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ |
|
29 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ | |
28 |
|
30 | |||
29 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ |
|
31 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ | |
30 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so |
|
32 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so | |
31 |
|
33 | |||
32 | INCLUDEPATH += \ |
|
34 | INCLUDEPATH += \ | |
33 | $${PWD} \ |
|
35 | $${PWD} \ | |
34 | $$STARTDUNDEEPATH/inc \ |
|
36 | $$STARTDUNDEEPATH/inc \ | |
35 | StarDundee \ |
|
37 | StarDundee \ | |
36 | GR-ESB |
|
38 | GR-ESB | |
37 |
|
39 | |||
38 | HEADERS += \ |
|
40 | HEADERS += \ | |
39 | spwplugin.h \ |
|
41 | spwplugin.h \ | |
40 | StarDundee/stardundeespw_usb.h \ |
|
42 | StarDundee/stardundeespw_usb.h \ | |
41 | abstractspwbridge.h \ |
|
43 | abstractspwbridge.h \ | |
42 | spw.h \ |
|
44 | spw.h \ | |
43 | StarDundee/stardundeegui.h \ |
|
45 | StarDundee/stardundeegui.h \ | |
44 | SpwTcpPacketServer/spwtcppacketserver.h \ |
|
46 | SpwTcpPacketServer/spwtcppacketserver.h \ | |
45 | spwpywrapper.h \ |
|
47 | spwpywrapper.h \ | |
46 | GR-ESB/gr_esb_bridge.h \ |
|
48 | GR-ESB/gr_esb_bridge.h \ | |
47 | GR-ESB/gr_esb_ui.h |
|
49 | GR-ESB/gr_esb_ui.h | |
48 |
|
50 | |||
49 |
|
51 | |||
50 | SOURCES += \ |
|
52 | SOURCES += \ | |
51 | spwplugin.cpp \ |
|
53 | spwplugin.cpp \ | |
52 | StarDundee/stardundeespw_usb.cpp \ |
|
54 | StarDundee/stardundeespw_usb.cpp \ | |
53 | abstractspwbridge.cpp \ |
|
55 | abstractspwbridge.cpp \ | |
54 | StarDundee/stardundeegui.cpp \ |
|
56 | StarDundee/stardundeegui.cpp \ | |
55 | SpwTcpPacketServer/spwtcppacketserver.cpp \ |
|
57 | SpwTcpPacketServer/spwtcppacketserver.cpp \ | |
56 | spwpywrapper.cpp \ |
|
58 | spwpywrapper.cpp \ | |
57 | GR-ESB/gr_esb_bridge.cpp \ |
|
59 | GR-ESB/gr_esb_bridge.cpp \ | |
58 | GR-ESB/gr_esb_ui.cpp |
|
60 | GR-ESB/gr_esb_ui.cpp | |
59 |
|
61 | |||
60 | FORMS += \ |
|
62 | FORMS += \ | |
61 | StarDundee/stardundeeGUI.ui \ |
|
63 | StarDundee/stardundeeGUI.ui \ | |
62 | SpwTcpPacketServer/spwtcppacketserver.ui \ |
|
64 | SpwTcpPacketServer/spwtcppacketserver.ui \ | |
63 | GR-ESB/gr_esb_ui.ui |
|
65 | GR-ESB/gr_esb_ui.ui | |
64 |
|
66 | |||
65 | RESOURCES += \ |
|
67 | RESOURCES += \ | |
66 | spwRessources.qrc |
|
68 | spwRessources.qrc | |
67 |
|
69 | |||
68 |
|
70 | |||
69 |
|
71 | |||
70 |
|
72 | |||
71 |
|
73 | |||
72 |
|
74 | |||
73 |
|
75 | |||
74 |
|
76 | |||
75 |
|
77 | |||
76 |
|
78 | |||
77 |
|
79 | |||
78 |
|
80 | |||
79 |
|
81 | |||
80 |
|
82 | |||
81 |
|
83 | |||
82 |
|
84 | |||
83 |
|
85 | |||
84 |
|
86 | |||
85 |
|
87 | |||
86 |
|
88 | |||
87 |
|
89 | |||
88 |
|
90 | |||
89 |
|
91 | |||
90 |
|
92 |
General Comments 0
You need to be logged in to leave comments.
Login now