@@ -1,399 +1,395 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the LPPMON Software |
|
2 | -- This file is a part of the LPPMON Software | |
3 | -- Copyright (C) 2012, Laboratory of Plasma Physics - CNRS |
|
3 | -- Copyright (C) 2012, Laboratory of Plasma Physics - 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 : Paul LEROY |
|
19 | /*-- Author : Paul LEROY | |
20 | -- Mail : paul.leroy@lpp.polytechnique.fr |
|
20 | -- Mail : paul.leroy@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "rmapplugin.h" |
|
22 | #include "rmapplugin.h" | |
23 | #include <QHostAddress> |
|
23 | #include <QHostAddress> | |
24 | #include <QIODevice> |
|
24 | #include <QIODevice> | |
25 | #include <QApplication> |
|
25 | #include <QApplication> | |
26 | #include <rmappluginpythonwrapper.h> |
|
26 | #include <rmappluginpythonwrapper.h> | |
27 | #include <PythonQt.h> |
|
27 | #include <PythonQt.h> | |
28 | #include <QTimer> |
|
28 | #include <QTimer> | |
29 | #include <lppmonproxy.h> |
|
29 | #include <lppmonproxy.h> | |
30 |
|
30 | |||
31 | rmapplugin::rmapplugin(QWidget *parent) |
|
31 | rmapplugin::rmapplugin(QWidget *parent) | |
32 | :lppmonplugin(parent,false) |
|
32 | :lppmonplugin(parent,false) | |
33 | { |
|
33 | { | |
34 | this->UI = new rmapPluginUI(); |
|
34 | this->UI = new rmapPluginUI(); | |
35 | this->setWindowTitle(tr("RMAP and SPW Communication")); |
|
35 | this->setWindowTitle(tr("RMAP and SPW Communication")); | |
36 | this->setWidget((QWidget*)this->UI); |
|
36 | this->setWidget((QWidget*)this->UI); | |
37 |
|
37 | |||
38 | scanDone = false; |
|
38 | scanDone = false; | |
39 | timeCode = 0; |
|
39 | timeCode = 0; | |
40 | time_COARSE = 0; |
|
40 | time_COARSE = 0; | |
41 | time_FINE = 0; |
|
41 | time_FINE = 0; | |
42 | currentBridge = selectedBridgeIsUnknown; |
|
42 | currentBridge = selectedBridgeIsUnknown; | |
43 |
|
43 | |||
44 | connectPythonWrapper(); |
|
44 | connectPythonWrapper(); | |
45 |
|
45 | |||
46 | //************** |
|
46 | //************** | |
47 | // get a smart pointer to the __main__ module of the Python interpreter |
|
47 | // get a smart pointer to the __main__ module of the Python interpreter | |
48 | PythonQtObjectPtr context = PythonQt::self()->getMainModule(); |
|
48 | PythonQtObjectPtr context = PythonQt::self()->getMainModule(); | |
49 | // add a QObject as variable of name "BUTTON_rmapOpenCommunication" to the namespace of the __main__ module |
|
49 | // add a QObject as variable of name "BUTTON_rmapOpenCommunication" to the namespace of the __main__ module | |
50 | context.addObject("BUTTON_rmapOpenCommunication", UI->rmapOpenCommunicationButton); |
|
50 | context.addObject("BUTTON_rmapOpenCommunication", UI->rmapOpenCommunicationButton); | |
51 | context.addObject("BUTTON_rmapCloseCommunication", UI->rmapCloseCommunicationButton); |
|
51 | context.addObject("BUTTON_rmapCloseCommunication", UI->rmapCloseCommunicationButton); | |
52 | context.addObject("BUTTON_selectStarDundee", UI->selectStarDundee_BUTTON); |
|
52 | context.addObject("BUTTON_selectStarDundee", UI->selectStarDundee_BUTTON); | |
53 | context.addObject("BUTTON_selectGRESB", UI->selectGRESB_BUTTON); |
|
53 | context.addObject("BUTTON_selectGRESB", UI->selectGRESB_BUTTON); | |
54 | context.addObject("GRESB_Bridge", UI->gresbBridge); |
|
54 | context.addObject("GRESB_Bridge", UI->gresbBridge); | |
55 | //************** |
|
55 | //************** | |
56 |
|
56 | |||
57 | connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge())); |
|
57 | connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge())); | |
58 | connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge())); |
|
58 | connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge())); | |
59 | connect(this, SIGNAL( |
|
59 | connect(this, SIGNAL( | |
60 | updateStatistics(unsigned char,unsigned char,unsigned char,unsigned char,uint,uint,uint,uint) |
|
60 | updateStatistics(unsigned char,unsigned char,unsigned char,unsigned char,uint,uint,uint,uint) | |
61 | ), |
|
61 | ), | |
62 | this->UI->tmStatistics, SLOT( |
|
62 | this->UI->tmStatistics, SLOT( | |
63 | updateStatistics(unsigned char,unsigned char,unsigned char,unsigned char,uint,uint,uint,uint) |
|
63 | updateStatistics(unsigned char,unsigned char,unsigned char,unsigned char,uint,uint,uint,uint) | |
64 | )); |
|
64 | )); | |
65 |
|
65 | |||
66 | //****** |
|
66 | //****** | |
67 | // GRESB |
|
67 | // GRESB | |
68 | connect(this->UI->gresbBridge, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); |
|
68 | connect(this->UI->gresbBridge, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
69 | connect(this->UI->gresbBridge, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); |
|
69 | connect(this->UI->gresbBridge, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); | |
70 | connect(this->UI->gresbBridge, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); |
|
70 | connect(this->UI->gresbBridge, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); | |
71 | connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->gresbBridge, SLOT(ccsdsPacketIsProcessed())); |
|
71 | connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->gresbBridge, SLOT(ccsdsPacketIsProcessed())); | |
72 | connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), |
|
72 | connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), | |
73 | this->UI->gresbBridge, SLOT(targetHasChanged(int))); |
|
73 | this->UI->gresbBridge, SLOT(targetHasChanged(int))); | |
74 | connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), |
|
74 | connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), | |
75 | this->UI->gresbBridge, SLOT(sourceHasChanged(int))); |
|
75 | this->UI->gresbBridge, SLOT(sourceHasChanged(int))); | |
76 | connect(this->UI->gresbBridge, SIGNAL(sendPacket(TMPacketToRead*)), |
|
76 | connect(this->UI->gresbBridge, SIGNAL(sendPacket(TMPacketToRead*)), | |
77 | this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection); |
|
77 | this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection); | |
78 |
|
78 | |||
79 | //************ |
|
79 | //************ | |
80 | // Star Dundee |
|
80 | // Star Dundee | |
81 | connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); |
|
81 | connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
82 | connect(this->UI->starDundee, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); |
|
82 | connect(this->UI->starDundee, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); | |
83 | connect(this->UI->starDundee, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); |
|
83 | connect(this->UI->starDundee, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); | |
84 | connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->starDundee, SLOT(ccsdsPacketIsProcessed())); |
|
84 | connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->starDundee, SLOT(ccsdsPacketIsProcessed())); | |
85 | connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), |
|
85 | connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), | |
86 | this->UI->starDundee, SLOT(targetHasChanged(int))); |
|
86 | this->UI->starDundee, SLOT(targetHasChanged(int))); | |
87 | connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), |
|
87 | connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), | |
88 | this->UI->starDundee, SLOT(sourceHasChanged(int))); |
|
88 | this->UI->starDundee, SLOT(sourceHasChanged(int))); | |
89 | connect(this, SIGNAL(spaceWireLinkNumberHasChanged(unsigned char)), |
|
89 | connect(this, SIGNAL(spaceWireLinkNumberHasChanged(unsigned char)), | |
90 | this->UI->starDundee, SLOT(spaceWireLinkHasChanged(unsigned char)), Qt::DirectConnection); |
|
90 | this->UI->starDundee, SLOT(spaceWireLinkHasChanged(unsigned char)), Qt::DirectConnection); | |
91 | connect(this->UI->starDundee, SIGNAL(sendPacket(TMPacketToRead*)), |
|
91 | connect(this->UI->starDundee, SIGNAL(sendPacket(TMPacketToRead*)), | |
92 | this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection); |
|
92 | this, SLOT(receivePacketFromBridge(TMPacketToRead*)), Qt::DirectConnection); | |
93 |
|
93 | |||
94 | connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge))); |
|
94 | connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge))); | |
95 |
|
95 | |||
96 | ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->generalCCSDSPacketStore); |
|
96 | ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->generalCCSDSPacketStore); | |
97 |
|
97 | |||
98 | //************ |
|
98 | //************ | |
99 | // LFR ACtions |
|
99 | // LFR ACtions | |
100 | connect(this->UI->lfrActions, SIGNAL(WriteSPWSig(char*,uint,char,char)), |
|
100 | connect(this->UI->lfrActions, SIGNAL(WriteSPWSig(char*,uint,char,char)), | |
101 | this, SLOT(WriteSPW(char*,uint,char,char))); |
|
101 | this, SLOT(WriteSPW(char*,uint,char,char))); | |
102 |
|
102 | |||
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | rmapplugin::~rmapplugin() |
|
105 | rmapplugin::~rmapplugin() | |
106 | { |
|
106 | { | |
107 | switch(currentBridge) |
|
107 | switch(currentBridge) | |
108 | { |
|
108 | { | |
109 | case selectedBridgeIsGRESB : |
|
109 | case selectedBridgeIsGRESB : | |
110 | this->UI->gresbBridge->writeSettings(); |
|
110 | this->UI->gresbBridge->writeSettings(); | |
111 | break; |
|
111 | break; | |
112 | case selectedBridgeIsStarDundee : |
|
112 | case selectedBridgeIsStarDundee : | |
113 | break; |
|
113 | break; | |
114 | default: |
|
114 | default: | |
115 | break; |
|
115 | break; | |
116 | } |
|
116 | } | |
117 | this->UI->tmStatistics->writeSettings(); |
|
117 | this->UI->tmStatistics->writeSettings(); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | unsigned int rmapplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
120 | unsigned int rmapplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
121 | { |
|
121 | { | |
122 | unsigned int result; |
|
122 | unsigned int result; | |
123 | switch(currentBridge) |
|
123 | switch(currentBridge) | |
124 | { |
|
124 | { | |
125 | case selectedBridgeIsGRESB : |
|
125 | case selectedBridgeIsGRESB : | |
126 | result = UI->gresbBridge->Write(Value, count, address); |
|
126 | result = UI->gresbBridge->Write(Value, count, address); | |
127 | break; |
|
127 | break; | |
128 | case selectedBridgeIsStarDundee : |
|
128 | case selectedBridgeIsStarDundee : | |
129 | result = UI->starDundee->Write(Value, count, address); |
|
129 | result = UI->starDundee->Write(Value, count, address); | |
130 | break; |
|
130 | break; | |
131 | default: |
|
131 | default: | |
132 | result = 1; |
|
132 | result = 1; | |
133 | break; |
|
133 | break; | |
134 | } |
|
134 | } | |
135 | return result; |
|
135 | return result; | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | unsigned int rmapplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
138 | unsigned int rmapplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
139 | { |
|
139 | { | |
140 | unsigned int result; |
|
140 | unsigned int result; | |
141 | switch(currentBridge) |
|
141 | switch(currentBridge) | |
142 | { |
|
142 | { | |
143 | case selectedBridgeIsGRESB : |
|
143 | case selectedBridgeIsGRESB : | |
144 | result = UI->gresbBridge->Read(Value, count, address); |
|
144 | result = UI->gresbBridge->Read(Value, count, address); | |
145 | break; |
|
145 | break; | |
146 | case selectedBridgeIsStarDundee : |
|
146 | case selectedBridgeIsStarDundee : | |
147 | result = UI->starDundee->Read(Value, count, address); |
|
147 | result = UI->starDundee->Read(Value, count, address); | |
148 | break; |
|
148 | break; | |
149 | default: |
|
149 | default: | |
150 | result = 1; |
|
150 | result = 1; | |
151 | break; |
|
151 | break; | |
152 | } |
|
152 | } | |
153 | return result; |
|
153 | return result; | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | //////// |
|
156 | //////// | |
157 | // SLOTS |
|
157 | // SLOTS | |
158 |
|
158 | |||
159 | unsigned int rmapplugin::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) // SLOT |
|
159 | unsigned int rmapplugin::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) // SLOT | |
160 | { |
|
160 | { | |
161 | unsigned int result; |
|
161 | unsigned int result; | |
162 | switch(currentBridge) |
|
162 | switch(currentBridge) | |
163 | { |
|
163 | { | |
164 | case selectedBridgeIsGRESB : |
|
164 | case selectedBridgeIsGRESB : | |
165 | result = UI->gresbBridge->WriteSPW(Value, count, targetLogicalAddress, userApplication); |
|
165 | result = UI->gresbBridge->WriteSPW(Value, count, targetLogicalAddress, userApplication); | |
166 | break; |
|
166 | break; | |
167 | case selectedBridgeIsStarDundee : |
|
167 | case selectedBridgeIsStarDundee : | |
168 | result = UI->starDundee->WriteSPW(Value, count, targetLogicalAddress, userApplication); |
|
168 | result = UI->starDundee->WriteSPW(Value, count, targetLogicalAddress, userApplication); | |
169 | break; |
|
169 | break; | |
170 | default: |
|
170 | default: | |
171 | result = 1; |
|
171 | result = 1; | |
172 | break; |
|
172 | break; | |
173 | } |
|
173 | } | |
174 | return result; |
|
174 | return result; | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | void rmapplugin::openBridge() |
|
177 | void rmapplugin::openBridge() | |
178 | { |
|
178 | { | |
179 | switch(currentBridge) |
|
179 | switch(currentBridge) | |
180 | { |
|
180 | { | |
181 | case selectedBridgeIsGRESB : |
|
181 | case selectedBridgeIsGRESB : | |
182 | this->Connected = this->UI->gresbBridge->Open(); |
|
182 | this->Connected = this->UI->gresbBridge->Open(); | |
183 | break; |
|
183 | break; | |
184 | case selectedBridgeIsStarDundee : |
|
184 | case selectedBridgeIsStarDundee : | |
185 | this->Connected = this->UI->starDundee->Open(); |
|
185 | this->Connected = this->UI->starDundee->Open(); | |
186 | break; |
|
186 | break; | |
187 | default: |
|
187 | default: | |
188 | break; |
|
188 | break; | |
189 | } |
|
189 | } | |
190 | if((this->scanDone==false)&&(this->Connected == true)) |
|
190 | if((this->scanDone==false)&&(this->Connected == true)) | |
191 | { |
|
191 | { | |
192 | lppmonproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
192 | lppmonproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
193 | this->scanDone=true; |
|
193 | this->scanDone=true; | |
194 | } |
|
194 | } | |
195 | emit activateSig( this->Connected ); |
|
195 | emit activateSig( this->Connected ); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | void rmapplugin::closeBridge() |
|
198 | void rmapplugin::closeBridge() | |
199 | { |
|
199 | { | |
200 | switch(currentBridge) |
|
200 | switch(currentBridge) | |
201 | { |
|
201 | { | |
202 | case selectedBridgeIsGRESB : |
|
202 | case selectedBridgeIsGRESB : | |
203 | this->UI->gresbBridge->Close(); |
|
203 | this->UI->gresbBridge->Close(); | |
204 | break; |
|
204 | break; | |
205 | case selectedBridgeIsStarDundee : |
|
205 | case selectedBridgeIsStarDundee : | |
206 | this->UI->starDundee->Close(); |
|
206 | this->UI->starDundee->Close(); | |
207 | break; |
|
207 | break; | |
208 | default: |
|
208 | default: | |
209 | break; |
|
209 | break; | |
210 | } |
|
210 | } | |
211 | this->Connected = false; |
|
211 | this->Connected = false; | |
212 | emit activateSig( this->Connected ); |
|
212 | emit activateSig( this->Connected ); | |
213 | } |
|
213 | } | |
214 |
|
214 | |||
215 | void rmapplugin::RMAP_write_reply_setText(QString text) |
|
215 | void rmapplugin::RMAP_write_reply_setText(QString text) | |
216 | { |
|
216 | { | |
217 | this->UI->RMAP_write_reply->setText(text); |
|
217 | this->UI->RMAP_write_reply->setText(text); | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | void rmapplugin::appendToLog(QString text) |
|
220 | void rmapplugin::appendToLog(QString text) | |
221 | { |
|
221 | { | |
222 | APPENDTOLOG(text); |
|
222 | APPENDTOLOG(text); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | void rmapplugin::setValueTargetAddress(unsigned char newAddress) |
|
225 | void rmapplugin::setValueTargetAddress(unsigned char newAddress) | |
226 | { |
|
226 | { | |
227 | this->UI->rmapTargetLogicalAddressSpinBox->setValue(newAddress); |
|
227 | this->UI->rmapTargetLogicalAddressSpinBox->setValue(newAddress); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void rmapplugin::setValueSourceAddress(unsigned char newAddress) |
|
230 | void rmapplugin::setValueSourceAddress(unsigned char newAddress) | |
231 | { |
|
231 | { | |
232 | this->UI->rmapSourceLogicalAddressSpinBox->setValue(newAddress); |
|
232 | this->UI->rmapSourceLogicalAddressSpinBox->setValue(newAddress); | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | void rmapplugin::setValueSpaceWireLinkNumber(unsigned char linkNumber) |
|
235 | void rmapplugin::setValueSpaceWireLinkNumber(unsigned char linkNumber) | |
236 | { |
|
236 | { | |
237 | // this->UI->spwLinkSpinBox->setValue( linkNumber ); |
|
237 | // this->UI->spwLinkSpinBox->setValue( linkNumber ); | |
238 | emit this->spaceWireLinkNumberHasChanged( linkNumber ); |
|
238 | emit this->spaceWireLinkNumberHasChanged( linkNumber ); | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | void rmapplugin::receivePacketFromBridge(TMPacketToRead *packet) |
|
241 | void rmapplugin::receivePacketFromBridge(TMPacketToRead *packet) | |
242 | { |
|
242 | { | |
243 | preProcessPacket(packet); |
|
243 | preProcessPacket(packet); | |
244 |
|
244 | |||
245 | // Send the packet to the TM echo bridge for processing |
|
245 | // Send the packet to the TM echo bridge for processing | |
246 | this->UI->tmEchoBridge->sendTMPacketLESIA(packet); |
|
246 | this->UI->tmEchoBridge->sendTMPacketLESIA(packet); | |
247 |
|
247 | |||
248 | this->generalCCSDSPacketStore.append(packet); |
|
248 | this->generalCCSDSPacketStore.append(packet); | |
249 | if (this->generalCCSDSPacketStore.size() > 200) |
|
249 | if (this->generalCCSDSPacketStore.size() > 200) | |
250 | { |
|
250 | { | |
251 | this->generalCCSDSPacketStore.erase(generalCCSDSPacketStore.begin(), |
|
251 | this->generalCCSDSPacketStore.erase(generalCCSDSPacketStore.begin(), | |
252 | generalCCSDSPacketStore.begin() + 100); |
|
252 | generalCCSDSPacketStore.begin() + 100); | |
253 | } |
|
253 | } | |
254 | this->UI->nbPacketInStore->setText("nb packets in store: " + QString::number(generalCCSDSPacketStore.size())); |
|
254 | this->UI->nbPacketInStore->setText("nb packets in store: " + QString::number(generalCCSDSPacketStore.size())); | |
255 | processPacketStore(); |
|
255 | processPacketStore(); | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | void rmapplugin::preProcessPacket(TMPacketToRead *packet) |
|
258 | void rmapplugin::preProcessPacket(TMPacketToRead *packet) | |
259 | { |
|
259 | { | |
260 | unsigned char pid = 0; |
|
260 | unsigned char pid = 0; | |
261 | unsigned char cat = 0; |
|
261 | unsigned char cat = 0; | |
262 | unsigned char typ = 0; |
|
262 | unsigned char typ = 0; | |
263 | unsigned char sub = 0; |
|
263 | unsigned char sub = 0; | |
264 | unsigned int sid = 0; |
|
264 | unsigned int sid = 0; | |
265 | unsigned int length = 0; |
|
265 | unsigned int length = 0; | |
266 | unsigned int coarse_t = 0; |
|
266 | unsigned int coarse_t = 0; | |
267 | unsigned int fine_t = 0; |
|
267 | unsigned int fine_t = 0; | |
268 |
|
268 | |||
269 | //********************************* |
|
269 | //********************************* | |
270 | // get the parameters of the packet |
|
270 | // get the parameters of the packet | |
271 | pid = this->UI->tmStatistics->getPID( packet ); |
|
271 | pid = this->UI->tmStatistics->getPID( packet ); | |
272 | cat = this->UI->tmStatistics->getCAT( packet ); |
|
272 | cat = this->UI->tmStatistics->getCAT( packet ); | |
273 | typ = this->UI->tmStatistics->getTYPE( packet ); |
|
273 | typ = this->UI->tmStatistics->getTYPE( packet ); | |
274 | sub = this->UI->tmStatistics->getSUBTYPE( packet ); |
|
274 | sub = this->UI->tmStatistics->getSUBTYPE( packet ); | |
275 | length = this->UI->tmStatistics->getLENGTH( packet ); |
|
275 | length = this->UI->tmStatistics->getLENGTH( packet ); | |
276 | coarse_t = this->UI->tmStatistics->getCoarseTime( packet ); |
|
276 | coarse_t = this->UI->tmStatistics->getCoarseTime( packet ); | |
277 | fine_t = this->UI->tmStatistics->getFineTime( packet ); |
|
277 | fine_t = this->UI->tmStatistics->getFineTime( packet ); | |
278 | sid = this->UI->tmStatistics->getSID( packet, pid, cat, typ, sub ); |
|
278 | sid = this->UI->tmStatistics->getSID( packet, pid, cat, typ, sub ); | |
279 |
|
279 | |||
280 | emit updateStatistics(pid, cat, typ, sub, sid, length, coarse_t, fine_t); |
|
280 | emit updateStatistics(pid, cat, typ, sub, sid, length, coarse_t, fine_t); | |
281 |
|
281 | |||
282 | //********************************************** |
|
282 | //********************************************** | |
283 | // if the packet is a parameter dump, display it |
|
283 | // if the packet is a parameter dump, display it | |
284 | if ( (typ == TM_TYPE_PARAMETER_DUMP) & (sub == TM_SUBTYPE_PARAMETER_DUMP) & (sid == SID_PARAMETER_DUMP) ) |
|
284 | if ( (typ == TM_TYPE_PARAMETER_DUMP) & (sub == TM_SUBTYPE_PARAMETER_DUMP) & (sid == SID_PARAMETER_DUMP) ) | |
285 | this->UI->lfrActions->parameterDump->updateParameterDump(packet); |
|
285 | this->UI->lfrActions->parameterDump->updateParameterDump(packet); | |
286 |
|
286 | |||
287 | if ( (typ == TC_TYPE_TIME) & (sub == TC_SUBTYPE_UPDT_TIME) ) // RE-EMIT THE TC_LFR_UPDATE_TIME PACKET |
|
287 | if ( (typ == TC_TYPE_TIME) & (sub == TC_SUBTYPE_UPDT_TIME) ) // RE-EMIT THE TC_LFR_UPDATE_TIME PACKET | |
288 | { |
|
288 | { | |
289 | emit spaceWireLinkNumberHasChanged( LFR_SPACEWIRE_LINK ); |
|
289 | emit spaceWireLinkNumberHasChanged( LFR_SPACEWIRE_LINK ); | |
290 | WriteSPW( (char *) &packet->Value[CCSDS_PROTOCOLE_EXTRA_BYTES], |
|
290 | WriteSPW( (char *) &packet->Value[CCSDS_PROTOCOLE_EXTRA_BYTES], | |
291 | packet->size - CCSDS_PROTOCOLE_EXTRA_BYTES, |
|
291 | packet->size - CCSDS_PROTOCOLE_EXTRA_BYTES, | |
292 | DEFAULT_TARGET, CCSDS_USER_APP ); |
|
292 | DEFAULT_TARGET, CCSDS_USER_APP ); | |
293 | } |
|
293 | } | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | void rmapplugin::nbPacketHasChanged(int nb) |
|
296 | void rmapplugin::nbPacketHasChanged(int nb) | |
297 | { |
|
297 | { | |
298 | this->UI->nbPacketInStore->setText("nb packets in store: " + QString::number(nb)); |
|
298 | this->UI->nbPacketInStore->setText("nb packets in store: " + QString::number(nb)); | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | ///////////////////// |
|
301 | ///////////////////// | |
302 | // INTERNAL FUNCTIONS |
|
302 | // INTERNAL FUNCTIONS | |
303 |
|
303 | |||
304 | void rmapplugin::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) // SLOT |
|
304 | void rmapplugin::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) // SLOT | |
305 | { |
|
305 | { | |
306 | QString message; |
|
306 | QString message; | |
307 | unsigned int fine_time_value = 0; |
|
307 | unsigned int fine_time_value = 0; | |
308 | fine_time_value = ((unsigned int) ccsdsPacket[7]<<24) |
|
308 | fine_time_value = ((unsigned int) ccsdsPacket[7]<<24) | |
309 | + ((unsigned int) ccsdsPacket[6]<<16) |
|
309 | + ((unsigned int) ccsdsPacket[6]<<16) | |
310 | + ((unsigned int) ccsdsPacket[5]<<8) |
|
310 | + ((unsigned int) ccsdsPacket[5]<<8) | |
311 | + ((unsigned int) ccsdsPacket[4]); |
|
311 | + ((unsigned int) ccsdsPacket[4]); | |
312 | message.append(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": "); |
|
312 | message.append(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": "); | |
313 | message.append("size " |
|
313 | message.append("size " | |
314 | + QString::number(size) |
|
314 | + QString::number(size) | |
315 | +" *** header " |
|
315 | +" *** header " | |
316 | + QString::number(ccsdsPacket[0], 16) |
|
316 | + QString::number(ccsdsPacket[0], 16) | |
317 | + " " |
|
317 | + " " | |
318 | + QString::number(ccsdsPacket[1], 16) |
|
318 | + QString::number(ccsdsPacket[1], 16) | |
319 | + " " |
|
319 | + " " | |
320 | + QString::number(ccsdsPacket[2], 16) |
|
320 | + QString::number(ccsdsPacket[2], 16) | |
321 | + " " |
|
321 | + " " | |
322 | + QString::number(ccsdsPacket[3], 16) |
|
322 | + QString::number(ccsdsPacket[3], 16) | |
323 | + " *** coarse time " |
|
323 | + " *** coarse time " | |
324 | + QString::number(fine_time_value)); |
|
324 | + QString::number(fine_time_value)); | |
325 | //+ QString::number(ccsdsPacket[4], 16) |
|
325 | //+ QString::number(ccsdsPacket[4], 16) | |
326 | //+" " |
|
326 | //+" " | |
327 | //+ QString::number(ccsdsPacket[5], 16) |
|
327 | //+ QString::number(ccsdsPacket[5], 16) | |
328 | //+" " |
|
328 | //+" " | |
329 | //+ QString::number(ccsdsPacket[6], 16) |
|
329 | //+ QString::number(ccsdsPacket[6], 16) | |
330 | //+" " |
|
330 | //+" " | |
331 | //+ QString::number(ccsdsPacket[7], 16)); |
|
331 | //+ QString::number(ccsdsPacket[7], 16)); | |
332 | displayOnConsole(message); |
|
332 | displayOnConsole(message); | |
333 | //((rmappluginPythonWrapper*)this->pyObject)->storeCCSDSPacket(ccsdsPacket, size); |
|
333 | //((rmappluginPythonWrapper*)this->pyObject)->storeCCSDSPacket(ccsdsPacket, size); | |
334 | emit ccsdsPacketIsProcessed(); |
|
334 | emit ccsdsPacketIsProcessed(); | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | void rmapplugin::processPacketStore() |
|
337 | void rmapplugin::processPacketStore() | |
338 | { |
|
338 | { | |
339 | ((rmappluginPythonWrapper*)this->pyObject)->processPacketStore(); |
|
339 | ((rmappluginPythonWrapper*)this->pyObject)->processPacketStore(); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | int rmapplugin::fetchPacket() |
|
342 | int rmapplugin::fetchPacket() | |
343 | { |
|
343 | { | |
344 | int ret = 0; |
|
344 | int ret = 0; | |
345 |
|
345 | |||
346 | switch(currentBridge) |
|
346 | switch(currentBridge) | |
347 | { |
|
347 | { | |
348 | case selectedBridgeIsGRESB : |
|
348 | case selectedBridgeIsGRESB : | |
349 | break; |
|
349 | break; | |
350 | case selectedBridgeIsStarDundee : |
|
350 | case selectedBridgeIsStarDundee : | |
351 | ret = this->UI->starDundee->receiveSPWPacketLoop(); |
|
351 | ret = this->UI->starDundee->receiveSPWPacketLoop(); | |
352 | break; |
|
352 | break; | |
353 | default: |
|
353 | default: | |
354 | break; |
|
354 | break; | |
355 | } |
|
355 | } | |
356 |
|
356 | |||
357 | return ret; |
|
357 | return ret; | |
358 | } |
|
358 | } | |
359 |
|
359 | |||
360 | void rmapplugin::connectPythonWrapper() |
|
360 | void rmapplugin::connectPythonWrapper() | |
361 | { |
|
361 | { | |
362 | this->pyObject = new rmappluginPythonWrapper(); |
|
362 | this->pyObject = new rmappluginPythonWrapper(); | |
363 | connect( this->pyObject, SIGNAL( ReadSig(uint*,uint,uint) ), this, SLOT( Read(uint*,uint,uint) ) ); |
|
363 | connect( this->pyObject, SIGNAL( ReadSig(uint*,uint,uint) ), this, SLOT( Read(uint*,uint,uint) ) ); | |
364 | connect( this->pyObject, SIGNAL( WriteSig(uint*,uint,uint) ), this, SLOT( Write(uint*,uint,uint) ) ); |
|
364 | connect( this->pyObject, SIGNAL( WriteSig(uint*,uint,uint) ), this, SLOT( Write(uint*,uint,uint) ) ); | |
365 | //** |
|
365 | //** | |
366 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( WriteSPWSig(char*,uint,char,char) ), |
|
366 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( WriteSPWSig(char*,uint,char,char) ), | |
367 | this, SLOT( WriteSPW(char*,uint,char,char) ), Qt::DirectConnection ); |
|
367 | this, SLOT( WriteSPW(char*,uint,char,char) ), Qt::DirectConnection ); | |
368 | //** |
|
368 | //** | |
369 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateTargetLogicalAddress(unsigned char) ), |
|
369 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateTargetLogicalAddress(unsigned char) ), | |
370 | this, SLOT( setValueTargetAddress(unsigned char) ) ); |
|
370 | this, SLOT( setValueTargetAddress(unsigned char) ) ); | |
371 | //** |
|
371 | //** | |
372 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateSourceLogicalAddress(unsigned char) ), |
|
372 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateSourceLogicalAddress(unsigned char) ), | |
373 | this, SLOT( setValueSourceAddress(unsigned char) ) ); |
|
373 | this, SLOT( setValueSourceAddress(unsigned char) ) ); | |
374 | //** |
|
374 | //** | |
375 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateSpaceWireLinkNumber(unsigned char) ), |
|
375 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateSpaceWireLinkNumber(unsigned char) ), | |
376 | this, SLOT( setValueSpaceWireLinkNumber(unsigned char) ) ); |
|
376 | this, SLOT( setValueSpaceWireLinkNumber(unsigned char) ) ); | |
377 | //** |
|
377 | //** | |
378 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sendMessage(QString)), |
|
378 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sendMessage(QString)), | |
379 | this, SLOT(displayOnConsole(QString)) ); |
|
379 | this, SLOT(displayOnConsole(QString)) ); | |
380 | //** |
|
380 | //** | |
381 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(fetchPacketSig()), |
|
381 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(fetchPacketSig()), | |
382 | this, SLOT(fetchPacket()), Qt::DirectConnection ); |
|
382 | this, SLOT(fetchPacket()), Qt::DirectConnection ); | |
383 | //*** |
|
383 | //*** | |
384 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(nbPacketHasChanged(int)), |
|
384 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(nbPacketHasChanged(int)), | |
385 | this, SLOT(nbPacketHasChanged(int))); |
|
385 | this, SLOT(nbPacketHasChanged(int))); | |
386 |
|
386 | |||
387 | //********** |
|
387 | //********** | |
388 | // TIMECODES |
|
388 | // TIMECODES | |
389 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendOneTimecode()), |
|
389 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendOneTimecode()), | |
390 | this->UI->starDundee, SLOT(sendOneTimecode()) ); |
|
390 | this->UI->starDundee, SLOT(sendOneTimecode()) ); | |
391 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendTimecodePeriodically()), |
|
391 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendTimecodePeriodically(unsigned char)), | |
392 | this->UI->starDundee, SLOT(sendTimecodePeriodically()) ); |
|
392 | this->UI->starDundee, SLOT(startSendingTimecodePeriodically(unsigned char)) ); | |
393 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendOneTimePacketAndOneTimecode()), |
|
|||
394 | this->UI->starDundee, SLOT(sendOneTimePacketAndOneTimecode()) ); |
|
|||
395 | connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sig_sendOneTimePacketAndTimecodePeriodically()), |
|
|||
396 | this->UI->starDundee, SLOT(sendOneTimePacketAndTimecodePeriodically()) ); |
|
|||
397 | } |
|
393 | } | |
398 |
|
394 | |||
399 |
|
395 |
@@ -1,165 +1,167 | |||||
1 | #include "rmappluginpythonwrapper.h" |
|
1 | #include "rmappluginpythonwrapper.h" | |
2 | #include <math.h> |
|
2 | #include <math.h> | |
3 | #include <QApplication> |
|
3 | #include <QApplication> | |
4 |
|
4 | |||
5 | rmappluginPythonWrapper::rmappluginPythonWrapper(lppmonplugin *parent) : |
|
5 | rmappluginPythonWrapper::rmappluginPythonWrapper(lppmonplugin *parent) : | |
6 | genericPySysdriver(parent) |
|
6 | genericPySysdriver(parent) | |
7 | { |
|
7 | { | |
8 | timer = new QTimer; |
|
8 | timer = new QTimer; | |
9 | timer->setSingleShot(true); |
|
9 | timer->setSingleShot(true); | |
10 | connect(timer, SIGNAL(timeout()), this, SLOT(sendTC())); |
|
10 | connect(timer, SIGNAL(timeout()), this, SLOT(sendTC())); | |
11 | connect(this, SIGNAL(activateTCLoopSig()), this, SLOT(sendTCLoop())); |
|
11 | connect(this, SIGNAL(activateTCLoopSig()), this, SLOT(sendTCLoop())); | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | QList<QVariant> rmappluginPythonWrapper::ReadSPW(unsigned int size) // size is not used |
|
14 | QList<QVariant> rmappluginPythonWrapper::ReadSPW(unsigned int size) // size is not used | |
15 | { |
|
15 | { | |
16 | QList<QVariant> result; |
|
16 | QList<QVariant> result; | |
17 | TMPacketToRead *ccsdsPacket; |
|
17 | TMPacketToRead *ccsdsPacket; | |
18 |
|
18 | |||
19 | if (!ccsdsPacketStore->isEmpty()) |
|
19 | if (!ccsdsPacketStore->isEmpty()) | |
20 | { |
|
20 | { | |
21 | ccsdsPacket = ccsdsPacketStore->takeFirst(); |
|
21 | ccsdsPacket = ccsdsPacketStore->takeFirst(); | |
22 | for(unsigned int i = 0;i<ccsdsPacket->size;i++) |
|
22 | for(unsigned int i = 0;i<ccsdsPacket->size;i++) | |
23 | { |
|
23 | { | |
24 | result.append((QVariant)ccsdsPacket->Value[i]); |
|
24 | result.append((QVariant)ccsdsPacket->Value[i]); | |
25 | } |
|
25 | } | |
26 | delete(ccsdsPacket); |
|
26 | delete(ccsdsPacket); | |
27 | } |
|
27 | } | |
28 | emit nbPacketHasChanged(ccsdsPacketStore->size()); |
|
28 | emit nbPacketHasChanged(ccsdsPacketStore->size()); | |
29 | return result; |
|
29 | return result; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | void rmappluginPythonWrapper::WriteSPW(QList<int> dataList) |
|
32 | void rmappluginPythonWrapper::WriteSPW(QList<int> dataList) | |
33 | { |
|
33 | { | |
34 | char targetLogicalAddress; |
|
34 | char targetLogicalAddress; | |
35 | char userApplication; |
|
35 | char userApplication; | |
36 | unsigned int count; |
|
36 | unsigned int count; | |
37 | char *Value; |
|
37 | char *Value; | |
38 |
|
38 | |||
39 | unsigned char data[dataList.count()]; |
|
39 | unsigned char data[dataList.count()]; | |
40 |
|
40 | |||
41 | for(int i = 0; i<dataList.count(); i++) // get the data as unsigned char |
|
41 | for(int i = 0; i<dataList.count(); i++) // get the data as unsigned char | |
42 | { |
|
42 | { | |
43 | data[i] = (unsigned char)dataList.at(i); |
|
43 | data[i] = (unsigned char)dataList.at(i); | |
44 | } |
|
44 | } | |
45 | // read the first bytes of the data to get the targetLogicalAddress and the userApplication parameters |
|
45 | // read the first bytes of the data to get the targetLogicalAddress and the userApplication parameters | |
46 | targetLogicalAddress = data[0]; |
|
46 | targetLogicalAddress = data[0]; | |
47 | userApplication = data[3]; |
|
47 | userApplication = data[3]; | |
48 |
|
48 | |||
49 | count = dataList.count() - 4; // the CCSDS header (4 bytes) is added by LPPMON |
|
49 | count = dataList.count() - 4; // the CCSDS header (4 bytes) is added by LPPMON | |
50 | Value = (char*) &data[4]; |
|
50 | Value = (char*) &data[4]; | |
51 |
|
51 | |||
52 | emit WriteSPWSig(Value, count, targetLogicalAddress, userApplication); |
|
52 | emit WriteSPWSig(Value, count, targetLogicalAddress, userApplication); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void rmappluginPythonWrapper::WriteSPWDelay(QList<int> dataList, unsigned int delay) |
|
55 | void rmappluginPythonWrapper::WriteSPWDelay(QList<int> dataList, unsigned int delay) | |
56 | { |
|
56 | { | |
57 | char targetLogicalAddress; |
|
57 | char targetLogicalAddress; | |
58 | char userApplication; |
|
58 | char userApplication; | |
59 | unsigned int count; |
|
59 | unsigned int count; | |
60 | char *Value; |
|
60 | char *Value; | |
61 | TCPacketToSend *packet; |
|
61 | TCPacketToSend *packet; | |
62 |
|
62 | |||
63 | unsigned char data[dataList.count()]; |
|
63 | unsigned char data[dataList.count()]; | |
64 |
|
64 | |||
65 | for(int i = 0; i<dataList.count(); i++) // get the data as unsigned char |
|
65 | for(int i = 0; i<dataList.count(); i++) // get the data as unsigned char | |
66 | { |
|
66 | { | |
67 | data[i] = (unsigned char)dataList.at(i); |
|
67 | data[i] = (unsigned char)dataList.at(i); | |
68 | } |
|
68 | } | |
69 | // read the first bytes of the data to get the targetLogicalAddress and the userApplication parameters |
|
69 | // read the first bytes of the data to get the targetLogicalAddress and the userApplication parameters | |
70 | targetLogicalAddress = data[0]; |
|
70 | targetLogicalAddress = data[0]; | |
71 | userApplication = data[3]; |
|
71 | userApplication = data[3]; | |
72 |
|
72 | |||
73 | count = dataList.count() - 4; // the CCSDS header (4 bytes) is added by LPPMON |
|
73 | count = dataList.count() - 4; // the CCSDS header (4 bytes) is added by LPPMON | |
74 | Value = (char*) &data[4]; |
|
74 | Value = (char*) &data[4]; | |
75 |
|
75 | |||
76 | packet = new TCPacketToSend(Value, count, targetLogicalAddress, userApplication, delay); |
|
76 | packet = new TCPacketToSend(Value, count, targetLogicalAddress, userApplication, delay); | |
77 | TCPacketStore.append(packet); |
|
77 | TCPacketStore.append(packet); | |
78 |
|
78 | |||
79 | emit(activateTCLoopSig()); |
|
79 | emit(activateTCLoopSig()); | |
80 |
|
80 | |||
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | void rmappluginPythonWrapper::processPacketStoreLater(unsigned int delay) |
|
83 | void rmappluginPythonWrapper::processPacketStoreLater(unsigned int delay) | |
84 | { |
|
84 | { | |
85 | emit sendMessage( |
|
85 | emit sendMessage( | |
86 | "*** process packet store in " + QString::number(delay) + " ms" |
|
86 | "*** process packet store in " + QString::number(delay) + " ms" | |
87 | ); |
|
87 | ); | |
88 | QTimer::singleShot(delay, this, SLOT(sendProcessPacketStoreNowSig())); |
|
88 | QTimer::singleShot(delay, this, SLOT(sendProcessPacketStoreNowSig())); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | void rmappluginPythonWrapper::sendTCLoop() |
|
91 | void rmappluginPythonWrapper::sendTCLoop() | |
92 | { |
|
92 | { | |
93 | unsigned int delay; |
|
93 | unsigned int delay; | |
94 |
|
94 | |||
95 | if (!timer->isActive()) |
|
95 | if (!timer->isActive()) | |
96 | { |
|
96 | { | |
97 | if (!TCPacketStore.isEmpty()) |
|
97 | if (!TCPacketStore.isEmpty()) | |
98 | { |
|
98 | { | |
99 | delay = TCPacketStore.at(0)->delay; |
|
99 | delay = TCPacketStore.at(0)->delay; | |
100 | timer->setInterval(delay); |
|
100 | timer->setInterval(delay); | |
101 | timer->start(); |
|
101 | timer->start(); | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | void rmappluginPythonWrapper::sendTC() |
|
106 | void rmappluginPythonWrapper::sendTC() | |
107 | { |
|
107 | { | |
108 | TCPacketToSend *packet; |
|
108 | TCPacketToSend *packet; | |
109 | unsigned int delay; |
|
109 | unsigned int delay; | |
110 |
|
110 | |||
111 | packet = TCPacketStore.takeFirst(); |
|
111 | packet = TCPacketStore.takeFirst(); | |
112 | // the signal is connected with the option Qt::DirectConnection, thus it is processed immediately |
|
112 | // the signal is connected with the option Qt::DirectConnection, thus it is processed immediately | |
113 | emit(WriteSPWSig(packet->Value, packet->count,packet->targetLogicalAddress, packet->userApplication)); |
|
113 | emit(WriteSPWSig(packet->Value, packet->count,packet->targetLogicalAddress, packet->userApplication)); | |
114 | delete(packet); |
|
114 | delete(packet); | |
115 | if (!TCPacketStore.isEmpty()) |
|
115 | if (!TCPacketStore.isEmpty()) | |
116 | { |
|
116 | { | |
117 | delay = TCPacketStore.at(0)->delay; |
|
117 | delay = TCPacketStore.at(0)->delay; | |
118 | timer->setInterval(delay); |
|
118 | timer->setInterval(delay); | |
119 | timer->start(); |
|
119 | timer->start(); | |
120 | } |
|
120 | } | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void rmappluginPythonWrapper::processPacketStore() |
|
123 | void rmappluginPythonWrapper::processPacketStore() | |
124 | { |
|
124 | { | |
125 | emit ccsdsPacketIsAvailable(ccsdsPacketStore->at(0)->size); |
|
125 | emit ccsdsPacketIsAvailable(ccsdsPacketStore->at(0)->size); | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | void rmappluginPythonWrapper::setValueTargetLogicalAddress(unsigned int address) |
|
128 | void rmappluginPythonWrapper::setValueTargetLogicalAddress(unsigned int address) | |
129 | { |
|
129 | { | |
130 | unsigned char newAddress; |
|
130 | unsigned char newAddress; | |
131 | newAddress = (unsigned char) address; |
|
131 | newAddress = (unsigned char) address; | |
132 | emit updateTargetLogicalAddress(newAddress); |
|
132 | emit updateTargetLogicalAddress(newAddress); | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | void rmappluginPythonWrapper::setValueSourceLogicalAddress(unsigned int address) |
|
135 | void rmappluginPythonWrapper::setValueSourceLogicalAddress(unsigned int address) | |
136 | { |
|
136 | { | |
137 | unsigned char newAddress; |
|
137 | unsigned char newAddress; | |
138 | newAddress = (unsigned char) address; |
|
138 | newAddress = (unsigned char) address; | |
139 | emit updateSourceLogicalAddress(newAddress); |
|
139 | emit updateSourceLogicalAddress(newAddress); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | void rmappluginPythonWrapper::setValueSpaceWireLinkNumber(unsigned int linkNumber) |
|
142 | void rmappluginPythonWrapper::setValueSpaceWireLinkNumber(unsigned int linkNumber) | |
143 | { |
|
143 | { | |
144 | unsigned char newLinkNumber; |
|
144 | unsigned char newLinkNumber; | |
145 | newLinkNumber = (unsigned char) linkNumber; |
|
145 | newLinkNumber = (unsigned char) linkNumber; | |
146 | emit updateSpaceWireLinkNumber(newLinkNumber); |
|
146 | emit updateSpaceWireLinkNumber(newLinkNumber); | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | void rmappluginPythonWrapper::ProcessPendingEvents() |
|
149 | void rmappluginPythonWrapper::ProcessPendingEvents() | |
150 | { |
|
150 | { | |
151 | QCoreApplication::processEvents(); |
|
151 | QCoreApplication::processEvents(); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | //******************* |
|
154 | //******************* | |
155 | // TIMECODE FUNCTIONS |
|
155 | // TIMECODE FUNCTIONS | |
156 | void rmappluginPythonWrapper::sendOneTimecode() |
|
156 | void rmappluginPythonWrapper::sendOneTimecode() | |
157 | { |
|
157 | { | |
158 | emit sig_sendOneTimecode(); |
|
158 | emit sig_sendOneTimecode(); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | void rmappluginPythonWrapper::sendTimecodePeriodically() |
|
161 | void rmappluginPythonWrapper::sendTimecodePeriodically( unsigned int onOff ) | |
162 | { |
|
162 | { | |
163 | emit sig_sendTimecodePeriodically(); |
|
163 | unsigned char newOnOff; | |
|
164 | newOnOff = (unsigned char) onOff; | |||
|
165 | emit sig_sendTimecodePeriodically( newOnOff ); | |||
164 | } |
|
166 | } | |
165 |
|
167 |
@@ -1,74 +1,74 | |||||
1 | #ifndef RMAPPLUGINPYTHONWRAPPER_H |
|
1 | #ifndef RMAPPLUGINPYTHONWRAPPER_H | |
2 | #define RMAPPLUGINPYTHONWRAPPER_H |
|
2 | #define RMAPPLUGINPYTHONWRAPPER_H | |
3 |
|
3 | |||
4 | #include <QObject> |
|
4 | #include <QObject> | |
5 | #include <genericPySysdriver.h> |
|
5 | #include <genericPySysdriver.h> | |
6 | #include <QList> |
|
6 | #include <QList> | |
7 | #include <QVariant> |
|
7 | #include <QVariant> | |
8 | #include <QTimer> |
|
8 | #include <QTimer> | |
9 |
|
9 | |||
10 | #include "rmapoperations.h" |
|
10 | #include "rmapoperations.h" | |
11 | #include "ccsds.h" |
|
11 | #include "ccsds.h" | |
12 | #include "tcpackettosend.h" |
|
12 | #include "tcpackettosend.h" | |
13 | #include "tmpackettoread.h" |
|
13 | #include "tmpackettoread.h" | |
14 |
|
14 | |||
15 | class rmappluginPythonWrapper : public genericPySysdriver |
|
15 | class rmappluginPythonWrapper : public genericPySysdriver | |
16 | { |
|
16 | { | |
17 | Q_OBJECT |
|
17 | Q_OBJECT | |
18 | public: |
|
18 | public: | |
19 | explicit rmappluginPythonWrapper(lppmonplugin *parent = 0); |
|
19 | explicit rmappluginPythonWrapper(lppmonplugin *parent = 0); | |
20 |
|
20 | |||
21 | QList<TMPacketToRead*> *ccsdsPacketStore; |
|
21 | QList<TMPacketToRead*> *ccsdsPacketStore; | |
22 | void processPacketStore(); |
|
22 | void processPacketStore(); | |
23 | unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); |
|
23 | unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); | |
24 |
|
24 | |||
25 | QList<TCPacketToSend*> TCPacketStore; |
|
25 | QList<TCPacketToSend*> TCPacketStore; | |
26 | QTimer *timer; |
|
26 | QTimer *timer; | |
27 |
|
27 | |||
28 | signals: |
|
28 | signals: | |
29 | void ccsdsPacketIsAvailable(unsigned int size); |
|
29 | void ccsdsPacketIsAvailable(unsigned int size); | |
30 | void wakeUpCallingThread(); |
|
30 | void wakeUpCallingThread(); | |
31 | unsigned int WriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); |
|
31 | unsigned int WriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
32 | // |
|
32 | // | |
33 | void updateTargetLogicalAddress(unsigned char newAddress); |
|
33 | void updateTargetLogicalAddress(unsigned char newAddress); | |
34 | void updateSourceLogicalAddress(unsigned char newAddress); |
|
34 | void updateSourceLogicalAddress(unsigned char newAddress); | |
35 | void updateSpaceWireLinkNumber(unsigned char newAddress); |
|
35 | void updateSpaceWireLinkNumber(unsigned char newAddress); | |
36 | // |
|
36 | // | |
37 | void activateTCLoopSig(); |
|
37 | void activateTCLoopSig(); | |
38 | void processPacketStoreNowSig(); |
|
38 | void processPacketStoreNowSig(); | |
39 | void sendMessage(QString message); |
|
39 | void sendMessage(QString message); | |
40 | int fetchPacketSig(); |
|
40 | int fetchPacketSig(); | |
41 | void nbPacketHasChanged(int nb); |
|
41 | void nbPacketHasChanged(int nb); | |
42 |
|
42 | |||
43 | //******************* |
|
43 | //******************* | |
44 | // TIMECODE SIGNALS |
|
44 | // TIMECODE SIGNALS | |
45 | void sig_sendOneTimecode(); |
|
45 | void sig_sendOneTimecode(); | |
46 | void sig_sendTimecodePeriodically(); |
|
46 | void sig_sendTimecodePeriodically(unsigned char); | |
47 |
|
47 | |||
48 | public slots: |
|
48 | public slots: | |
49 | QList<QVariant> ReadSPW(unsigned int size=0); |
|
49 | QList<QVariant> ReadSPW(unsigned int size=0); | |
50 | int fetchPacket() {return emit fetchPacketSig();} |
|
50 | int fetchPacket() {return emit fetchPacketSig();} | |
51 | void WriteSPW(QList<int> dataList); |
|
51 | void WriteSPW(QList<int> dataList); | |
52 | void WriteSPWDelay(QList<int> dataList, unsigned int delay=0); |
|
52 | void WriteSPWDelay(QList<int> dataList, unsigned int delay=0); | |
53 | void processPacketStoreLater(unsigned int delay); |
|
53 | void processPacketStoreLater(unsigned int delay); | |
54 | void sendProcessPacketStoreNowSig(){emit processPacketStoreNowSig();} |
|
54 | void sendProcessPacketStoreNowSig(){emit processPacketStoreNowSig();} | |
55 | void sendTCLoop(); |
|
55 | void sendTCLoop(); | |
56 | void sendTC(); |
|
56 | void sendTC(); | |
57 | void reEmitWriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) |
|
57 | void reEmitWriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) | |
58 | {emit WriteSPWSig(Value, count, targetLogicalAddress, userApplication);} |
|
58 | {emit WriteSPWSig(Value, count, targetLogicalAddress, userApplication);} | |
59 | // |
|
59 | // | |
60 | void setValueTargetLogicalAddress(unsigned int address); |
|
60 | void setValueTargetLogicalAddress(unsigned int address); | |
61 | void setValueSourceLogicalAddress(unsigned int address); |
|
61 | void setValueSourceLogicalAddress(unsigned int address); | |
62 | void setValueSpaceWireLinkNumber(unsigned int linkNumber); |
|
62 | void setValueSpaceWireLinkNumber(unsigned int linkNumber); | |
63 | // |
|
63 | // | |
64 | void ProcessPendingEvents(); |
|
64 | void ProcessPendingEvents(); | |
65 | void BlockAllSignals(); |
|
65 | void BlockAllSignals(); | |
66 |
|
66 | |||
67 | //******************* |
|
67 | //******************* | |
68 | // TIMECODE FUNCTIONS |
|
68 | // TIMECODE FUNCTIONS | |
69 | void sendOneTimecode(); |
|
69 | void sendOneTimecode(); | |
70 | void sendTimecodePeriodically(); |
|
70 | void sendTimecodePeriodically(unsigned int onOff); | |
71 |
|
71 | |||
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | #endif // RMAPPLUGINPYTHONWRAPPER_H |
|
74 | #endif // RMAPPLUGINPYTHONWRAPPER_H |
@@ -1,1095 +1,1118 | |||||
1 | #include "stardundee.h" |
|
1 | #include "stardundee.h" | |
2 | #include <lppmonengine.h> |
|
2 | #include <lppmonengine.h> | |
3 | #include <QTime> |
|
3 | #include <QTime> | |
4 | #include <QProgressBar> |
|
4 | #include <QProgressBar> | |
5 | #include <math.h> |
|
5 | #include <math.h> | |
6 | #include "ccsds.h" |
|
6 | #include "ccsds.h" | |
7 |
|
7 | |||
8 | StarDundee::StarDundee(QWidget *parent) : |
|
8 | StarDundee::StarDundee(QWidget *parent) : | |
9 | QWidget(parent) |
|
9 | QWidget(parent) | |
10 | { |
|
10 | { | |
11 | // Packet receiver |
|
11 | // Packet receiver | |
12 | timer = new QTimer; |
|
12 | timer = new QTimer; | |
13 | rmapPacketSEMAPHORE = new QSemaphore; |
|
13 | rmapPacketSEMAPHORE = new QSemaphore; | |
14 | ccsdsPacketSEMAPHORE = new QSemaphore; |
|
14 | ccsdsPacketSEMAPHORE = new QSemaphore; | |
15 | rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH); |
|
15 | rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH); | |
16 | ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH); |
|
16 | ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH); | |
17 | spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) ); |
|
17 | spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) ); | |
18 |
|
18 | |||
19 | starDundeeStatusQueryDialog = new QDialog; |
|
19 | starDundeeStatusQueryDialog = new QDialog; | |
20 |
|
20 | |||
21 | commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers |
|
21 | commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers | |
22 | rmapTargetLogicalAddress = DEFAULT_TARGET; |
|
22 | rmapTargetLogicalAddress = DEFAULT_TARGET; | |
23 | rmapSourceLogicalAddress = DEFAULT_SOURCE; |
|
23 | rmapSourceLogicalAddress = DEFAULT_SOURCE; | |
24 |
|
24 | |||
25 | connection_LAYOUT = new QGridLayout; |
|
25 | connection_LAYOUT = new QGridLayout; | |
26 |
|
26 | |||
27 | usbDeviceNumber_LABEL = new QLabel(tr("USB device number: ")); |
|
27 | usbDeviceNumber_LABEL = new QLabel(tr("USB device number: ")); | |
28 | linkNumber_LABEL = new QLabel(tr("SpaceWire link number: ")); |
|
28 | linkNumber_LABEL = new QLabel(tr("SpaceWire link number: ")); | |
29 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); |
|
29 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); | |
30 | statusLink1 = new QLabel(tr("Link 1 status code: -")); |
|
30 | statusLink1 = new QLabel(tr("Link 1 status code: -")); | |
31 | statusLink2 = new QLabel(tr("Link 2 status code: -")); |
|
31 | statusLink2 = new QLabel(tr("Link 2 status code: -")); | |
32 |
|
32 | |||
33 | //*** QPUSHBUTTON ***// |
|
33 | //*** QPUSHBUTTON ***// | |
34 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); |
|
34 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); | |
35 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); |
|
35 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); | |
36 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); |
|
36 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); | |
37 | starDundeeSendOneTimecode = new QPushButton(tr("send one timecode")); |
|
37 | starDundeeSendOneTimecode = new QPushButton(tr("send one timecode")); | |
38 | starDundeeSendOneTimePacketAndOneTimecode = new QPushButton(tr("send one update time\n+ one time code")); |
|
38 | starDundeeSendOneTimePacketAndOneTimecode = new QPushButton(tr("send one update time\n+ one time code")); | |
39 | starDundeeSendTimecodePeriodically = new QPushButton(tr("start timecodes at 1 Hz")); |
|
39 | starDundeeSendTimecodePeriodically = new QPushButton(tr("start timecodes at 1 Hz")); | |
40 | starDundeeSendOneTimePacketAndTimecodePeriodically = new QPushButton(tr("send one update time\n+ timecodes at 1 Hz")); |
|
40 | starDundeeSendOneTimePacketAndTimecodePeriodically = new QPushButton(tr("send one update time\n+ timecodes at 1 Hz")); | |
41 |
|
41 | |||
42 | arbitraryTime = new ArbitraryTime(1); // 1 is for the horizontal layout |
|
42 | arbitraryTime = new ArbitraryTime(1); // 1 is for the horizontal layout | |
43 | arbitraryTimeToSend = 0x80000000; |
|
43 | arbitraryTimeToSend = 0x80000000; | |
44 |
|
44 | |||
45 | paulCommonCRC = new PaulCommonCRC(); |
|
45 | paulCommonCRC = new PaulCommonCRC(); | |
46 |
|
46 | |||
47 | flag_sendTimecodePeriodically = false; |
|
47 | flag_sendTimecodePeriodically = false; | |
48 | starDundeeSendOneTimecode->setEnabled( false ); |
|
48 | starDundeeSendOneTimecode->setEnabled( false ); | |
49 | starDundeeSendTimecodePeriodically->setEnabled( false ); |
|
49 | starDundeeSendTimecodePeriodically->setEnabled( false ); | |
50 | starDundeeSendOneTimePacketAndOneTimecode->setEnabled( false ); |
|
50 | starDundeeSendOneTimePacketAndOneTimecode->setEnabled( false ); | |
51 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); |
|
51 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); | |
52 |
|
52 | |||
53 | usbDeviceNumber_SPINBOX = new QSpinBox; |
|
53 | usbDeviceNumber_SPINBOX = new QSpinBox; | |
54 | usbDeviceNumber_SPINBOX->setRange(0,32); |
|
54 | usbDeviceNumber_SPINBOX->setRange(0,32); | |
55 | usbDeviceNumber_SPINBOX->setValue(0); |
|
55 | usbDeviceNumber_SPINBOX->setValue(0); | |
56 | linkNumber_SPINBOX = new QSpinBox; |
|
56 | linkNumber_SPINBOX = new QSpinBox; | |
57 | linkNumber_SPINBOX->setRange(1,2); |
|
57 | linkNumber_SPINBOX->setRange(1,2); | |
58 | linkNumber_SPINBOX->setValue(1); |
|
58 | linkNumber_SPINBOX->setValue(1); | |
59 |
|
59 | |||
60 | // STAR DUNDEE STATUS QUERY DIALOG |
|
60 | // STAR DUNDEE STATUS QUERY DIALOG | |
61 | starDundeeStatusQueryDialogLayout = new QGridLayout; |
|
61 | starDundeeStatusQueryDialogLayout = new QGridLayout; | |
62 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); |
|
62 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); | |
63 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); |
|
63 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); | |
64 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); |
|
64 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); | |
65 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); |
|
65 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); | |
66 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); |
|
66 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); | |
67 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); |
|
67 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); | |
68 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); |
|
68 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); | |
69 |
|
69 | |||
70 | connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 0, 0, 1, 1); |
|
70 | connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 0, 0, 1, 1); | |
71 | connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1); |
|
71 | connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1); | |
72 | connection_LAYOUT->addWidget(linkNumber_LABEL, 1, 0, 1, 1); |
|
72 | connection_LAYOUT->addWidget(linkNumber_LABEL, 1, 0, 1, 1); | |
73 | connection_LAYOUT->addWidget(linkNumber_SPINBOX, 1, 1, 1, 1); |
|
73 | connection_LAYOUT->addWidget(linkNumber_SPINBOX, 1, 1, 1, 1); | |
74 | connection_LAYOUT->addWidget(starDundeeSendOneTimecode, 2, 0, 1, 1); |
|
74 | connection_LAYOUT->addWidget(starDundeeSendOneTimecode, 2, 0, 1, 1); | |
75 | connection_LAYOUT->addWidget(starDundeeSendOneTimePacketAndOneTimecode, 2, 1, 1, 1); |
|
75 | connection_LAYOUT->addWidget(starDundeeSendOneTimePacketAndOneTimecode, 2, 1, 1, 1); | |
76 | connection_LAYOUT->addWidget(starDundeeSendTimecodePeriodically, 3, 0, 1, 1 ); |
|
76 | connection_LAYOUT->addWidget(starDundeeSendTimecodePeriodically, 3, 0, 1, 1 ); | |
77 | connection_LAYOUT->addWidget(starDundeeSendOneTimePacketAndTimecodePeriodically, 3, 1, 1, 1); |
|
77 | connection_LAYOUT->addWidget(starDundeeSendOneTimePacketAndTimecodePeriodically, 3, 1, 1, 1); | |
78 | connection_LAYOUT->addWidget(arbitraryTime, 6, 0, 1, 2); |
|
78 | connection_LAYOUT->addWidget(arbitraryTime, 6, 0, 1, 2); | |
79 |
|
79 | |||
80 | connection_LAYOUT->setRowStretch(7, 1); |
|
80 | connection_LAYOUT->setRowStretch(7, 1); | |
81 | connection_LAYOUT->setColumnStretch(2, 1); |
|
81 | connection_LAYOUT->setColumnStretch(2, 1); | |
82 |
|
82 | |||
83 | this->setLayout(connection_LAYOUT); |
|
83 | this->setLayout(connection_LAYOUT); | |
84 |
|
84 | |||
85 | connect(starDundeeStatusQueryRetryButton, SIGNAL(clicked()), |
|
85 | connect(starDundeeStatusQueryRetryButton, SIGNAL(clicked()), | |
86 | this, SLOT(reTestSPWLink())); |
|
86 | this, SLOT(reTestSPWLink())); | |
87 | connect(starDundeeStatusQueryAbortButton, SIGNAL(clicked()), |
|
87 | connect(starDundeeStatusQueryAbortButton, SIGNAL(clicked()), | |
88 | starDundeeStatusQueryDialog, SLOT(reject())); |
|
88 | starDundeeStatusQueryDialog, SLOT(reject())); | |
89 | connect(starDundeeStatusQueryContinueButton, SIGNAL(clicked()), |
|
89 | connect(starDundeeStatusQueryContinueButton, SIGNAL(clicked()), | |
90 | starDundeeStatusQueryDialog, SLOT(accept())); |
|
90 | starDundeeStatusQueryDialog, SLOT(accept())); | |
91 |
|
91 | |||
92 | // TIMECODES |
|
92 | // TIMECODES | |
93 | connect(this->starDundeeSendOneTimecode, SIGNAL(clicked()), |
|
93 | connect(this->starDundeeSendOneTimecode, SIGNAL(clicked()), | |
94 | this, SLOT(sendOneTimecode())); |
|
94 | this, SLOT(sendOneTimecode())); | |
95 | connect(this->starDundeeSendTimecodePeriodically, SIGNAL(clicked()), |
|
95 | connect(this->starDundeeSendTimecodePeriodically, SIGNAL(clicked()), | |
96 | this, SLOT(sendTimecodePeriodically())); |
|
96 | this, SLOT(sendTimecodePeriodically())); | |
97 | connect(this->starDundeeSendOneTimePacketAndOneTimecode, SIGNAL(clicked()), |
|
97 | connect(this->starDundeeSendOneTimePacketAndOneTimecode, SIGNAL(clicked()), | |
98 | this, SLOT(sendOneTimePacketAndOneTimecode())); |
|
98 | this, SLOT(sendOneTimePacketAndOneTimecode())); | |
99 | connect(this->starDundeeSendOneTimePacketAndTimecodePeriodically, SIGNAL(clicked()), |
|
99 | connect(this->starDundeeSendOneTimePacketAndTimecodePeriodically, SIGNAL(clicked()), | |
100 | this, SLOT(sendOneTimePacketAndTimecodePeriodically())); |
|
100 | this, SLOT(sendOneTimePacketAndTimecodePeriodically())); | |
101 | connect(this->arbitraryTime, SIGNAL(timeToSendChanged(long)), |
|
101 | connect(this->arbitraryTime, SIGNAL(timeToSendChanged(long)), | |
102 | this, SLOT(updateTimeToSend(long))); |
|
102 | this, SLOT(updateTimeToSend(long))); | |
103 |
|
103 | |||
104 | connect(this->timer, SIGNAL(timeout()), this, SLOT(receivePollingLoop())); |
|
104 | connect(this->timer, SIGNAL(timeout()), this, SLOT(receivePollingLoop())); | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | StarDundee::~StarDundee() |
|
107 | StarDundee::~StarDundee() | |
108 | { |
|
108 | { | |
109 | free(rmapPacket); |
|
109 | free(rmapPacket); | |
110 | free(ccsdsPacket); |
|
110 | free(ccsdsPacket); | |
111 | free(spwPacket); |
|
111 | free(spwPacket); | |
112 | USBSpaceWire_Close(hDevice); // Close the device |
|
112 | USBSpaceWire_Close(hDevice); // Close the device | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | bool StarDundee::Open() |
|
115 | bool StarDundee::Open() | |
116 | { |
|
116 | { | |
117 | int status; |
|
117 | int status; | |
118 | U32 statusControl; |
|
118 | U32 statusControl; | |
119 | unsigned int linkStatus1; |
|
119 | unsigned int linkStatus1; | |
120 | unsigned int linkStatus2; |
|
120 | unsigned int linkStatus2; | |
121 | unsigned char linkNumber; |
|
121 | unsigned char linkNumber; | |
122 | unsigned char deviceIsAnInterface; |
|
122 | unsigned char deviceIsAnInterface; | |
123 |
|
123 | |||
124 | if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device |
|
124 | if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device | |
125 | { |
|
125 | { | |
126 | emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); |
|
126 | emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |
127 | return false; |
|
127 | return false; | |
128 | } |
|
128 | } | |
129 | emit sendMessage("stardundee *** Open *** USBSpaceWire_Open successful, device number: " |
|
129 | emit sendMessage("stardundee *** Open *** USBSpaceWire_Open successful, device number: " | |
130 | + QString::number(usbDeviceNumber_SPINBOX->value())); |
|
130 | + QString::number(usbDeviceNumber_SPINBOX->value())); | |
131 |
|
131 | |||
132 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
132 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
133 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
133 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
134 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
134 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
135 |
|
135 | |||
136 | // Set the path and return path to the device |
|
136 | // Set the path and return path to the device | |
137 | // This affects just the operations performed by the Configuration Library and does not affect the packets |
|
137 | // This affects just the operations performed by the Configuration Library and does not affect the packets | |
138 | // sent and received using the driver API. |
|
138 | // sent and received using the driver API. | |
139 | CFGSpaceWire_StackClear(); |
|
139 | CFGSpaceWire_StackClear(); | |
140 | CFGSpaceWire_AddrStackPush(0); |
|
140 | CFGSpaceWire_AddrStackPush(0); | |
141 | CFGSpaceWire_AddrStackPush(254); |
|
141 | CFGSpaceWire_AddrStackPush(254); | |
142 | CFGSpaceWire_RetAddrStackPush(254); |
|
142 | CFGSpaceWire_RetAddrStackPush(254); | |
143 |
|
143 | |||
144 | // set the base transmit rate to 100 MHz |
|
144 | // set the base transmit rate to 100 MHz | |
145 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
145 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
146 | if (status != CFG_TRANSFER_SUCCESS) |
|
146 | if (status != CFG_TRANSFER_SUCCESS) | |
147 | { |
|
147 | { | |
148 | emit sendMessage("ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); |
|
148 | emit sendMessage("ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |
149 | } |
|
149 | } | |
150 | else emit sendMessage("OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); |
|
150 | else emit sendMessage("OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |
151 |
|
151 | |||
152 | //********************* |
|
152 | //********************* | |
153 | // LINK 1 CONFIGURATION |
|
153 | // LINK 1 CONFIGURATION | |
154 | linkNumber = 1; |
|
154 | linkNumber = 1; | |
155 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
155 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
156 | emit sendMessage("Could not read link status control for link " + QString::number(linkNumber)); |
|
156 | emit sendMessage("Could not read link status control for link " + QString::number(linkNumber)); | |
157 | else |
|
157 | else | |
158 | { |
|
158 | { | |
159 | emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
159 | emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
160 |
|
160 | |||
161 | // Set the link status control register properties |
|
161 | // Set the link status control register properties | |
162 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
162 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
163 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
163 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
164 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
164 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
165 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
165 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
166 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
166 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
167 |
|
167 | |||
168 | // Set the link status control register |
|
168 | // Set the link status control register | |
169 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
169 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
170 | emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber)); |
|
170 | emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber)); | |
171 | else |
|
171 | else | |
172 | emit sendMessage("link status control for link " + QString::number(0x01) + " is set"); |
|
172 | emit sendMessage("link status control for link " + QString::number(0x01) + " is set"); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | //********************* |
|
175 | //********************* | |
176 | // LINK 2 CONFIGURATION |
|
176 | // LINK 2 CONFIGURATION | |
177 | linkNumber = 2; |
|
177 | linkNumber = 2; | |
178 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
178 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
179 | emit sendMessage("Could not read link status control for link " + QString::number(linkNumber)); |
|
179 | emit sendMessage("Could not read link status control for link " + QString::number(linkNumber)); | |
180 | else |
|
180 | else | |
181 | { |
|
181 | { | |
182 | emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
182 | emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
183 |
|
183 | |||
184 | // Set the link status control register properties |
|
184 | // Set the link status control register properties | |
185 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
185 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
186 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
186 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
187 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
187 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
188 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
188 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
189 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
189 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
190 |
|
190 | |||
191 | // Set the link status control register |
|
191 | // Set the link status control register | |
192 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
192 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
193 | emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber)); |
|
193 | emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber)); | |
194 | else |
|
194 | else | |
195 | emit sendMessage("link status control for link " + QString::number(linkNumber) + " is set"); |
|
195 | emit sendMessage("link status control for link " + QString::number(linkNumber) + " is set"); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | //******************************* |
|
198 | //******************************* | |
199 | // SET THE DEVICE AS AN INTERFACE |
|
199 | // SET THE DEVICE AS AN INTERFACE | |
200 | deviceIsAnInterface = 1; |
|
200 | deviceIsAnInterface = 1; | |
201 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) |
|
201 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) | |
202 | emit sendMessage("Could not set the device to be an interface"); |
|
202 | emit sendMessage("Could not set the device to be an interface"); | |
203 | else |
|
203 | else | |
204 | emit sendMessage("Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); |
|
204 | emit sendMessage("Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); | |
205 |
|
205 | |||
206 | // setRoutingTableEntry(0xfe, 0x02); // [0010] => connect LFR on the [Link 1] port |
|
206 | // setRoutingTableEntry(0xfe, 0x02); // [0010] => connect LFR on the [Link 1] port | |
207 | // setRoutingTableEntry(0xfd, 0x04); // [0100] => connect TIMEGEN on the [Link 2] port |
|
207 | // setRoutingTableEntry(0xfd, 0x04); // [0100] => connect TIMEGEN on the [Link 2] port | |
208 |
|
208 | |||
209 | // GetRoutingTableEntry(0xfe); |
|
209 | // GetRoutingTableEntry(0xfe); | |
210 | // GetRoutingTableEntry(0xfd); |
|
210 | // GetRoutingTableEntry(0xfd); | |
211 | // GetRoutingTableEntry(0x01); |
|
211 | // GetRoutingTableEntry(0x01); | |
212 |
|
212 | |||
213 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only |
|
213 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only | |
214 | // USBSpaceWire_RegisterReceiveOnPort(hDevice, 0x01); // Register to receive on port 1 only |
|
214 | // USBSpaceWire_RegisterReceiveOnPort(hDevice, 0x01); // Register to receive on port 1 only | |
215 | // USBSpaceWire_RegisterReceiveOnPort(hDevice, 0xfe); // Register to receive on port 254 only |
|
215 | // USBSpaceWire_RegisterReceiveOnPort(hDevice, 0xfe); // Register to receive on port 254 only | |
216 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
216 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
217 |
|
217 | |||
218 | emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); |
|
218 | emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |
219 | emit sendMessage("The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); |
|
219 | emit sendMessage("The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |
220 | emit sendMessage("USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); |
|
220 | emit sendMessage("USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |
221 |
|
221 | |||
222 | // initialize SPW packet semaphores |
|
222 | // initialize SPW packet semaphores | |
223 | while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); |
|
223 | while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); | |
224 | while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); |
|
224 | while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); | |
225 |
|
225 | |||
226 | //************ |
|
226 | //************ | |
227 | // test Link 1 and Link 2 |
|
227 | // test Link 1 and Link 2 | |
228 | linkStatus1 = getLinkStatus(0x01); |
|
228 | linkStatus1 = getLinkStatus(0x01); | |
229 | linkStatus2 = getLinkStatus(0x02); |
|
229 | linkStatus2 = getLinkStatus(0x02); | |
230 |
|
230 | |||
231 | if ((linkStatus1==1) || (linkStatus2==1)) |
|
231 | if ((linkStatus1==1) || (linkStatus2==1)) | |
232 | { |
|
232 | { | |
233 | // statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
233 | // statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |
234 | // statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
234 | // statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |
235 | // starDundeeStatusQueryDialog->exec(); |
|
235 | // starDundeeStatusQueryDialog->exec(); | |
236 | emit isOpen(true); |
|
236 | emit isOpen(true); | |
237 | timer->start(1); // starts the periodical timer, period = 100ms |
|
237 | timer->start(1); // starts the periodical timer, period = 100ms | |
238 | initializeTimecodeGeneration(); |
|
238 | initializeTimecodeGeneration(); | |
239 | return true; |
|
239 | return true; | |
240 | } |
|
240 | } | |
241 | else |
|
241 | else | |
242 | { |
|
242 | { | |
243 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
243 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |
244 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
244 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |
245 | starDundeeStatusQueryDialog->exec(); |
|
245 | starDundeeStatusQueryDialog->exec(); | |
246 | return false; |
|
246 | return false; | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | void StarDundee::Close() |
|
250 | void StarDundee::Close() | |
251 | { |
|
251 | { | |
252 | USBSpaceWire_Close(hDevice); // Close the device |
|
252 | USBSpaceWire_Close(hDevice); // Close the device | |
253 | emit sendMessage("stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(usbDeviceNumber_SPINBOX->value())); |
|
253 | emit sendMessage("stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(usbDeviceNumber_SPINBOX->value())); | |
254 |
|
254 | |||
255 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
255 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
256 |
|
256 | |||
257 | emit isOpen(false); |
|
257 | emit isOpen(false); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | unsigned char StarDundee::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts) |
|
260 | unsigned char StarDundee::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts) | |
261 | { |
|
261 | { | |
262 | U32 routingTableEntry; |
|
262 | U32 routingTableEntry; | |
263 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber |
|
263 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber | |
264 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) |
|
264 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) | |
265 | { |
|
265 | { | |
266 | emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); |
|
266 | emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); | |
267 | } |
|
267 | } | |
268 | // Build the routing table entry |
|
268 | // Build the routing table entry | |
269 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, |
|
269 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, | |
270 | dwOutputPorts, // route out of port dwOutputPorts |
|
270 | dwOutputPorts, // route out of port dwOutputPorts | |
271 | 0, // header deletion disabled |
|
271 | 0, // header deletion disabled | |
272 | 0); // priority normal |
|
272 | 0); // priority normal | |
273 | // Set the routing table entry for logical address tableEntry |
|
273 | // Set the routing table entry for logical address tableEntry | |
274 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
274 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
275 | { |
|
275 | { | |
276 | emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]"); |
|
276 | emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]"); | |
277 | } |
|
277 | } | |
278 | else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" ); |
|
278 | else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" ); | |
279 | return 1; |
|
279 | return 1; | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 | unsigned int StarDundee::GetRoutingTableEntry(int tableEntry) |
|
282 | unsigned int StarDundee::GetRoutingTableEntry(int tableEntry) | |
283 | { |
|
283 | { | |
284 | U32 routingTableEntry, outputPorts; |
|
284 | U32 routingTableEntry, outputPorts; | |
285 | char enabled, delHead, priority; |
|
285 | char enabled, delHead, priority; | |
286 | int portNum; |
|
286 | int portNum; | |
287 |
|
287 | |||
288 | emit sendMessage("GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); |
|
288 | emit sendMessage("GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); | |
289 | // Read the routing table entry |
|
289 | // Read the routing table entry | |
290 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
290 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
291 | { |
|
291 | { | |
292 | emit sendMessage("Could not read routing table entry [" + QString::number(tableEntry) + "]"); |
|
292 | emit sendMessage("Could not read routing table entry [" + QString::number(tableEntry) + "]"); | |
293 | } |
|
293 | } | |
294 | else |
|
294 | else | |
295 | { |
|
295 | { | |
296 | // Display the routing table entry properties |
|
296 | // Display the routing table entry properties | |
297 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); |
|
297 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); | |
298 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); |
|
298 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); | |
299 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); |
|
299 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); | |
300 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); |
|
300 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); | |
301 | emit sendMessage("CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); |
|
301 | emit sendMessage("CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); | |
302 | emit sendMessage("CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); |
|
302 | emit sendMessage("CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); | |
303 | emit sendMessage("CFGSpaceWire_RTIsPriority : " + QString::number(priority)); |
|
303 | emit sendMessage("CFGSpaceWire_RTIsPriority : " + QString::number(priority)); | |
304 | emit sendMessage("CFGSpaceWire_RTGetOutputPorts : "); |
|
304 | emit sendMessage("CFGSpaceWire_RTGetOutputPorts : "); | |
305 | for (portNum = 0; portNum < 32; portNum++) |
|
305 | for (portNum = 0; portNum < 32; portNum++) | |
306 | { |
|
306 | { | |
307 | if (outputPorts & (1 << portNum)) |
|
307 | if (outputPorts & (1 << portNum)) | |
308 | { |
|
308 | { | |
309 | emit sendMessage(QString::number(portNum)); |
|
309 | emit sendMessage(QString::number(portNum)); | |
310 | } |
|
310 | } | |
311 | } |
|
311 | } | |
312 | } |
|
312 | } | |
313 |
|
313 | |||
314 | return 1; |
|
314 | return 1; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | unsigned int StarDundee::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
317 | unsigned int StarDundee::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
318 | { |
|
318 | { | |
319 | unsigned int remainingCount = count; |
|
319 | unsigned int remainingCount = count; | |
320 | unsigned int iOffset = 0; |
|
320 | unsigned int iOffset = 0; | |
321 | QString console_message; |
|
321 | QString console_message; | |
322 | char* data; |
|
322 | char* data; | |
323 |
|
323 | |||
324 | if(rmapPacketSEMAPHORE->available()!=0) |
|
324 | if(rmapPacketSEMAPHORE->available()!=0) | |
325 | { |
|
325 | { | |
326 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped"); |
|
326 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped"); | |
327 | return 1; |
|
327 | return 1; | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | emit this->RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); |
|
330 | emit this->RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); | |
331 |
|
331 | |||
332 | data = (char*) malloc(READ_WRITE_MAX_COUNTS*4); |
|
332 | data = (char*) malloc(READ_WRITE_MAX_COUNTS*4); | |
333 |
|
333 | |||
334 | emit appendToLog(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); |
|
334 | emit appendToLog(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); | |
335 |
|
335 | |||
336 | QProgressBar* progress=NULL; |
|
336 | QProgressBar* progress=NULL; | |
337 | if (count > READ_WRITE_MAX_COUNTS) |
|
337 | if (count > READ_WRITE_MAX_COUNTS) | |
338 | { |
|
338 | { | |
339 | progress = lppmonEngine::getProgressBar("Reading on spw @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
339 | progress = lppmonEngine::getProgressBar("Reading on spw @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | while (remainingCount > READ_WRITE_MAX_COUNTS) |
|
342 | while (remainingCount > READ_WRITE_MAX_COUNTS) | |
343 | { |
|
343 | { | |
344 | // progress bar |
|
344 | // progress bar | |
345 | progress->setValue(count-remainingCount); |
|
345 | progress->setValue(count-remainingCount); | |
346 | qApp->processEvents(); |
|
346 | qApp->processEvents(); | |
347 |
|
347 | |||
348 | for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++) |
|
348 | for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++) | |
349 | { |
|
349 | { | |
350 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); |
|
350 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); | |
351 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); |
|
351 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); | |
352 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); |
|
352 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); | |
353 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); |
|
353 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | console_message.sprintf("remainingCount: %d => ", remainingCount); |
|
356 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
357 | emit appendToLog(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16)); |
|
357 | emit appendToLog(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
358 |
|
358 | |||
359 | if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0) |
|
359 | if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0) | |
360 | { |
|
360 | { | |
361 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); |
|
361 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); | |
362 | return 1; |
|
362 | return 1; | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; |
|
365 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; | |
366 | address = address + READ_WRITE_MAX_COUNTS * 4; |
|
366 | address = address + READ_WRITE_MAX_COUNTS * 4; | |
367 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; |
|
367 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | if (remainingCount > 0) |
|
370 | if (remainingCount > 0) | |
371 | { |
|
371 | { | |
372 | for (unsigned int i = 0; i<remainingCount; i++) |
|
372 | for (unsigned int i = 0; i<remainingCount; i++) | |
373 | { |
|
373 | { | |
374 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); |
|
374 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); | |
375 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); |
|
375 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); | |
376 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); |
|
376 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); | |
377 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); |
|
377 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | console_message.sprintf("remainingCount: %d => ", remainingCount); |
|
380 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
381 | emit appendToLog(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16)); |
|
381 | emit appendToLog(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
382 |
|
382 | |||
383 | if (WriteBLOCK(data, remainingCount*4, address)==0) |
|
383 | if (WriteBLOCK(data, remainingCount*4, address)==0) | |
384 | { |
|
384 | { | |
385 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); |
|
385 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); | |
386 | return 1; |
|
386 | return 1; | |
387 | } |
|
387 | } | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | if (count > READ_WRITE_MAX_COUNTS) |
|
390 | if (count > READ_WRITE_MAX_COUNTS) | |
391 | { |
|
391 | { | |
392 | lppmonEngine::deleteProgressBar(progress); |
|
392 | lppmonEngine::deleteProgressBar(progress); | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | emit appendToLog(QString("*** STOP *** WRITE")); |
|
395 | emit appendToLog(QString("*** STOP *** WRITE")); | |
396 |
|
396 | |||
397 | free(data); |
|
397 | free(data); | |
398 | return count; |
|
398 | return count; | |
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | unsigned int StarDundee::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
401 | unsigned int StarDundee::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
402 | { |
|
402 | { | |
403 | unsigned int remainingCount = count; |
|
403 | unsigned int remainingCount = count; | |
404 | unsigned int iOffset = 0; |
|
404 | unsigned int iOffset = 0; | |
405 | QString console_message; |
|
405 | QString console_message; | |
406 |
|
406 | |||
407 | if(rmapPacketSEMAPHORE->available()!=0) |
|
407 | if(rmapPacketSEMAPHORE->available()!=0) | |
408 | { |
|
408 | { | |
409 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped"); |
|
409 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped"); | |
410 | return 1; |
|
410 | return 1; | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | emit appendToLog(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); |
|
413 | emit appendToLog(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); | |
414 |
|
414 | |||
415 | QProgressBar* progress=NULL; |
|
415 | QProgressBar* progress=NULL; | |
416 | if (count > READ_WRITE_MAX_COUNTS) |
|
416 | if (count > READ_WRITE_MAX_COUNTS) | |
417 | { |
|
417 | { | |
418 | progress = lppmonEngine::getProgressBar("Reading on spw @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
418 | progress = lppmonEngine::getProgressBar("Reading on spw @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | while (remainingCount > READ_WRITE_MAX_COUNTS) |
|
421 | while (remainingCount > READ_WRITE_MAX_COUNTS) | |
422 | { |
|
422 | { | |
423 | // progress bar |
|
423 | // progress bar | |
424 | progress->setValue(count-remainingCount); |
|
424 | progress->setValue(count-remainingCount); | |
425 | qApp->processEvents(); |
|
425 | qApp->processEvents(); | |
426 |
|
426 | |||
427 | console_message.sprintf("remainingCount: %d => ", remainingCount); |
|
427 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
428 | emit appendToLog(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16)); |
|
428 | emit appendToLog(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
429 |
|
429 | |||
430 | if (this->ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0) |
|
430 | if (this->ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0) | |
431 | { |
|
431 | { | |
432 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); |
|
432 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); | |
433 | return 1; |
|
433 | return 1; | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | for(int i=0;i<READ_WRITE_MAX_COUNTS;i++) |
|
436 | for(int i=0;i<READ_WRITE_MAX_COUNTS;i++) | |
437 | { |
|
437 | { | |
438 | Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; |
|
438 | Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; | |
439 | for(int j=1;j<4;j++) |
|
439 | for(int j=1;j<4;j++) | |
440 | { |
|
440 | { | |
441 | Value[i+iOffset]= ((unsigned char) (rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) |
|
441 | Value[i+iOffset]= ((unsigned char) (rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) | |
442 | + Value[i+iOffset]*256; |
|
442 | + Value[i+iOffset]*256; | |
443 | } |
|
443 | } | |
444 | } |
|
444 | } | |
445 |
|
445 | |||
446 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; |
|
446 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; | |
447 | address = address + READ_WRITE_MAX_COUNTS * 4; |
|
447 | address = address + READ_WRITE_MAX_COUNTS * 4; | |
448 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; |
|
448 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; | |
449 | this->acquireRMAPSemaphore(); |
|
449 | this->acquireRMAPSemaphore(); | |
450 | } |
|
450 | } | |
451 |
|
451 | |||
452 | if (remainingCount > 0) |
|
452 | if (remainingCount > 0) | |
453 | { |
|
453 | { | |
454 | console_message.sprintf("remainingCount: %d => ", remainingCount); |
|
454 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
455 | emit appendToLog(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16)); |
|
455 | emit appendToLog(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
456 |
|
456 | |||
457 | if (this->ReadBLOCK(4*remainingCount, address)==0) |
|
457 | if (this->ReadBLOCK(4*remainingCount, address)==0) | |
458 | { |
|
458 | { | |
459 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); |
|
459 | emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); | |
460 | return 1; |
|
460 | return 1; | |
461 | } |
|
461 | } | |
462 |
|
462 | |||
463 | for(unsigned int i=0;i<remainingCount;i++) |
|
463 | for(unsigned int i=0;i<remainingCount;i++) | |
464 | { |
|
464 | { | |
465 | Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; |
|
465 | Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; | |
466 | for(int j=1;j<4;j++) |
|
466 | for(int j=1;j<4;j++) | |
467 | { |
|
467 | { | |
468 | Value[i+iOffset]= ((unsigned char)(rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256; |
|
468 | Value[i+iOffset]= ((unsigned char)(rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256; | |
469 | } |
|
469 | } | |
470 | } |
|
470 | } | |
471 | this->acquireRMAPSemaphore(); |
|
471 | this->acquireRMAPSemaphore(); | |
472 | } |
|
472 | } | |
473 |
|
473 | |||
474 | if (count > READ_WRITE_MAX_COUNTS) |
|
474 | if (count > READ_WRITE_MAX_COUNTS) | |
475 | { |
|
475 | { | |
476 | lppmonEngine::deleteProgressBar(progress); |
|
476 | lppmonEngine::deleteProgressBar(progress); | |
477 | } |
|
477 | } | |
478 |
|
478 | |||
479 | emit appendToLog(QString("*** STOP *** READ ")); |
|
479 | emit appendToLog(QString("*** STOP *** READ ")); | |
480 | return count; |
|
480 | return count; | |
481 | } |
|
481 | } | |
482 |
|
482 | |||
483 | unsigned int StarDundee::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address) |
|
483 | unsigned int StarDundee::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address) | |
484 | { |
|
484 | { | |
485 | RMAP *RMAPCommand; |
|
485 | RMAP *RMAPCommand; | |
486 | char * packet; |
|
486 | char * packet; | |
487 | char* aux; |
|
487 | char* aux; | |
488 | unsigned char offset, headerSize, CRCSize; |
|
488 | unsigned char offset, headerSize, CRCSize; | |
489 | unsigned int totalSize; |
|
489 | unsigned int totalSize; | |
490 | int errorCode; |
|
490 | int errorCode; | |
491 | QString console_message; |
|
491 | QString console_message; | |
492 |
|
492 | |||
493 | if (getLinkStatus(this->linkNumber_SPINBOX->value()) == 0) |
|
493 | if (getLinkStatus(this->linkNumber_SPINBOX->value()) == 0) | |
494 | { |
|
494 | { | |
495 | this->Close(); |
|
495 | this->Close(); | |
496 | return 1; |
|
496 | return 1; | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | RMAPCommand = new RMAP(this->commandCode, |
|
499 | RMAPCommand = new RMAP(this->commandCode, | |
500 | rmapTargetLogicalAddress, |
|
500 | rmapTargetLogicalAddress, | |
501 | rmapSourceLogicalAddress, |
|
501 | rmapSourceLogicalAddress, | |
502 | address, |
|
502 | address, | |
503 | nbBytes, |
|
503 | nbBytes, | |
504 | data); |
|
504 | data); | |
505 | headerSize = sizeof(RMAPCommand->RMAPHeader); |
|
505 | headerSize = sizeof(RMAPCommand->RMAPHeader); | |
506 | CRCSize = 1; |
|
506 | CRCSize = 1; | |
507 |
|
507 | |||
508 | //************************* |
|
508 | //************************* | |
509 | // BUILD THE PACKET TO SEND |
|
509 | // BUILD THE PACKET TO SEND | |
510 | totalSize = headerSize + nbBytes + CRCSize + PATH_ADDRESSING_OFFSET; |
|
510 | totalSize = headerSize + nbBytes + CRCSize + PATH_ADDRESSING_OFFSET; | |
511 | packet = (char*) malloc( totalSize ); |
|
511 | packet = (char*) malloc( totalSize ); | |
512 | aux = (char*) ((void*) &RMAPCommand->RMAPHeader); |
|
512 | aux = (char*) ((void*) &RMAPCommand->RMAPHeader); | |
513 | packet[0] = getPacketFirstByte(); // TO BE SUPPRESSED |
|
513 | packet[0] = getPacketFirstByte(); // TO BE SUPPRESSED | |
514 | for(unsigned int i = 0; i<headerSize; i++) packet[i+PATH_ADDRESSING_OFFSET] = aux[i]; |
|
514 | for(unsigned int i = 0; i<headerSize; i++) packet[i+PATH_ADDRESSING_OFFSET] = aux[i]; | |
515 | offset = headerSize; |
|
515 | offset = headerSize; | |
516 | for(unsigned int i = 0; i<nbBytes; i++) |
|
516 | for(unsigned int i = 0; i<nbBytes; i++) | |
517 | { |
|
517 | { | |
518 | packet[i+offset+PATH_ADDRESSING_OFFSET] = data[i]; |
|
518 | packet[i+offset+PATH_ADDRESSING_OFFSET] = data[i]; | |
519 | } |
|
519 | } | |
520 | packet[nbBytes+offset+PATH_ADDRESSING_OFFSET] = RMAPCommand->dataCRC; |
|
520 | packet[nbBytes+offset+PATH_ADDRESSING_OFFSET] = RMAPCommand->dataCRC; | |
521 |
|
521 | |||
522 | //**************** |
|
522 | //**************** | |
523 | // SEND THE PACKET |
|
523 | // SEND THE PACKET | |
524 | result = USBSpaceWire_SendPacket(hDevice, |
|
524 | result = USBSpaceWire_SendPacket(hDevice, | |
525 | packet, |
|
525 | packet, | |
526 | totalSize, |
|
526 | totalSize, | |
527 | BWAIT_1, &pIdentifier); |
|
527 | BWAIT_1, &pIdentifier); | |
528 | if (result != TRANSFER_SUCCESS) |
|
528 | if (result != TRANSFER_SUCCESS) | |
529 | { |
|
529 | { | |
530 | emit sendMessage("ERROR *** WriteStarDundee when sending packet of size " |
|
530 | emit sendMessage("ERROR *** WriteStarDundee when sending packet of size " | |
531 | + QString::number(totalSize) +", with code: " + QString::number(result)); |
|
531 | + QString::number(totalSize) +", with code: " + QString::number(result)); | |
532 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
532 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
533 | free(data); |
|
533 | free(data); | |
534 | return 1; |
|
534 | return 1; | |
535 | } |
|
535 | } | |
536 | // else emit sendMessage("OK *** WriteStarDundee when sending packet of size " + QString::number(totalSize)); |
|
536 | // else emit sendMessage("OK *** WriteStarDundee when sending packet of size " + QString::number(totalSize)); | |
537 |
|
537 | |||
538 | //************** |
|
538 | //************** | |
539 | // Free the send |
|
539 | // Free the send | |
540 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
540 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
541 | free(packet); |
|
541 | free(packet); | |
542 |
|
542 | |||
543 | if ( (commandCode == writeSingle_noVer_Rep) | (commandCode == writeInc_noVer_Rep) | |
|
543 | if ( (commandCode == writeSingle_noVer_Rep) | (commandCode == writeInc_noVer_Rep) | | |
544 | (commandCode == writeSingle_ver_rep) | (commandCode == writeInc_ver_rep) ) |
|
544 | (commandCode == writeSingle_ver_rep) | (commandCode == writeInc_ver_rep) ) | |
545 | { |
|
545 | { | |
546 | // WAIT FOR THE RMAP REPLY PACKET |
|
546 | // WAIT FOR THE RMAP REPLY PACKET | |
547 | errorCode = this->receiveSPWPacket(1); |
|
547 | errorCode = this->receiveSPWPacket(1); | |
548 | if (errorCode<=0) |
|
548 | if (errorCode<=0) | |
549 | { |
|
549 | { | |
550 | emit appendToLog("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); |
|
550 | emit appendToLog("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); | |
551 | return 0; |
|
551 | return 0; | |
552 | } |
|
552 | } | |
553 | if(rmapPacketSize != 8) |
|
553 | if(rmapPacketSize != 8) | |
554 | { |
|
554 | { | |
555 | console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n"); |
|
555 | console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n"); | |
556 | emit appendToLog(console_message); |
|
556 | emit appendToLog(console_message); | |
557 | return 0; |
|
557 | return 0; | |
558 | } |
|
558 | } | |
559 | switch (this->rmapPacket[3]) // byte 4 is the status byte in the reply |
|
559 | switch (this->rmapPacket[3]) // byte 4 is the status byte in the reply | |
560 | { |
|
560 | { | |
561 | case 0: |
|
561 | case 0: | |
562 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 0 Successfull"); |
|
562 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 0 Successfull"); | |
563 | break; |
|
563 | break; | |
564 | case 1: |
|
564 | case 1: | |
565 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** General error code"); |
|
565 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** General error code"); | |
566 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 1 General error code"); |
|
566 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 1 General error code"); | |
567 | break; |
|
567 | break; | |
568 | case 2: |
|
568 | case 2: | |
569 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code"); |
|
569 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code"); | |
570 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code"); |
|
570 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code"); | |
571 | break; |
|
571 | break; | |
572 | case 3: |
|
572 | case 3: | |
573 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key"); |
|
573 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key"); | |
574 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 3 Invalid key"); |
|
574 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 3 Invalid key"); | |
575 | break; |
|
575 | break; | |
576 | case 4: |
|
576 | case 4: | |
577 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC"); |
|
577 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC"); | |
578 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 4 Invalid data CRC"); |
|
578 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 4 Invalid data CRC"); | |
579 | break; |
|
579 | break; | |
580 | case 5: |
|
580 | case 5: | |
581 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP"); |
|
581 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP"); | |
582 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 5 Early EOP"); |
|
582 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 5 Early EOP"); | |
583 | break; |
|
583 | break; | |
584 | case 6: |
|
584 | case 6: | |
585 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data"); |
|
585 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data"); | |
586 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 6 Too much data"); |
|
586 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 6 Too much data"); | |
587 | break; |
|
587 | break; | |
588 | case 7: |
|
588 | case 7: | |
589 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** EEP"); |
|
589 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** EEP"); | |
590 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 7 EEP"); |
|
590 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 7 EEP"); | |
591 | break; |
|
591 | break; | |
592 | case 8: |
|
592 | case 8: | |
593 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved"); |
|
593 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved"); | |
594 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 8 Reserved"); |
|
594 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 8 Reserved"); | |
595 | break; |
|
595 | break; | |
596 | case 9: |
|
596 | case 9: | |
597 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun"); |
|
597 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun"); | |
598 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun"); |
|
598 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun"); | |
599 | break; |
|
599 | break; | |
600 | case 10: |
|
600 | case 10: | |
601 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised"); |
|
601 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised"); | |
602 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised"); |
|
602 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised"); | |
603 | break; |
|
603 | break; | |
604 | case 11: |
|
604 | case 11: | |
605 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error"); |
|
605 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error"); | |
606 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error"); |
|
606 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error"); | |
607 | break; |
|
607 | break; | |
608 | case 12: |
|
608 | case 12: | |
609 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address"); |
|
609 | emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address"); | |
610 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 12 Invalid target logical address"); |
|
610 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 12 Invalid target logical address"); | |
611 | break; |
|
611 | break; | |
612 | } |
|
612 | } | |
613 | this->acquireRMAPSemaphore(); |
|
613 | this->acquireRMAPSemaphore(); | |
614 | } |
|
614 | } | |
615 | else |
|
615 | else | |
616 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); |
|
616 | emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); | |
617 |
|
617 | |||
618 | return nbBytes; |
|
618 | return nbBytes; | |
619 | } |
|
619 | } | |
620 |
|
620 | |||
621 | unsigned int StarDundee::ReadBLOCK(unsigned int nbBytes, unsigned int address) |
|
621 | unsigned int StarDundee::ReadBLOCK(unsigned int nbBytes, unsigned int address) | |
622 | { |
|
622 | { | |
623 | int errorCode; |
|
623 | int errorCode; | |
624 | RMAP *RMAPCommand; |
|
624 | RMAP *RMAPCommand; | |
625 | char *packet; |
|
625 | char *packet; | |
626 | char *aux; |
|
626 | char *aux; | |
627 | unsigned int dataLength = 0; |
|
627 | unsigned int dataLength = 0; | |
628 | unsigned int totalSize = 0; |
|
628 | unsigned int totalSize = 0; | |
629 |
|
629 | |||
630 | //********************** |
|
630 | //********************** | |
631 | // Check the link status |
|
631 | // Check the link status | |
632 | if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 ) |
|
632 | if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 ) | |
633 | { |
|
633 | { | |
634 | this->Close(); |
|
634 | this->Close(); | |
635 | emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n"); |
|
635 | emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n"); | |
636 | return 0; |
|
636 | return 0; | |
637 | } |
|
637 | } | |
638 |
|
638 | |||
639 | //********************** |
|
639 | //********************** | |
640 | // SEND THE READ COMMAND |
|
640 | // SEND THE READ COMMAND | |
641 | if (nbBytes > 4) |
|
641 | if (nbBytes > 4) | |
642 | { |
|
642 | { | |
643 | RMAPCommand = new RMAP(read_Inc, |
|
643 | RMAPCommand = new RMAP(read_Inc, | |
644 | rmapTargetLogicalAddress, |
|
644 | rmapTargetLogicalAddress, | |
645 | rmapSourceLogicalAddress, |
|
645 | rmapSourceLogicalAddress, | |
646 | address, |
|
646 | address, | |
647 | nbBytes, |
|
647 | nbBytes, | |
648 | NULL); |
|
648 | NULL); | |
649 | } |
|
649 | } | |
650 | else |
|
650 | else | |
651 | { |
|
651 | { | |
652 | RMAPCommand = new RMAP(read_Single, |
|
652 | RMAPCommand = new RMAP(read_Single, | |
653 | rmapTargetLogicalAddress, |
|
653 | rmapTargetLogicalAddress, | |
654 | rmapSourceLogicalAddress, |
|
654 | rmapSourceLogicalAddress, | |
655 | address, |
|
655 | address, | |
656 | nbBytes, |
|
656 | nbBytes, | |
657 | NULL); |
|
657 | NULL); | |
658 | } |
|
658 | } | |
659 |
|
659 | |||
660 | //************************* |
|
660 | //************************* | |
661 | // BUILD THE PACKET TO SEND |
|
661 | // BUILD THE PACKET TO SEND | |
662 | totalSize = sizeof(RMAPCommand->RMAPHeader) + PATH_ADDRESSING_OFFSET; |
|
662 | totalSize = sizeof(RMAPCommand->RMAPHeader) + PATH_ADDRESSING_OFFSET; | |
663 | packet = (char*) malloc( totalSize ); |
|
663 | packet = (char*) malloc( totalSize ); | |
664 | aux = (char*) ((void*) &RMAPCommand->RMAPHeader); |
|
664 | aux = (char*) ((void*) &RMAPCommand->RMAPHeader); | |
665 | packet[0] = getPacketFirstByte(); // TO BE SUPPRESSED |
|
665 | packet[0] = getPacketFirstByte(); // TO BE SUPPRESSED | |
666 | for (unsigned int i = 0; i<sizeof(RMAPCommand->RMAPHeader); i++) |
|
666 | for (unsigned int i = 0; i<sizeof(RMAPCommand->RMAPHeader); i++) | |
667 | packet[i+PATH_ADDRESSING_OFFSET] = aux[i]; |
|
667 | packet[i+PATH_ADDRESSING_OFFSET] = aux[i]; | |
668 |
|
668 | |||
669 | //**************** |
|
669 | //**************** | |
670 | // SEND THE PACKET |
|
670 | // SEND THE PACKET | |
671 | result = USBSpaceWire_SendPacket(hDevice, |
|
671 | result = USBSpaceWire_SendPacket(hDevice, | |
672 | packet, |
|
672 | packet, | |
673 | totalSize, |
|
673 | totalSize, | |
674 | BWAIT_1, &pIdentifier); |
|
674 | BWAIT_1, &pIdentifier); | |
675 | if (result != TRANSFER_SUCCESS) emit sendMessage("ERR *** ReadStarDundee *** ReadBLOCK *** sending the READ command "); |
|
675 | if (result != TRANSFER_SUCCESS) emit sendMessage("ERR *** ReadStarDundee *** ReadBLOCK *** sending the READ command "); | |
676 | else |
|
676 | else | |
677 | { |
|
677 | { | |
678 | // emit sendMessage("OK *** ReadStarDundee *** ReadBLOCK *** sending the READ command"); |
|
678 | // emit sendMessage("OK *** ReadStarDundee *** ReadBLOCK *** sending the READ command"); | |
679 | // emit appendToLog("packet sent, B0 = " + QString::number(packet[0], 16) |
|
679 | // emit appendToLog("packet sent, B0 = " + QString::number(packet[0], 16) | |
680 | // + " *** B1 = " + QString::number(packet[1], 16) |
|
680 | // + " *** B1 = " + QString::number(packet[1], 16) | |
681 | // + " *** B2 = " + QString::number(packet[2], 16) |
|
681 | // + " *** B2 = " + QString::number(packet[2], 16) | |
682 | // + " *** B3 = " + QString::number(packet[3], 16) |
|
682 | // + " *** B3 = " + QString::number(packet[3], 16) | |
683 | // + " *** B4 = " + QString::number(packet[4], 16) |
|
683 | // + " *** B4 = " + QString::number(packet[4], 16) | |
684 | // + " *** B5 = " + QString::number(packet[5], 16) |
|
684 | // + " *** B5 = " + QString::number(packet[5], 16) | |
685 | // ); |
|
685 | // ); | |
686 | } |
|
686 | } | |
687 |
|
687 | |||
688 | //************** |
|
688 | //************** | |
689 | // Free the send |
|
689 | // Free the send | |
690 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
690 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
691 | free(packet); |
|
691 | free(packet); | |
692 |
|
692 | |||
693 | //********************************* |
|
693 | //********************************* | |
694 | // RECEIVE THE INCOMING RMAP PACKET |
|
694 | // RECEIVE THE INCOMING RMAP PACKET | |
695 | errorCode = this->receiveSPWPacket(1); // request ID 1 is for RMAP packet |
|
695 | errorCode = this->receiveSPWPacket(1); // request ID 1 is for RMAP packet | |
696 | if (errorCode<=0) |
|
696 | if (errorCode<=0) | |
697 | { |
|
697 | { | |
698 | emit appendToLog("WARNING === in function ReadBLOCK of StarDundee *** RMAP packet reception failed with code " + QString::number(errorCode)); |
|
698 | emit appendToLog("WARNING === in function ReadBLOCK of StarDundee *** RMAP packet reception failed with code " + QString::number(errorCode)); | |
699 | return 0; |
|
699 | return 0; | |
700 | } |
|
700 | } | |
701 | dataLength = rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; |
|
701 | dataLength = rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; | |
702 | if(dataLength != nbBytes) |
|
702 | if(dataLength != nbBytes) | |
703 | { |
|
703 | { | |
704 | emit appendToLog("WARNING === in function READ of StarDundee *** number of data received (" |
|
704 | emit appendToLog("WARNING === in function READ of StarDundee *** number of data received (" | |
705 | +QString::number(dataLength) |
|
705 | +QString::number(dataLength) | |
706 | +") not equal to number of data requested (" |
|
706 | +") not equal to number of data requested (" | |
707 | +QString::number(nbBytes) |
|
707 | +QString::number(nbBytes) | |
708 | +")"); |
|
708 | +")"); | |
709 | return 0; |
|
709 | return 0; | |
710 | } |
|
710 | } | |
711 | return dataLength; |
|
711 | return dataLength; | |
712 | } |
|
712 | } | |
713 |
|
713 | |||
714 | unsigned int StarDundee::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) |
|
714 | unsigned int StarDundee::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) | |
715 | { |
|
715 | { | |
716 | char protocoleIdentifier = 0x02; |
|
716 | char protocoleIdentifier = 0x02; | |
717 | char reserved = 0x00; |
|
717 | char reserved = 0x00; | |
718 | char *SPWData; |
|
718 | char *SPWData; | |
719 | unsigned int totalSize; |
|
719 | unsigned int totalSize; | |
720 |
|
720 | |||
721 | if (count>248) |
|
721 | if (count>248) | |
722 | { |
|
722 | { | |
723 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n"); |
|
723 | emit appendToLog("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n"); | |
724 | return 1; |
|
724 | return 1; | |
725 | } |
|
725 | } | |
726 |
|
726 | |||
727 | emit appendToLog("*** START *** Send CCSDS packet of "+ QString::number(count) + " byte(s)"); |
|
727 | emit appendToLog("*** START *** Send CCSDS packet of "+ QString::number(count) + " byte(s)"); | |
728 |
|
728 | |||
729 | if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 ) |
|
729 | if ( getLinkStatus( this->linkNumber_SPINBOX->value() ) == 0 ) | |
730 | { |
|
730 | { | |
731 | this->Close(); |
|
731 | this->Close(); | |
732 | emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n"); |
|
732 | emit appendToLog("WARNING === in function WriteSPW of StarDundee *** SPW link not running\n"); | |
733 | return 1; |
|
733 | return 1; | |
734 | } |
|
734 | } | |
735 |
|
735 | |||
736 | totalSize = count + 4 + PATH_ADDRESSING_OFFSET; // The StarDundee brick is in PATH addressing |
|
736 | totalSize = count + 4 + PATH_ADDRESSING_OFFSET; // The StarDundee brick is in PATH addressing | |
737 | SPWData = (char*) malloc(totalSize); |
|
737 | SPWData = (char*) malloc(totalSize); | |
738 | // SPW HEADER |
|
738 | // SPW HEADER | |
739 | SPWData[0] = getPacketFirstByte(); |
|
739 | SPWData[0] = getPacketFirstByte(); | |
740 | SPWData[0+PATH_ADDRESSING_OFFSET] = targetLogicalAddress; |
|
740 | SPWData[0+PATH_ADDRESSING_OFFSET] = targetLogicalAddress; | |
741 | SPWData[1+PATH_ADDRESSING_OFFSET] = protocoleIdentifier; |
|
741 | SPWData[1+PATH_ADDRESSING_OFFSET] = protocoleIdentifier; | |
742 | SPWData[2+PATH_ADDRESSING_OFFSET] = reserved; |
|
742 | SPWData[2+PATH_ADDRESSING_OFFSET] = reserved; | |
743 | SPWData[3+PATH_ADDRESSING_OFFSET] = userApplication; |
|
743 | SPWData[3+PATH_ADDRESSING_OFFSET] = userApplication; | |
744 | // CCSDS PACKET |
|
744 | // CCSDS PACKET | |
745 | for (unsigned int i = 0; i<count; i++) |
|
745 | for (unsigned int i = 0; i<count; i++) | |
746 | { |
|
746 | { | |
747 | SPWData[i+4+PATH_ADDRESSING_OFFSET] = Value[i]; |
|
747 | SPWData[i+4+PATH_ADDRESSING_OFFSET] = Value[i]; | |
748 | } |
|
748 | } | |
749 |
|
749 | |||
750 | //**************** |
|
750 | //**************** | |
751 | // SEND THE PACKET |
|
751 | // SEND THE PACKET | |
752 | result = USBSpaceWire_SendPacket(hDevice, |
|
752 | result = USBSpaceWire_SendPacket(hDevice, | |
753 | SPWData, |
|
753 | SPWData, | |
754 | totalSize, |
|
754 | totalSize, | |
755 | BWAIT_1, &pIdentifier); |
|
755 | BWAIT_1, &pIdentifier); | |
756 | if (result != TRANSFER_SUCCESS) |
|
756 | if (result != TRANSFER_SUCCESS) | |
757 | { |
|
757 | { | |
758 | emit sendMessage("ERROR *** WriteSPW when sending packet of size " |
|
758 | emit sendMessage("ERROR *** WriteSPW when sending packet of size " | |
759 | + QString::number(totalSize) +", with code: " + QString::number(result)); |
|
759 | + QString::number(totalSize) +", with code: " + QString::number(result)); | |
760 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
760 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
761 | free(SPWData); |
|
761 | free(SPWData); | |
762 | return 0; |
|
762 | return 0; | |
763 | } |
|
763 | } | |
764 | else emit sendMessage("OK *** WriteSPW when sending packet of size " + QString::number(totalSize-1)); |
|
764 | else emit sendMessage("OK *** WriteSPW when sending packet of size " + QString::number(totalSize-1)); | |
765 | emit appendToLog("packet sent, B0 = " + QString::number(SPWData[0]) |
|
765 | emit appendToLog("packet sent, B0 = " + QString::number(SPWData[0]) | |
766 | + " *** B1 = " + QString::number(SPWData[1]) |
|
766 | + " *** B1 = " + QString::number(SPWData[1]) | |
767 | + " *** B2 = " + QString::number(SPWData[2]) |
|
767 | + " *** B2 = " + QString::number(SPWData[2]) | |
768 | + " *** B3 = " + QString::number(SPWData[3]) |
|
768 | + " *** B3 = " + QString::number(SPWData[3]) | |
769 | + " *** B4 = " + QString::number(SPWData[4]) |
|
769 | + " *** B4 = " + QString::number(SPWData[4]) | |
770 | + " *** B5 = " + QString::number(SPWData[5]) |
|
770 | + " *** B5 = " + QString::number(SPWData[5]) | |
771 | + " *** B6 = " + QString::number(SPWData[6]) |
|
771 | + " *** B6 = " + QString::number(SPWData[6]) | |
772 | + " *** B7 = " + QString::number(SPWData[7]) |
|
772 | + " *** B7 = " + QString::number(SPWData[7]) | |
773 | + " *** B8 = " + QString::number(SPWData[8]) |
|
773 | + " *** B8 = " + QString::number(SPWData[8]) | |
774 | + " *** B9 = " + QString::number(SPWData[9]) |
|
774 | + " *** B9 = " + QString::number(SPWData[9]) | |
775 | + " *** B10 = " + QString::number(SPWData[10]) |
|
775 | + " *** B10 = " + QString::number(SPWData[10]) | |
776 | + " *** B11 = " + QString::number(SPWData[11]) |
|
776 | + " *** B11 = " + QString::number(SPWData[11]) | |
777 | + " *** B12 = " + QString::number(SPWData[12]) |
|
777 | + " *** B12 = " + QString::number(SPWData[12]) | |
778 | ); |
|
778 | ); | |
779 |
|
779 | |||
780 | //************** |
|
780 | //************** | |
781 | // Free the send |
|
781 | // Free the send | |
782 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
782 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
783 | free(SPWData); |
|
783 | free(SPWData); | |
784 |
|
784 | |||
785 | emit appendToLog(QString("*** CCSDS packet sent")); |
|
785 | emit appendToLog(QString("*** CCSDS packet sent")); | |
786 |
|
786 | |||
787 | return 1; |
|
787 | return 1; | |
788 | } |
|
788 | } | |
789 |
|
789 | |||
790 | unsigned int StarDundee::getLinkStatus(unsigned char link) |
|
790 | unsigned int StarDundee::getLinkStatus(unsigned char link) | |
791 | { |
|
791 | { | |
792 | U32 statusControl, errorStatus, portType; |
|
792 | U32 statusControl, errorStatus, portType; | |
793 | U32 linkStatus, operatingSpeed, outputPortConnection; |
|
793 | U32 linkStatus, operatingSpeed, outputPortConnection; | |
794 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; |
|
794 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; | |
795 |
|
795 | |||
796 | // Read the link status control register |
|
796 | // Read the link status control register | |
797 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
797 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) | |
798 | { |
|
798 | { | |
799 | emit appendToLog("Could not read link status control for link" + QString::number(link)); |
|
799 | emit appendToLog("Could not read link status control for link" + QString::number(link)); | |
800 | } |
|
800 | } | |
801 | else |
|
801 | else | |
802 | { |
|
802 | { | |
803 | // Display the link status control register properties |
|
803 | // Display the link status control register properties | |
804 | CFGSpaceWire_LSPortType(statusControl, &portType); |
|
804 | CFGSpaceWire_LSPortType(statusControl, &portType); | |
805 | if (portType == CFG_CONFIGURATION_PORT) |
|
805 | if (portType == CFG_CONFIGURATION_PORT) | |
806 | { |
|
806 | { | |
807 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); |
|
807 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); | |
808 | //emit appendToLog("Configuration port error status = " + QString::number(errorStatus)); |
|
808 | //emit appendToLog("Configuration port error status = " + QString::number(errorStatus)); | |
809 | } |
|
809 | } | |
810 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) |
|
810 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) | |
811 | { |
|
811 | { | |
812 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); |
|
812 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); | |
813 | //emit appendToLog("External port error status = " + QString::number(errorStatus)); |
|
813 | //emit appendToLog("External port error status = " + QString::number(errorStatus)); | |
814 | } |
|
814 | } | |
815 | else |
|
815 | else | |
816 | { |
|
816 | { | |
817 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); |
|
817 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); | |
818 | //emit appendToLog("SpaceWire link error status = " + QString::number(errorStatus)); |
|
818 | //emit appendToLog("SpaceWire link error status = " + QString::number(errorStatus)); | |
819 | } |
|
819 | } | |
820 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); |
|
820 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); | |
821 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); |
|
821 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); | |
822 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); |
|
822 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); | |
823 | CFGSpaceWire_LSIsStart(statusControl, &isStart); |
|
823 | CFGSpaceWire_LSIsStart(statusControl, &isStart); | |
824 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); |
|
824 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); | |
825 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); |
|
825 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); | |
826 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); |
|
826 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); | |
827 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); |
|
827 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); | |
828 | //emit appendToLog("The link state is = " + QString::number(linkStatus)); |
|
828 | //emit appendToLog("The link state is = " + QString::number(linkStatus)); | |
829 | //emit appendToLog("The link is running = " + QString::number(isLinkRunning)); |
|
829 | //emit appendToLog("The link is running = " + QString::number(isLinkRunning)); | |
830 | //emit appendToLog("The autostart bit is enabled = " + QString::number(isAutoStart)); |
|
830 | //emit appendToLog("The autostart bit is enabled = " + QString::number(isAutoStart)); | |
831 | //emit appendToLog("The start bit is enabled = " + QString::number(isStart)); |
|
831 | //emit appendToLog("The start bit is enabled = " + QString::number(isStart)); | |
832 | //emit appendToLog("The link is disabled = " + QString::number(isDisabled)); |
|
832 | //emit appendToLog("The link is disabled = " + QString::number(isDisabled)); | |
833 | //emit appendToLog("The tri-state bit is enabled = " + QString::number(isAutoStart)); |
|
833 | //emit appendToLog("The tri-state bit is enabled = " + QString::number(isAutoStart)); | |
834 | //emit appendToLog("The operating speed is = " + QString::number(operatingSpeed)); |
|
834 | //emit appendToLog("The operating speed is = " + QString::number(operatingSpeed)); | |
835 | //emit appendToLog("This port is currently connected to output port = " + QString::number(outputPortConnection)); |
|
835 | //emit appendToLog("This port is currently connected to output port = " + QString::number(outputPortConnection)); | |
836 | } |
|
836 | } | |
837 | if (linkStatus == 5) return 1; |
|
837 | if (linkStatus == 5) return 1; | |
838 | else return 0; |
|
838 | else return 0; | |
839 | } |
|
839 | } | |
840 |
|
840 | |||
841 | void StarDundee::spaceWireLinkHasChanged(unsigned char spaceWireLink) |
|
841 | void StarDundee::spaceWireLinkHasChanged(unsigned char spaceWireLink) | |
842 | { |
|
842 | { | |
843 | linkNumber_SPINBOX->setValue(spaceWireLink); |
|
843 | linkNumber_SPINBOX->setValue(spaceWireLink); | |
844 | } |
|
844 | } | |
845 |
|
845 | |||
846 | void StarDundee::receivePollingLoop() |
|
846 | void StarDundee::receivePollingLoop() | |
847 | { |
|
847 | { | |
848 | timer->blockSignals(true); |
|
848 | timer->blockSignals(true); | |
849 | if (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) receiveSPWPacketLoop(0); |
|
849 | if (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) receiveSPWPacketLoop(0); | |
850 | timer->blockSignals(false); |
|
850 | timer->blockSignals(false); | |
851 | } |
|
851 | } | |
852 |
|
852 | |||
853 | int StarDundee::receiveSPWPacketLoop(unsigned char requestID) |
|
853 | int StarDundee::receiveSPWPacketLoop(unsigned char requestID) | |
854 | { |
|
854 | { | |
855 | int result = 0; |
|
855 | int result = 0; | |
856 | emit appendToLog("Number of packets dropped by the driver: " + |
|
856 | emit appendToLog("Number of packets dropped by the driver: " + | |
857 | QString::number(USBSpaceWire_GetDriverDroppedPackets(hDevice))); |
|
857 | QString::number(USBSpaceWire_GetDriverDroppedPackets(hDevice))); | |
858 |
|
858 | |||
859 | while (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) |
|
859 | while (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) | |
860 | { |
|
860 | { | |
861 | result = receiveSPWPacket(requestID); |
|
861 | result = receiveSPWPacket(requestID); | |
862 | } |
|
862 | } | |
863 |
|
863 | |||
864 | return result; |
|
864 | return result; | |
865 | } |
|
865 | } | |
866 |
|
866 | |||
867 | int StarDundee::receiveSPWPacket(unsigned char requestID) // SLOT |
|
867 | int StarDundee::receiveSPWPacket(unsigned char requestID) // SLOT | |
868 | { |
|
868 | { | |
869 | unsigned int packetLength; |
|
869 | unsigned int packetLength; | |
870 | unsigned int nbBytes; |
|
870 | unsigned int nbBytes; | |
871 | unsigned nPacketNum; |
|
871 | unsigned nPacketNum; | |
872 | USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read |
|
872 | USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read | |
873 |
|
873 | |||
874 | if (requestID==1) |
|
874 | if (requestID==1) | |
875 | { |
|
875 | { | |
876 | if (rmapPacketSEMAPHORE->available()) |
|
876 | if (rmapPacketSEMAPHORE->available()) | |
877 | { |
|
877 | { | |
878 | return rmapPacketSize; |
|
878 | return rmapPacketSize; | |
879 | } |
|
879 | } | |
880 | } |
|
880 | } | |
881 |
|
881 | |||
882 | //******************** |
|
882 | //******************** | |
883 | // TRY TO RECEIVE DATA |
|
883 | // TRY TO RECEIVE DATA | |
884 | nbBytes = qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH); // maximum size of the packet to receive |
|
884 | nbBytes = qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH); // maximum size of the packet to receive | |
885 | nPacketNum = 1; |
|
885 | nPacketNum = 1; | |
886 | result = USBSpaceWire_ReadPackets(hDevice, spwPacket, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifierRead); |
|
886 | result = USBSpaceWire_ReadPackets(hDevice, spwPacket, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifierRead); | |
887 | if (result != TRANSFER_SUCCESS) |
|
887 | if (result != TRANSFER_SUCCESS) | |
888 | { |
|
888 | { | |
889 | emit sendMessage("Error: Could not receive the packet, result = " + QString::number(result)); |
|
889 | emit sendMessage("Error: Could not receive the packet, result = " + QString::number(result)); | |
890 | USBSpaceWire_FreeRead(hDevice, pIdentifierRead); // Free the read buffer |
|
890 | USBSpaceWire_FreeRead(hDevice, pIdentifierRead); // Free the read buffer | |
891 | return 0; |
|
891 | return 0; | |
892 | } |
|
892 | } | |
893 | else |
|
893 | else | |
894 | { |
|
894 | { | |
895 | packetLength = properties.len; |
|
895 | packetLength = properties.len; | |
896 | if (properties.eop == SPACEWIRE_USB_NO_EOP) |
|
896 | if (properties.eop == SPACEWIRE_USB_NO_EOP) | |
897 | { |
|
897 | { | |
898 | emit appendToLog("No end of packet marker received"); |
|
898 | emit appendToLog("No end of packet marker received"); | |
899 | } |
|
899 | } | |
900 | // else if (properties.eop == SPACEWIRE_USB_EOP) |
|
900 | // else if (properties.eop == SPACEWIRE_USB_EOP) | |
901 | // { |
|
901 | // { | |
902 | // emit appendToLog("Normal end of packet marker received"); |
|
902 | // emit appendToLog("Normal end of packet marker received"); | |
903 | // } |
|
903 | // } | |
904 | else if (properties.eop == SPACEWIRE_USB_EEP) |
|
904 | else if (properties.eop == SPACEWIRE_USB_EEP) | |
905 | { |
|
905 | { | |
906 | emit appendToLog("Error end of packet marker received"); |
|
906 | emit appendToLog("Error end of packet marker received"); | |
907 | } |
|
907 | } | |
908 |
|
908 | |||
909 | USBSpaceWire_FreeRead(hDevice, pIdentifierRead); // Free the read buffer |
|
909 | USBSpaceWire_FreeRead(hDevice, pIdentifierRead); // Free the read buffer | |
910 | } |
|
910 | } | |
911 |
|
911 | |||
912 | switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet |
|
912 | switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet | |
913 | { |
|
913 | { | |
914 | case 1: // 0x01 is the protocole identifier for RMAP packets |
|
914 | case 1: // 0x01 is the protocole identifier for RMAP packets | |
915 | if (rmapPacketSEMAPHORE->available()!=0) return -3; // ERROR === previous RMAP packet not processed yet |
|
915 | if (rmapPacketSEMAPHORE->available()!=0) return -3; // ERROR === previous RMAP packet not processed yet | |
916 | for(unsigned int i=0; i<packetLength; i++) rmapPacket[i] = spwPacket[i]; |
|
916 | for(unsigned int i=0; i<packetLength; i++) rmapPacket[i] = spwPacket[i]; | |
917 | rmapPacketSize = packetLength; |
|
917 | rmapPacketSize = packetLength; | |
918 | rmapPacketSEMAPHORE->release(); |
|
918 | rmapPacketSEMAPHORE->release(); | |
919 | // emit appendToLog("RMAP packet of size " + QString::number(packetLength) + " received"); |
|
919 | // emit appendToLog("RMAP packet of size " + QString::number(packetLength) + " received"); | |
920 | // emit appendToLog("packet received, B0 = " + QString::number(spwPacket[0], 16) |
|
920 | // emit appendToLog("packet received, B0 = " + QString::number(spwPacket[0], 16) | |
921 | // + " *** B1 = " + QString::number(spwPacket[1], 16) |
|
921 | // + " *** B1 = " + QString::number(spwPacket[1], 16) | |
922 | // + " *** B2 = " + QString::number(spwPacket[2], 16) |
|
922 | // + " *** B2 = " + QString::number(spwPacket[2], 16) | |
923 | // + " *** B3 = " + QString::number(spwPacket[3], 16) |
|
923 | // + " *** B3 = " + QString::number(spwPacket[3], 16) | |
924 | // + " *** B4 = " + QString::number(spwPacket[4], 16) |
|
924 | // + " *** B4 = " + QString::number(spwPacket[4], 16) | |
925 | // + " *** B5 = " + QString::number(spwPacket[5], 16) |
|
925 | // + " *** B5 = " + QString::number(spwPacket[5], 16) | |
926 | // ); |
|
926 | // ); | |
927 | return packetLength; |
|
927 | return packetLength; | |
928 |
|
928 | |||
929 | case 2: // 0x02 is the protocole identifier for CCSDS packets |
|
929 | case 2: // 0x02 is the protocole identifier for CCSDS packets | |
930 | if (ccsdsPacketSEMAPHORE->available()!=0) |
|
930 | if (ccsdsPacketSEMAPHORE->available()!=0) | |
931 | { |
|
931 | { | |
932 | emit sendMessage("in function [receiveSPWPacket] === ERROR === previous CCSDS packet not processed yet"); |
|
932 | emit sendMessage("in function [receiveSPWPacket] === ERROR === previous CCSDS packet not processed yet"); | |
933 | return -4; // ERROR === previous CCSDS packet not processed yet |
|
933 | return -4; // ERROR === previous CCSDS packet not processed yet | |
934 | } |
|
934 | } | |
935 | for(unsigned int i=0; i<packetLength; i++) ccsdsPacket[i] = spwPacket[i]; |
|
935 | for(unsigned int i=0; i<packetLength; i++) ccsdsPacket[i] = spwPacket[i]; | |
936 | ccsdsPacketSize = packetLength; |
|
936 | ccsdsPacketSize = packetLength; | |
937 | emit appendToLog("CCSDS packet of size " + QString::number(packetLength) + " received"); |
|
937 | emit appendToLog("CCSDS packet of size " + QString::number(packetLength) + " received"); | |
938 | emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) |
|
938 | emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) | |
939 | + " *** byte1 " + QString::number(spwPacket[1], 16) |
|
939 | + " *** byte1 " + QString::number(spwPacket[1], 16) | |
940 | + " *** byte2 " + QString::number(spwPacket[2], 16) |
|
940 | + " *** byte2 " + QString::number(spwPacket[2], 16) | |
941 | + " *** byte3 " + QString::number(spwPacket[3], 16)); |
|
941 | + " *** byte3 " + QString::number(spwPacket[3], 16)); | |
942 | storeCCSDSPacket(ccsdsPacket, packetLength); |
|
942 | storeCCSDSPacket(ccsdsPacket, packetLength); | |
943 | return packetLength; |
|
943 | return packetLength; | |
944 | default: |
|
944 | default: | |
945 | emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) |
|
945 | emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) | |
946 | + " *** byte1 " + QString::number(spwPacket[1], 16) |
|
946 | + " *** byte1 " + QString::number(spwPacket[1], 16) | |
947 | + " *** byte2 " + QString::number(spwPacket[2], 16) |
|
947 | + " *** byte2 " + QString::number(spwPacket[2], 16) | |
948 | + " *** byte3 " + QString::number(spwPacket[3], 16)); |
|
948 | + " *** byte3 " + QString::number(spwPacket[3], 16)); | |
949 | return 0; |
|
949 | return 0; | |
950 | } |
|
950 | } | |
951 | return 0; |
|
951 | return 0; | |
952 | } |
|
952 | } | |
953 |
|
953 | |||
954 | unsigned int StarDundee::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) |
|
954 | unsigned int StarDundee::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) | |
955 | { |
|
955 | { | |
956 | TMPacketToRead *generalPacket; |
|
956 | TMPacketToRead *generalPacket; | |
957 |
|
957 | |||
958 | generalPacket = new TMPacketToRead(ccsdsPacket, size); |
|
958 | generalPacket = new TMPacketToRead(ccsdsPacket, size); | |
959 | emit sendPacket(generalPacket); |
|
959 | emit sendPacket(generalPacket); | |
960 |
|
960 | |||
961 | return 1; |
|
961 | return 1; | |
962 | } |
|
962 | } | |
963 |
|
963 | |||
964 | void StarDundee::reTestSPWLink() // SLOT |
|
964 | void StarDundee::reTestSPWLink() // SLOT | |
965 | { |
|
965 | { | |
966 | if (getLinkStatus(linkNumber_SPINBOX->value())) |
|
966 | if (getLinkStatus(linkNumber_SPINBOX->value())) | |
967 | { |
|
967 | { | |
968 | emit isOpen(true); |
|
968 | emit isOpen(true); | |
969 | starDundeeStatusQueryDialog->accept(); |
|
969 | starDundeeStatusQueryDialog->accept(); | |
970 | } |
|
970 | } | |
971 | } |
|
971 | } | |
972 |
|
972 | |||
973 | unsigned char StarDundee::getPacketFirstByte() |
|
973 | unsigned char StarDundee::getPacketFirstByte() | |
974 | { |
|
974 | { | |
975 | unsigned char firstByte; |
|
975 | unsigned char firstByte; | |
976 | firstByte = (unsigned char) this->linkNumber_SPINBOX->value(); |
|
976 | firstByte = (unsigned char) this->linkNumber_SPINBOX->value(); | |
977 |
|
977 | |||
978 | return firstByte; |
|
978 | return firstByte; | |
979 | } |
|
979 | } | |
980 |
|
980 | |||
981 | //********** |
|
981 | //********** | |
982 | // TIMECODES |
|
982 | // TIMECODES | |
983 |
|
983 | |||
984 | void StarDundee::initializeTimecodeGeneration() |
|
984 | void StarDundee::initializeTimecodeGeneration() | |
985 | { |
|
985 | { | |
986 | U32 dwTickEnableStatus; |
|
986 | U32 dwTickEnableStatus; | |
987 | U32 rtr_clk_freq; |
|
987 | U32 rtr_clk_freq; | |
988 |
|
988 | |||
989 | // (1) RESET |
|
989 | // (1) RESET | |
990 | if (!USBSpaceWire_TC_Reset(hDevice)) |
|
990 | if (!USBSpaceWire_TC_Reset(hDevice)) | |
991 | emit sendMessage("ERR *** in Open *** Could not reset timecodes\n"); |
|
991 | emit sendMessage("ERR *** in Open *** Could not reset timecodes\n"); | |
992 |
|
992 | |||
993 | // (2) Clear the tick enable register |
|
993 | // (2) Clear the tick enable register | |
994 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) |
|
994 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) | |
995 | emit sendMessage("Could not clear the tick enable register"); |
|
995 | emit sendMessage("Could not clear the tick enable register"); | |
996 | else |
|
996 | else | |
997 | emit sendMessage("Cleared the tick enable register"); |
|
997 | emit sendMessage("Cleared the tick enable register"); | |
998 |
|
998 | |||
999 | // (3) get the tick status |
|
999 | // (3) get the tick status | |
1000 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); |
|
1000 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); | |
1001 | emit sendMessage("OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); |
|
1001 | emit sendMessage("OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); | |
1002 |
|
1002 | |||
1003 | // (4) enable external timecode selection |
|
1003 | // (4) enable external timecode selection | |
1004 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
1004 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
1005 | emit sendMessage("ERR *** disable external timecode selection"); |
|
1005 | emit sendMessage("ERR *** disable external timecode selection"); | |
1006 |
|
1006 | |||
1007 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
1007 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
1008 |
|
1008 | |||
1009 | emit sendMessage("clock frequency = " + QString::number(rtr_clk_freq) ); |
|
1009 | emit sendMessage("clock frequency = " + QString::number(rtr_clk_freq) ); | |
1010 |
|
1010 | |||
1011 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) |
|
1011 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) | |
1012 | emit sendMessage("Could not set the tick-in frequency"); |
|
1012 | emit sendMessage("Could not set the tick-in frequency"); | |
1013 |
|
1013 | |||
1014 | starDundeeSendOneTimecode->setEnabled( true ); |
|
1014 | starDundeeSendOneTimecode->setEnabled( true ); | |
1015 | starDundeeSendTimecodePeriodically->setEnabled( true ); |
|
1015 | starDundeeSendTimecodePeriodically->setEnabled( true ); | |
1016 | starDundeeSendOneTimePacketAndOneTimecode->setEnabled( true ); |
|
1016 | starDundeeSendOneTimePacketAndOneTimecode->setEnabled( true ); | |
1017 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( true ); |
|
1017 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( true ); | |
1018 | } |
|
1018 | } | |
1019 |
|
1019 | |||
1020 | void StarDundee::sendOneTimecode() |
|
1020 | void StarDundee::sendOneTimecode() | |
1021 | { |
|
1021 | { | |
1022 | if(!USBSpaceWire_TC_PerformTickIn(hDevice, 0)) |
|
1022 | if(!USBSpaceWire_TC_PerformTickIn(hDevice, 0)) | |
1023 | emit sendMessage("ERR *** in sendOneTimecode *** perform TickIn"); |
|
1023 | emit sendMessage("ERR *** in sendOneTimecode *** perform TickIn"); | |
1024 | } |
|
1024 | } | |
1025 |
|
1025 | |||
1026 | void StarDundee::sendOneTimePacketAndOneTimecode() |
|
1026 | void StarDundee::sendOneTimePacketAndOneTimecode() | |
1027 | { |
|
1027 | { | |
1028 | sendUpdateTime( arbitraryTimeToSend ); |
|
1028 | sendUpdateTime( arbitraryTimeToSend ); | |
1029 | QTimer::singleShot(300, this, SLOT(sendOneTimecode())); |
|
1029 | QTimer::singleShot(300, this, SLOT(sendOneTimecode())); | |
1030 | } |
|
1030 | } | |
1031 |
|
1031 | |||
1032 | void StarDundee::sendOneTimePacketAndTimecodePeriodically() |
|
1032 | void StarDundee::sendOneTimePacketAndTimecodePeriodically() | |
1033 | { |
|
1033 | { | |
1034 | sendUpdateTime( arbitraryTimeToSend ); |
|
1034 | sendUpdateTime( arbitraryTimeToSend ); | |
1035 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); |
|
1035 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); | |
1036 | QTimer::singleShot(300, this, SLOT(sendTimecodePeriodically())); |
|
1036 | QTimer::singleShot(300, this, SLOT(sendTimecodePeriodically())); | |
1037 | } |
|
1037 | } | |
1038 |
|
1038 | |||
1039 | void StarDundee::sendTimecodePeriodically() |
|
1039 | void StarDundee::sendTimecodePeriodically() | |
1040 | { |
|
1040 | { | |
1041 | if (flag_sendTimecodePeriodically == false) |
|
1041 | if (flag_sendTimecodePeriodically == false) | |
1042 | { |
|
1042 | { | |
1043 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) |
|
1043 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |
1044 | emit sendMessage("Could not enable auto tick-in"); |
|
1044 | emit sendMessage("Could not enable auto tick-in"); | |
1045 |
|
1045 | |||
1046 | flag_sendTimecodePeriodically = true; |
|
1046 | flag_sendTimecodePeriodically = true; | |
1047 | this->starDundeeSendTimecodePeriodically->setText("stop timecodes at 1 Hz"); |
|
1047 | this->starDundeeSendTimecodePeriodically->setText("stop timecodes at 1 Hz"); | |
|
1048 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); | |||
1048 | } |
|
1049 | } | |
1049 | else |
|
1050 | else | |
1050 | { |
|
1051 | { | |
1051 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) |
|
1052 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |
1052 | emit sendMessage("Could not disable auto tick-in"); |
|
1053 | emit sendMessage("Could not disable auto tick-in"); | |
1053 |
|
1054 | |||
1054 | flag_sendTimecodePeriodically = false; |
|
1055 | flag_sendTimecodePeriodically = false; | |
1055 | this->starDundeeSendTimecodePeriodically->setText("start timecodes at 1 Hz"); |
|
1056 | this->starDundeeSendTimecodePeriodically->setText("start timecodes at 1 Hz"); | |
1056 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( true ); |
|
1057 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( true ); | |
1057 | } |
|
1058 | } | |
1058 | } |
|
1059 | } | |
1059 |
|
1060 | |||
|
1061 | void StarDundee::startSendingTimecodePeriodically(unsigned char onOff) | |||
|
1062 | { | |||
|
1063 | if (onOff == 0) | |||
|
1064 | { | |||
|
1065 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |||
|
1066 | emit sendMessage("Could not disable auto tick-in"); | |||
|
1067 | ||||
|
1068 | flag_sendTimecodePeriodically = false; | |||
|
1069 | this->starDundeeSendTimecodePeriodically->setText("start timecodes at 1 Hz"); | |||
|
1070 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( true ); | |||
|
1071 | } | |||
|
1072 | else | |||
|
1073 | { | |||
|
1074 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |||
|
1075 | emit sendMessage("Could not enable auto tick-in"); | |||
|
1076 | ||||
|
1077 | flag_sendTimecodePeriodically = true; | |||
|
1078 | this->starDundeeSendTimecodePeriodically->setText("stop timecodes at 1 Hz"); | |||
|
1079 | starDundeeSendOneTimePacketAndTimecodePeriodically->setEnabled( false ); | |||
|
1080 | } | |||
|
1081 | } | |||
|
1082 | ||||
1060 | void StarDundee::sendUpdateTime(long time) |
|
1083 | void StarDundee::sendUpdateTime(long time) | |
1061 | { |
|
1084 | { | |
1062 | Packet_TC_LFR_UPDATE_TIME_t packet; |
|
1085 | Packet_TC_LFR_UPDATE_TIME_t packet; | |
1063 | unsigned char crcAsTwoBytes[2]; |
|
1086 | unsigned char crcAsTwoBytes[2]; | |
1064 |
|
1087 | |||
1065 | packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); |
|
1088 | packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | |
1066 | packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); |
|
1089 | packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | |
1067 | packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); |
|
1090 | packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | |
1068 | packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); |
|
1091 | packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | |
1069 | packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME >> 8); |
|
1092 | packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME >> 8); | |
1070 | packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME ); |
|
1093 | packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME ); | |
1071 |
|
1094 | |||
1072 | packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; |
|
1095 | packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | |
1073 | packet.serviceType = TC_TYPE_LFR_UPDATE_TIME; |
|
1096 | packet.serviceType = TC_TYPE_LFR_UPDATE_TIME; | |
1074 | packet.serviceSubType = TC_SUBTYPE_UPDATE_TIME; |
|
1097 | packet.serviceSubType = TC_SUBTYPE_UPDATE_TIME; | |
1075 | packet.sourceID = SID_TC_RPW_INTERNAL; |
|
1098 | packet.sourceID = SID_TC_RPW_INTERNAL; | |
1076 | packet.cp_rpw_time[0] = (unsigned char) (time >> 24); |
|
1099 | packet.cp_rpw_time[0] = (unsigned char) (time >> 24); | |
1077 | packet.cp_rpw_time[1] = (unsigned char) (time >> 16); |
|
1100 | packet.cp_rpw_time[1] = (unsigned char) (time >> 16); | |
1078 | packet.cp_rpw_time[2] = (unsigned char) (time >> 8); |
|
1101 | packet.cp_rpw_time[2] = (unsigned char) (time >> 8); | |
1079 | packet.cp_rpw_time[3] = (unsigned char) (time); |
|
1102 | packet.cp_rpw_time[3] = (unsigned char) (time); | |
1080 | packet.cp_rpw_time[4] = 0; // fine time MSB |
|
1103 | packet.cp_rpw_time[4] = 0; // fine time MSB | |
1081 | packet.cp_rpw_time[5] = 0; // fine time LSB |
|
1104 | packet.cp_rpw_time[5] = 0; // fine time LSB | |
1082 |
|
1105 | |||
1083 | paulCommonCRC->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, |
|
1106 | paulCommonCRC->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | |
1084 | PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET - 2); |
|
1107 | PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET - 2); | |
1085 | packet.crc[0] = crcAsTwoBytes[0]; |
|
1108 | packet.crc[0] = crcAsTwoBytes[0]; | |
1086 | packet.crc[1] = crcAsTwoBytes[1]; |
|
1109 | packet.crc[1] = crcAsTwoBytes[1]; | |
1087 |
|
1110 | |||
1088 | WriteSPW((char*) &packet, PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET, |
|
1111 | WriteSPW((char*) &packet, PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET, | |
1089 | CCSDS_NODE_ADDRESS, CCSDS_USER_APP); |
|
1112 | CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | |
1090 | } |
|
1113 | } | |
1091 |
|
1114 | |||
1092 | void StarDundee::updateTimeToSend(long timeToSend) |
|
1115 | void StarDundee::updateTimeToSend(long timeToSend) | |
1093 | { |
|
1116 | { | |
1094 | arbitraryTimeToSend = timeToSend; |
|
1117 | arbitraryTimeToSend = timeToSend; | |
1095 | } |
|
1118 | } |
@@ -1,133 +1,134 | |||||
1 | #ifndef STARDUNDEE_H |
|
1 | #ifndef STARDUNDEE_H | |
2 | #define STARDUNDEE_H |
|
2 | #define STARDUNDEE_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
5 | #include <QPushButton> |
|
5 | #include <QPushButton> | |
6 | #include <QGridLayout> |
|
6 | #include <QGridLayout> | |
7 | #include <QSpinBox> |
|
7 | #include <QSpinBox> | |
8 | #include <QLabel> |
|
8 | #include <QLabel> | |
9 | #include <QSemaphore> |
|
9 | #include <QSemaphore> | |
10 | #include <QTimer> |
|
10 | #include <QTimer> | |
11 | #include <QDialog> |
|
11 | #include <QDialog> | |
12 |
|
12 | |||
13 | #include <arbitrarytime.h> |
|
13 | #include <arbitrarytime.h> | |
14 | #include <TC_types.h> |
|
14 | #include <TC_types.h> | |
15 | #include <paulcommoncrc.h> |
|
15 | #include <paulcommoncrc.h> | |
16 |
|
16 | |||
17 | #include "rmapoperations.h" |
|
17 | #include "rmapoperations.h" | |
18 | #include "spw_usb_api.h" |
|
18 | #include "spw_usb_api.h" | |
19 | #include "spw_config_library.h" |
|
19 | #include "spw_config_library.h" | |
20 | #include "ccsds.h" |
|
20 | #include "ccsds.h" | |
21 | #include "tmpackettoread.h" |
|
21 | #include "tmpackettoread.h" | |
22 |
|
22 | |||
23 | #define BWAIT_0 0 |
|
23 | #define BWAIT_0 0 | |
24 | #define BWAIT_1 1 |
|
24 | #define BWAIT_1 1 | |
25 | #define PATH_ADDRESSING_OFFSET 1 |
|
25 | #define PATH_ADDRESSING_OFFSET 1 | |
26 |
|
26 | |||
27 | class StarDundee : public QWidget |
|
27 | class StarDundee : public QWidget | |
28 | { |
|
28 | { | |
29 | Q_OBJECT |
|
29 | Q_OBJECT | |
30 | public: |
|
30 | public: | |
31 | explicit StarDundee(QWidget *parent = 0); |
|
31 | explicit StarDundee(QWidget *parent = 0); | |
32 | ~StarDundee(); |
|
32 | ~StarDundee(); | |
33 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
33 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); | |
34 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
34 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); | |
35 | unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); |
|
35 | unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
36 |
|
36 | |||
37 | unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); |
|
37 | unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); | |
38 |
|
38 | |||
39 | void initializeTimecodeGeneration(); |
|
39 | void initializeTimecodeGeneration(); | |
40 | void sendUpdateTime(long time); |
|
40 | void sendUpdateTime(long time); | |
41 |
|
41 | |||
42 | signals: |
|
42 | signals: | |
43 | void sendMessage(QString message); |
|
43 | void sendMessage(QString message); | |
44 | void sendPacket(TMPacketToRead*); |
|
44 | void sendPacket(TMPacketToRead*); | |
45 | void isOpen(bool); |
|
45 | void isOpen(bool); | |
46 | void RMAP_write_reply_setText(QString); |
|
46 | void RMAP_write_reply_setText(QString); | |
47 | void appendToLog(QString); |
|
47 | void appendToLog(QString); | |
48 |
|
48 | |||
49 | public slots: |
|
49 | public slots: | |
50 | bool Open(); |
|
50 | bool Open(); | |
51 | void Close(); |
|
51 | void Close(); | |
52 | void reTestSPWLink(); |
|
52 | void reTestSPWLink(); | |
53 | int receiveSPWPacketLoop(unsigned char requestID=0); |
|
53 | int receiveSPWPacketLoop(unsigned char requestID=0); | |
54 | int receiveSPWPacket(unsigned char requestID=0); |
|
54 | int receiveSPWPacket(unsigned char requestID=0); | |
55 | void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} |
|
55 | void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} | |
56 | void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} |
|
56 | void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} | |
57 | void sourceHasChanged(int source) {rmapSourceLogicalAddress = (unsigned char) source;} |
|
57 | void sourceHasChanged(int source) {rmapSourceLogicalAddress = (unsigned char) source;} | |
58 | void spaceWireLinkHasChanged(unsigned char spaceWireLink); |
|
58 | void spaceWireLinkHasChanged(unsigned char spaceWireLink); | |
59 | void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} |
|
59 | void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} | |
60 | // |
|
60 | // | |
61 | void receivePollingLoop(); |
|
61 | void receivePollingLoop(); | |
62 | // TIMECODES |
|
62 | // TIMECODES | |
63 | void sendOneTimecode(); |
|
63 | void sendOneTimecode(); | |
64 | void sendTimecodePeriodically(); |
|
64 | void sendTimecodePeriodically(); | |
|
65 | void startSendingTimecodePeriodically( unsigned char onOff ); | |||
65 | void sendOneTimePacketAndOneTimecode(); |
|
66 | void sendOneTimePacketAndOneTimecode(); | |
66 | void sendOneTimePacketAndTimecodePeriodically(); |
|
67 | void sendOneTimePacketAndTimecodePeriodically(); | |
67 | void updateTimeToSend(long timeToSend); |
|
68 | void updateTimeToSend(long timeToSend); | |
68 |
|
69 | |||
69 | private: |
|
70 | private: | |
70 | unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0); |
|
71 | unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0); | |
71 | unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0); |
|
72 | unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0); | |
72 | void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->tryAcquire();} |
|
73 | void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->tryAcquire();} | |
73 | void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->tryAcquire();} |
|
74 | void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->tryAcquire();} | |
74 |
|
75 | |||
75 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts); |
|
76 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts); | |
76 | unsigned int GetRoutingTableEntry(int tableEntry); |
|
77 | unsigned int GetRoutingTableEntry(int tableEntry); | |
77 | unsigned int getLinkStatus(unsigned char link); |
|
78 | unsigned int getLinkStatus(unsigned char link); | |
78 | unsigned char getPacketFirstByte(); |
|
79 | unsigned char getPacketFirstByte(); | |
79 |
|
80 | |||
80 | unsigned char rmapTargetLogicalAddress ; |
|
81 | unsigned char rmapTargetLogicalAddress ; | |
81 | unsigned char rmapSourceLogicalAddress ; |
|
82 | unsigned char rmapSourceLogicalAddress ; | |
82 |
|
83 | |||
83 | RMAP_command_codes commandCode; |
|
84 | RMAP_command_codes commandCode; | |
84 |
|
85 | |||
85 | QLabel *usbDeviceNumber_LABEL; |
|
86 | QLabel *usbDeviceNumber_LABEL; | |
86 | QLabel *linkNumber_LABEL; |
|
87 | QLabel *linkNumber_LABEL; | |
87 | QLabel *starDundeeStatusQueryDialogLabel; |
|
88 | QLabel *starDundeeStatusQueryDialogLabel; | |
88 | QLabel *statusLink1; |
|
89 | QLabel *statusLink1; | |
89 | QLabel *statusLink2; |
|
90 | QLabel *statusLink2; | |
90 |
|
91 | |||
91 | QSpinBox *usbDeviceNumber_SPINBOX; |
|
92 | QSpinBox *usbDeviceNumber_SPINBOX; | |
92 | QSpinBox *linkNumber_SPINBOX; |
|
93 | QSpinBox *linkNumber_SPINBOX; | |
93 |
|
94 | |||
94 | QGridLayout *connection_LAYOUT; |
|
95 | QGridLayout *connection_LAYOUT; | |
95 | QGridLayout *starDundeeStatusQueryDialogLayout; |
|
96 | QGridLayout *starDundeeStatusQueryDialogLayout; | |
96 |
|
97 | |||
97 | QDialog *starDundeeStatusQueryDialog; |
|
98 | QDialog *starDundeeStatusQueryDialog; | |
98 |
|
99 | |||
99 | QPushButton *starDundeeStatusQueryRetryButton; |
|
100 | QPushButton *starDundeeStatusQueryRetryButton; | |
100 | QPushButton *starDundeeStatusQueryAbortButton; |
|
101 | QPushButton *starDundeeStatusQueryAbortButton; | |
101 | QPushButton *starDundeeStatusQueryContinueButton; |
|
102 | QPushButton *starDundeeStatusQueryContinueButton; | |
102 | QPushButton *starDundeeSendOneTimecode; |
|
103 | QPushButton *starDundeeSendOneTimecode; | |
103 | QPushButton *starDundeeSendOneTimePacketAndOneTimecode; |
|
104 | QPushButton *starDundeeSendOneTimePacketAndOneTimecode; | |
104 | QPushButton *starDundeeSendTimecodePeriodically; |
|
105 | QPushButton *starDundeeSendTimecodePeriodically; | |
105 | QPushButton *starDundeeSendOneTimePacketAndTimecodePeriodically; |
|
106 | QPushButton *starDundeeSendOneTimePacketAndTimecodePeriodically; | |
106 |
|
107 | |||
107 | ArbitraryTime *arbitraryTime; |
|
108 | ArbitraryTime *arbitraryTime; | |
108 | long arbitraryTimeToSend; |
|
109 | long arbitraryTimeToSend; | |
109 |
|
110 | |||
110 | PaulCommonCRC *paulCommonCRC; |
|
111 | PaulCommonCRC *paulCommonCRC; | |
111 |
|
112 | |||
112 | bool flag_sendTimecodePeriodically; |
|
113 | bool flag_sendTimecodePeriodically; | |
113 |
|
114 | |||
114 | QTimer *timer; |
|
115 | QTimer *timer; | |
115 |
|
116 | |||
116 | unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data |
|
117 | unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data | |
117 | USB_SPACEWIRE_ID pIdentifierRead; // A pointer to a variable which will be set to contain a unique identifier for the read |
|
118 | USB_SPACEWIRE_ID pIdentifierRead; // A pointer to a variable which will be set to contain a unique identifier for the read | |
118 | USB_SPACEWIRE_ID pIdentifier; |
|
119 | USB_SPACEWIRE_ID pIdentifier; | |
119 |
|
120 | |||
120 | star_device_handle hDevice; // Handle to the SpaceWire device |
|
121 | star_device_handle hDevice; // Handle to the SpaceWire device | |
121 | USB_SPACEWIRE_STATUS result; // The result of the send operation |
|
122 | USB_SPACEWIRE_STATUS result; // The result of the send operation | |
122 |
|
123 | |||
123 | // Packet receiver |
|
124 | // Packet receiver | |
124 | QSemaphore *rmapPacketSEMAPHORE; |
|
125 | QSemaphore *rmapPacketSEMAPHORE; | |
125 | QSemaphore *ccsdsPacketSEMAPHORE; |
|
126 | QSemaphore *ccsdsPacketSEMAPHORE; | |
126 | char* rmapPacket; // The buffer to receive RMAP READ packets |
|
127 | char* rmapPacket; // The buffer to receive RMAP READ packets | |
127 | unsigned char *ccsdsPacket; |
|
128 | unsigned char *ccsdsPacket; | |
128 | char *spwPacket; |
|
129 | char *spwPacket; | |
129 | unsigned int rmapPacketSize; |
|
130 | unsigned int rmapPacketSize; | |
130 | unsigned int ccsdsPacketSize; |
|
131 | unsigned int ccsdsPacketSize; | |
131 | }; |
|
132 | }; | |
132 |
|
133 | |||
133 | #endif // STARDUNDEE_H |
|
134 | #endif // STARDUNDEE_H |
General Comments 0
You need to be logged in to leave comments.
Login now