This diff has been collapsed as it changes many lines, (653 lines changed) Show them Hide them | |||||
@@ -0,0 +1,653 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
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 | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
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 | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #include "fakestardundeespwusb_lib.h" | |||
|
23 | #include <QDebug> | |||
|
24 | ||||
|
25 | ||||
|
26 | char (*resolved_USBSpaceWire_Open)(star_device_handle *phDevice, int nDeviceNum)=NULL; | |||
|
27 | void (*resolved_USBSpaceWire_Close)(star_device_handle hDevice)=NULL; | |||
|
28 | U32 (*resolved_USBSpaceWire_ListDevices)()=NULL; | |||
|
29 | char (*resolved_USBSpaceWire_GetSerialNumber)(star_device_handle hDevice, U8 pSerialNumber[11])=NULL; | |||
|
30 | void (*resolved_USBSpaceWire_EnableNetworkMode)(star_device_handle hDevice, char enable)=NULL; | |||
|
31 | char (*resolved_USBSpaceWire_RegisterReceiveOnAllPorts)(star_device_handle hDevice)=NULL; | |||
|
32 | char (*resolved_USBSpaceWire_UnregisterReceiveOnAllPorts)(star_device_handle hDevice)=NULL; | |||
|
33 | char (*resolved_USBSpaceWire_ClearEndpoints)(star_device_handle hDevice)=NULL; | |||
|
34 | void (*resolved_USBSpaceWire_SetTimeout)(star_device_handle hDevice, double timeout)=NULL; | |||
|
35 | char (*resolved_USBSpaceWire_TC_Reset)(star_device_handle hDevice)=NULL; | |||
|
36 | char (*resolved_USBSpaceWire_TC_EnableExternalTimecodeSelection)(star_device_handle hDevice,char enable)=NULL; | |||
|
37 | U32 (*resolved_USBSpaceWire_TC_GetClockFrequency)(star_device_handle hDevice)=NULL; | |||
|
38 | char (*resolved_USBSpaceWire_TC_SetAutoTickInFrequency)(star_device_handle hDevice, U32 frequency)=NULL; | |||
|
39 | char (*resolved_USBSpaceWire_TC_EnableAutoTickIn)(star_device_handle hDevice, char enableAutoTickIns, char enableAllPorts)=NULL; | |||
|
40 | char (*resolved_USBSpaceWire_TC_PerformTickIn)(star_device_handle hDevice, U8 timein)=NULL; | |||
|
41 | U32 (*resolved_USBSpaceWire_GetDriverSendBufferSize)(star_device_handle hDevice)=NULL; | |||
|
42 | U32 (*resolved_USBSpaceWire_GetDriverReadBufferSize)(star_device_handle hDevice)=NULL; | |||
|
43 | char (*resolved_USBSpaceWire_IsReadThrottling)(star_device_handle hDevice)=NULL; | |||
|
44 | ||||
|
45 | char (*resolved_USBSpaceWire_WaitOnReadPacketAvailable)(star_device_handle hDevice, double timeout)=NULL; | |||
|
46 | USB_SPACEWIRE_STATUS (*resolved_USBSpaceWire_SendPacket)(star_device_handle hDevice, void *pBuffer, U32 nBufferSize, char bWait,USB_SPACEWIRE_ID *identifier)=NULL; | |||
|
47 | char (*resolved_USBSpaceWire_FreeSend)(star_device_handle hDevice, USB_SPACEWIRE_ID identifier)=NULL; | |||
|
48 | USB_SPACEWIRE_STATUS (*resolved_USBSpaceWire_ReadPackets)(star_device_handle hDevice, void *pBuffer, U32 nBufferSize,U32 nPacketNum, char bWait, PUSB_SPACEWIRE_PACKET_PROPERTIES properties,USB_SPACEWIRE_ID *identifier)=NULL; | |||
|
49 | char (*resolved_USBSpaceWire_FreeRead)(star_device_handle hDevice, USB_SPACEWIRE_ID identifier)=NULL; | |||
|
50 | SPACEWIRE_TRAFFIC_TYPE (*resolved_USBSpaceWire_GetReadTrafficType)(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties, U32 nPacketNum)=NULL; | |||
|
51 | USB_SPACEWIRE_EOP_TYPE (*resolved_USBSpaceWire_GetReadEOPStatus)(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties,U32 nPacketNum)=NULL; | |||
|
52 | ||||
|
53 | void (*resolved_CFGSpaceWire_EnableRMAP)(char useRMAP)=NULL; | |||
|
54 | void (*resolved_CFGSpaceWire_SetRMAPDestinationKey)(U8 destinationKey)=NULL; | |||
|
55 | void (*resolved_CFGSpaceWire_StackClear)(void)=NULL; | |||
|
56 | void (*resolved_CFGSpaceWire_AddrStackPush)(U8 dwAddress)=NULL; | |||
|
57 | void (*resolved_CFGSpaceWire_RetAddrStackPush)(U8 dwAddress)=NULL; | |||
|
58 | int (*resolved_CFGSpaceWire_SetBrickBaseTransmitRate)(star_device_handle hDevice, U32 dwBaseClk, U32 dwBaseDvdr, U32 dwEnableClk)=NULL; | |||
|
59 | int (*resolved_CFGSpaceWire_GetLinkStatusControl)(star_device_handle hDevice, U32 dwLinkNum, U32 *dwStatusControl)=NULL; | |||
|
60 | void (*resolved_CFGSpaceWire_LSEnableAutoStart)(U32 *dwStatusControl, char bEnabled)=NULL; | |||
|
61 | void (*resolved_CFGSpaceWire_LSEnableStart)(U32 *dwStatusControl, char bEnabled)=NULL; | |||
|
62 | void (*resolved_CFGSpaceWire_LSEnableDisabled)(U32 *dwStatusControl, char bEnabled)=NULL; | |||
|
63 | void (*resolved_CFGSpaceWire_LSEnableTristate)(U32 *dwStatusControl, char bEnabled)=NULL; | |||
|
64 | void (*resolved_CFGSpaceWire_LSPortType)(U32 dwStatusControl, U32 *dwPortType)=NULL; | |||
|
65 | void (*resolved_CFGSpaceWire_LSSetOperatingSpeed)(U32 *dwStatusControl, U32 dwOperatingSpeed)=NULL; | |||
|
66 | void (*resolved_CFGSpaceWire_LSConfigErrorStatus)(U32 dwStatusControl, U32 *dwErrorStatus)=NULL; | |||
|
67 | void (*resolved_CFGSpaceWire_LSExternalErrorStatus)(U32 dwStatusControl, U32 *dwErrorStatus)=NULL; | |||
|
68 | void (*resolved_CFGSpaceWire_LSErrorStatus)(U32 dwStatusControl, U32 *dwErrorStatus)=NULL; | |||
|
69 | void (*resolved_CFGSpaceWire_LSLinkState)(U32 dwStatusControl, U32 *dwLinkStatus)=NULL; | |||
|
70 | void (*resolved_CFGSpaceWire_LSIsLinkRunning)(U32 dwStatusControl, char *isLinkRunning)=NULL; | |||
|
71 | void (*resolved_CFGSpaceWire_LSIsAutoStart)(U32 dwStatusControl, char *isAutoStart)=NULL; | |||
|
72 | void (*resolved_CFGSpaceWire_LSIsStart)(U32 dwStatusControl, char *isStart)=NULL; | |||
|
73 | void (*resolved_CFGSpaceWire_LSIsDisabled)(U32 dwStatusControl, char *isDisabled)=NULL; | |||
|
74 | void (*resolved_CFGSpaceWire_LSIsTristate)(U32 dwStatusControl, char *isTristate)=NULL; | |||
|
75 | void (*resolved_CFGSpaceWire_LSOperatingSpeed)(U32 dwStatusControl, U32 *dwOperatingSpeed)=NULL; | |||
|
76 | void (*resolved_CFGSpaceWire_LSOutputPortConnection)(U32 dwStatusControl, U32 *dwOutputPortConnection)=NULL; | |||
|
77 | int (*resolved_CFGSpaceWire_SetLinkStatusControl)(star_device_handle hDevice, U32 dwLinkNum, U32 dwStatusControl)=NULL; | |||
|
78 | int (*resolved_CFGSpaceWire_SetAsInterface)(star_device_handle hDevice, char bEnabled, char bAddIdentifier)=NULL; | |||
|
79 | int (*resolved_CFGSpaceWire_ClearRoutingTableEntry)(star_device_handle hDevice, U32 nLogicalAddress)=NULL; | |||
|
80 | void (*resolved_CFGSpaceWire_RTBuildRoutingTableEntry)(U32 *dwRoutingTableEntry,U32 dwOutputPorts, char bDelHead, char bPriority)=NULL; | |||
|
81 | int (*resolved_CFGSpaceWire_SetRoutingTableEntry)(star_device_handle hDevice, U32 nLogicalAddress, U32 dwRoutingTableEntry)=NULL; | |||
|
82 | int (*resolved_CFGSpaceWire_GetRoutingTableEntry)(star_device_handle hDevice, U32 nLogicalAddress, U32 *dwRoutingTableEntry)=NULL; | |||
|
83 | void (*resolved_CFGSpaceWire_RTIsEnabled)(U32 dwRoutingTableEntry, char *bEnabled)=NULL; | |||
|
84 | void (*resolved_CFGSpaceWire_RTIsDelHead)(U32 dwRoutingTableEntry, char *bDelHead)=NULL; | |||
|
85 | void (*resolved_CFGSpaceWire_RTIsPriority)(U32 dwRoutingTableEntry, char *bPriority)=NULL; | |||
|
86 | void (*resolved_CFGSpaceWire_RTGetOutputPorts)(U32 dwRoutingTableEntry, U32 *dwOutputPorts)=NULL; | |||
|
87 | int (*resolved_CFGSpaceWire_GetTickEnableStatus)(star_device_handle hDevice, U32 *dwTickEnableStatus)=NULL; | |||
|
88 | int (*resolved_CFGSpaceWire_SetTickEnableStatus)(star_device_handle hDevice, U32 dwTickEnableStatus)=NULL; | |||
|
89 | ||||
|
90 | ||||
|
91 | typedef struct funcToresolve | |||
|
92 | { | |||
|
93 | void (** function)(); | |||
|
94 | const char* symbolName; | |||
|
95 | }funcToresolve; | |||
|
96 | ||||
|
97 | QList<funcToresolve> funcTable=QList<funcToresolve>() | |||
|
98 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_Open,"USBSpaceWire_Open"} | |||
|
99 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_Close,"USBSpaceWire_Close"} | |||
|
100 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_ListDevices,"USBSpaceWire_ListDevices"} | |||
|
101 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_GetSerialNumber,"USBSpaceWire_GetSerialNumber"} | |||
|
102 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_EnableNetworkMode,"USBSpaceWire_EnableNetworkMode"} | |||
|
103 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_RegisterReceiveOnAllPorts,"USBSpaceWire_RegisterReceiveOnAllPorts"} | |||
|
104 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_UnregisterReceiveOnAllPorts,"USBSpaceWire_UnregisterReceiveOnAllPorts"} | |||
|
105 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_ClearEndpoints,"USBSpaceWire_ClearEndpoints"} | |||
|
106 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_SetTimeout,"USBSpaceWire_SetTimeout"} | |||
|
107 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_Reset,"USBSpaceWire_TC_Reset"} | |||
|
108 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_EnableExternalTimecodeSelection,"USBSpaceWire_TC_EnableExternalTimecodeSelection"} | |||
|
109 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_GetClockFrequency,"USBSpaceWire_TC_GetClockFrequency"} | |||
|
110 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_SetAutoTickInFrequency,"USBSpaceWire_TC_SetAutoTickInFrequency"} | |||
|
111 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_EnableAutoTickIn,"USBSpaceWire_TC_EnableAutoTickIn"} | |||
|
112 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_TC_PerformTickIn,"USBSpaceWire_TC_PerformTickIn"} | |||
|
113 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_GetDriverSendBufferSize,"USBSpaceWire_GetDriverSendBufferSize"} | |||
|
114 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_GetDriverReadBufferSize,"USBSpaceWire_GetDriverReadBufferSize"} | |||
|
115 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_IsReadThrottling,"USBSpaceWire_IsReadThrottling"} | |||
|
116 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_WaitOnReadPacketAvailable,"USBSpaceWire_WaitOnReadPacketAvailable"} | |||
|
117 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_SendPacket,"USBSpaceWire_SendPacket"} | |||
|
118 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_FreeSend,"USBSpaceWire_FreeSend"} | |||
|
119 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_ReadPackets,"USBSpaceWire_ReadPackets"} | |||
|
120 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_FreeRead,"USBSpaceWire_FreeRead"} | |||
|
121 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_GetReadTrafficType,"USBSpaceWire_GetReadTrafficType"} | |||
|
122 | <<funcToresolve{(void (**)())&resolved_USBSpaceWire_GetReadEOPStatus,"USBSpaceWire_GetReadEOPStatus"} | |||
|
123 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_EnableRMAP,"CFGSpaceWire_EnableRMAP"} | |||
|
124 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetRMAPDestinationKey,"CFGSpaceWire_SetRMAPDestinationKey"} | |||
|
125 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_StackClear,"CFGSpaceWire_StackClear"} | |||
|
126 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_AddrStackPush,"CFGSpaceWire_AddrStackPush"} | |||
|
127 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RetAddrStackPush,"CFGSpaceWire_RetAddrStackPush"} | |||
|
128 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetBrickBaseTransmitRate,"CFGSpaceWire_SetBrickBaseTransmitRate"} | |||
|
129 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_GetLinkStatusControl,"CFGSpaceWire_GetLinkStatusControl"} | |||
|
130 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSEnableAutoStart,"CFGSpaceWire_LSEnableAutoStart"} | |||
|
131 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSEnableStart,"CFGSpaceWire_LSEnableStart"} | |||
|
132 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSEnableDisabled,"CFGSpaceWire_LSEnableDisabled"} | |||
|
133 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSEnableTristate,"CFGSpaceWire_LSEnableTristate"} | |||
|
134 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSPortType,"CFGSpaceWire_LSPortType"} | |||
|
135 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSSetOperatingSpeed,"CFGSpaceWire_LSSetOperatingSpeed"} | |||
|
136 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSConfigErrorStatus,"CFGSpaceWire_LSConfigErrorStatus"} | |||
|
137 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSExternalErrorStatus,"CFGSpaceWire_LSExternalErrorStatus"} | |||
|
138 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSErrorStatus,"CFGSpaceWire_LSErrorStatus"} | |||
|
139 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSLinkState,"CFGSpaceWire_LSLinkState"} | |||
|
140 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSIsLinkRunning,"CFGSpaceWire_LSIsLinkRunning"} | |||
|
141 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSIsAutoStart,"CFGSpaceWire_LSIsAutoStart"} | |||
|
142 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSIsStart,"CFGSpaceWire_LSIsStart"} | |||
|
143 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSIsDisabled,"CFGSpaceWire_LSIsDisabled"} | |||
|
144 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSIsTristate,"CFGSpaceWire_LSIsTristate"} | |||
|
145 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSOperatingSpeed,"CFGSpaceWire_LSOperatingSpeed"} | |||
|
146 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_LSOutputPortConnection,"CFGSpaceWire_LSOutputPortConnection"} | |||
|
147 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetLinkStatusControl,"CFGSpaceWire_SetLinkStatusControl"} | |||
|
148 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetAsInterface,"CFGSpaceWire_SetAsInterface"} | |||
|
149 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_ClearRoutingTableEntry,"CFGSpaceWire_ClearRoutingTableEntry"} | |||
|
150 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RTBuildRoutingTableEntry,"CFGSpaceWire_RTBuildRoutingTableEntry"} | |||
|
151 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetRoutingTableEntry,"CFGSpaceWire_SetRoutingTableEntry"} | |||
|
152 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_GetRoutingTableEntry,"CFGSpaceWire_GetRoutingTableEntry"} | |||
|
153 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RTIsEnabled,"CFGSpaceWire_RTIsEnabled"} | |||
|
154 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RTIsDelHead,"CFGSpaceWire_RTIsDelHead"} | |||
|
155 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RTIsPriority,"CFGSpaceWire_RTIsPriority"} | |||
|
156 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_RTGetOutputPorts,"CFGSpaceWire_RTGetOutputPorts"} | |||
|
157 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_GetTickEnableStatus,"CFGSpaceWire_GetTickEnableStatus"} | |||
|
158 | <<funcToresolve{(void (**)())&resolved_CFGSpaceWire_SetTickEnableStatus,"CFGSpaceWire_SetTickEnableStatus"}; | |||
|
159 | ||||
|
160 | ||||
|
161 | ||||
|
162 | FakeStarDundeeSpwUSB_Lib::FakeStarDundeeSpwUSB_Lib() | |||
|
163 | { | |||
|
164 | ||||
|
165 | } | |||
|
166 | ||||
|
167 | void FakeStarDundeeSpwUSB_Lib::resolve() | |||
|
168 | { | |||
|
169 | QLibrary cfgLib; | |||
|
170 | QLibrary usbLib; | |||
|
171 | usbLib.setFileName("/home/spacewire/usb/spw_usb_driver_v2.68/lib/x86_64/libSpaceWireUSBAPI.so"); | |||
|
172 | cfgLib.setFileName("/home/spacewire/usb/spw_usb_driver_v2.68/lib/x86_64/libConfigLibraryUSB.so"); | |||
|
173 | usbLib.load(); | |||
|
174 | cfgLib.load(); | |||
|
175 | if(usbLib.isLoaded()&&cfgLib.isLoaded()) | |||
|
176 | { | |||
|
177 | for(int i=0;i<funcTable.count();i++) | |||
|
178 | { | |||
|
179 | QString symbolName = funcTable[i].symbolName; | |||
|
180 | if(!symbolName.contains("USBSpaceWire_")) | |||
|
181 | { | |||
|
182 | *(funcTable[i].function) = usbLib.resolve(funcTable[i].symbolName); | |||
|
183 | if(*(funcTable[i].function)==NULL) | |||
|
184 | *(funcTable[i].function) = cfgLib.resolve(funcTable[i].symbolName); | |||
|
185 | } | |||
|
186 | else | |||
|
187 | { | |||
|
188 | *(funcTable[i].function) = cfgLib.resolve(funcTable[i].symbolName); | |||
|
189 | if(*(funcTable[i].function)==NULL) | |||
|
190 | *(funcTable[i].function) = usbLib.resolve(funcTable[i].symbolName); | |||
|
191 | } | |||
|
192 | } | |||
|
193 | } | |||
|
194 | } | |||
|
195 | ||||
|
196 | ||||
|
197 | ||||
|
198 | char USBSpaceWire_Open(star_device_handle *phDevice, int nDeviceNum) | |||
|
199 | { | |||
|
200 | if(resolved_USBSpaceWire_Open!=NULL) | |||
|
201 | return resolved_USBSpaceWire_Open(phDevice, nDeviceNum); | |||
|
202 | return 0; | |||
|
203 | } | |||
|
204 | ||||
|
205 | ||||
|
206 | void USBSpaceWire_Close(star_device_handle hDevice) | |||
|
207 | { | |||
|
208 | if(resolved_USBSpaceWire_Close!=NULL) | |||
|
209 | resolved_USBSpaceWire_Close(hDevice); | |||
|
210 | } | |||
|
211 | ||||
|
212 | ||||
|
213 | U32 USBSpaceWire_ListDevices() | |||
|
214 | { | |||
|
215 | if(resolved_USBSpaceWire_ListDevices!=NULL) | |||
|
216 | return resolved_USBSpaceWire_ListDevices(); | |||
|
217 | return 0; | |||
|
218 | } | |||
|
219 | ||||
|
220 | ||||
|
221 | char USBSpaceWire_GetSerialNumber(star_device_handle hDevice, U8 pSerialNumber[]) | |||
|
222 | { | |||
|
223 | if(resolved_USBSpaceWire_GetSerialNumber!=NULL) | |||
|
224 | return resolved_USBSpaceWire_GetSerialNumber(hDevice,pSerialNumber); | |||
|
225 | return 0; | |||
|
226 | } | |||
|
227 | ||||
|
228 | ||||
|
229 | void USBSpaceWire_EnableNetworkMode(star_device_handle hDevice, char enable) | |||
|
230 | { | |||
|
231 | if(resolved_USBSpaceWire_EnableNetworkMode!=NULL) | |||
|
232 | resolved_USBSpaceWire_EnableNetworkMode(hDevice,enable); | |||
|
233 | } | |||
|
234 | ||||
|
235 | ||||
|
236 | char USBSpaceWire_RegisterReceiveOnAllPorts(star_device_handle hDevice) | |||
|
237 | { | |||
|
238 | if(resolved_USBSpaceWire_RegisterReceiveOnAllPorts!=NULL) | |||
|
239 | return resolved_USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); | |||
|
240 | return 0; | |||
|
241 | } | |||
|
242 | ||||
|
243 | ||||
|
244 | char USBSpaceWire_UnregisterReceiveOnAllPorts(star_device_handle hDevice) | |||
|
245 | { | |||
|
246 | if(resolved_USBSpaceWire_UnregisterReceiveOnAllPorts!=NULL) | |||
|
247 | return resolved_USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); | |||
|
248 | return 0; | |||
|
249 | } | |||
|
250 | ||||
|
251 | ||||
|
252 | char USBSpaceWire_ClearEndpoints(star_device_handle hDevice) | |||
|
253 | { | |||
|
254 | if(resolved_USBSpaceWire_ClearEndpoints!=NULL) | |||
|
255 | return resolved_USBSpaceWire_ClearEndpoints(hDevice); | |||
|
256 | return 0; | |||
|
257 | } | |||
|
258 | ||||
|
259 | ||||
|
260 | void USBSpaceWire_SetTimeout(star_device_handle hDevice, double timeout) | |||
|
261 | { | |||
|
262 | if(resolved_USBSpaceWire_SetTimeout!=NULL) | |||
|
263 | resolved_USBSpaceWire_SetTimeout(hDevice,timeout); | |||
|
264 | } | |||
|
265 | ||||
|
266 | ||||
|
267 | char USBSpaceWire_TC_Reset(star_device_handle hDevice) | |||
|
268 | { | |||
|
269 | if(resolved_USBSpaceWire_TC_Reset!=NULL) | |||
|
270 | return resolved_USBSpaceWire_TC_Reset(hDevice); | |||
|
271 | return 0; | |||
|
272 | } | |||
|
273 | ||||
|
274 | ||||
|
275 | char USBSpaceWire_TC_EnableExternalTimecodeSelection(star_device_handle hDevice, char enable) | |||
|
276 | { | |||
|
277 | if(resolved_USBSpaceWire_TC_EnableExternalTimecodeSelection!=NULL) | |||
|
278 | return resolved_USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,enable); | |||
|
279 | return 0; | |||
|
280 | } | |||
|
281 | ||||
|
282 | ||||
|
283 | U32 USBSpaceWire_TC_GetClockFrequency(star_device_handle hDevice) | |||
|
284 | { | |||
|
285 | if(resolved_USBSpaceWire_TC_GetClockFrequency!=NULL) | |||
|
286 | return resolved_USBSpaceWire_TC_GetClockFrequency(hDevice); | |||
|
287 | return 0; | |||
|
288 | } | |||
|
289 | ||||
|
290 | ||||
|
291 | char USBSpaceWire_TC_SetAutoTickInFrequency(star_device_handle hDevice, U32 frequency) | |||
|
292 | { | |||
|
293 | if(resolved_USBSpaceWire_TC_SetAutoTickInFrequency!=NULL) | |||
|
294 | return resolved_USBSpaceWire_TC_SetAutoTickInFrequency(hDevice,frequency); | |||
|
295 | return 0; | |||
|
296 | } | |||
|
297 | ||||
|
298 | ||||
|
299 | char USBSpaceWire_TC_EnableAutoTickIn(star_device_handle hDevice, char enableAutoTickIns, char enableAllPorts) | |||
|
300 | { | |||
|
301 | if(resolved_USBSpaceWire_TC_EnableAutoTickIn!=NULL) | |||
|
302 | return resolved_USBSpaceWire_TC_EnableAutoTickIn(hDevice,enableAutoTickIns,enableAllPorts); | |||
|
303 | return 0; | |||
|
304 | } | |||
|
305 | ||||
|
306 | ||||
|
307 | char USBSpaceWire_TC_PerformTickIn(star_device_handle hDevice, U8 timein) | |||
|
308 | { | |||
|
309 | if(resolved_USBSpaceWire_TC_PerformTickIn!=NULL) | |||
|
310 | return resolved_USBSpaceWire_TC_PerformTickIn(hDevice,timein); | |||
|
311 | return 0; | |||
|
312 | } | |||
|
313 | ||||
|
314 | ||||
|
315 | U32 USBSpaceWire_GetDriverSendBufferSize(star_device_handle hDevice) | |||
|
316 | { | |||
|
317 | if(resolved_USBSpaceWire_GetDriverSendBufferSize!=NULL) | |||
|
318 | return resolved_USBSpaceWire_GetDriverSendBufferSize(hDevice); | |||
|
319 | return 0; | |||
|
320 | } | |||
|
321 | ||||
|
322 | ||||
|
323 | U32 USBSpaceWire_GetDriverReadBufferSize(star_device_handle hDevice) | |||
|
324 | { | |||
|
325 | if(resolved_USBSpaceWire_GetDriverReadBufferSize!=NULL) | |||
|
326 | return resolved_USBSpaceWire_GetDriverReadBufferSize(hDevice); | |||
|
327 | return 0; | |||
|
328 | } | |||
|
329 | ||||
|
330 | ||||
|
331 | char USBSpaceWire_IsReadThrottling(star_device_handle hDevice) | |||
|
332 | { | |||
|
333 | if(resolved_USBSpaceWire_IsReadThrottling!=NULL) | |||
|
334 | return resolved_USBSpaceWire_IsReadThrottling(hDevice); | |||
|
335 | return 0; | |||
|
336 | } | |||
|
337 | ||||
|
338 | ||||
|
339 | char USBSpaceWire_WaitOnReadPacketAvailable(star_device_handle hDevice, double timeout) | |||
|
340 | { | |||
|
341 | if(resolved_USBSpaceWire_WaitOnReadPacketAvailable!=NULL) | |||
|
342 | return resolved_USBSpaceWire_WaitOnReadPacketAvailable(hDevice,timeout); | |||
|
343 | return 0; | |||
|
344 | } | |||
|
345 | ||||
|
346 | ||||
|
347 | USB_SPACEWIRE_STATUS USBSpaceWire_SendPacket(star_device_handle hDevice, void *pBuffer, U32 nBufferSize, char bWait, USB_SPACEWIRE_ID *identifier) | |||
|
348 | { | |||
|
349 | if(resolved_USBSpaceWire_SendPacket!=NULL) | |||
|
350 | return resolved_USBSpaceWire_SendPacket(hDevice,pBuffer,nBufferSize,bWait,identifier); | |||
|
351 | return TRANSFER_ERROR_USB_ERROR; | |||
|
352 | } | |||
|
353 | ||||
|
354 | ||||
|
355 | char USBSpaceWire_FreeSend(star_device_handle hDevice, USB_SPACEWIRE_ID identifier) | |||
|
356 | { | |||
|
357 | if(resolved_USBSpaceWire_FreeSend!=NULL) | |||
|
358 | return resolved_USBSpaceWire_FreeSend(hDevice,identifier); | |||
|
359 | return 0; | |||
|
360 | } | |||
|
361 | ||||
|
362 | ||||
|
363 | USB_SPACEWIRE_STATUS USBSpaceWire_ReadPackets(star_device_handle hDevice, void *pBuffer, U32 nBufferSize, U32 nPacketNum, char bWait, PUSB_SPACEWIRE_PACKET_PROPERTIES properties, USB_SPACEWIRE_ID *identifier) | |||
|
364 | { | |||
|
365 | if(resolved_USBSpaceWire_ReadPackets!=NULL) | |||
|
366 | return resolved_USBSpaceWire_ReadPackets(hDevice,pBuffer,nBufferSize, nPacketNum,bWait, properties,identifier); | |||
|
367 | return TRANSFER_ERROR_USB_ERROR; | |||
|
368 | } | |||
|
369 | ||||
|
370 | ||||
|
371 | char USBSpaceWire_FreeRead(star_device_handle hDevice, USB_SPACEWIRE_ID identifier) | |||
|
372 | { | |||
|
373 | if(resolved_USBSpaceWire_FreeRead!=NULL) | |||
|
374 | return resolved_USBSpaceWire_FreeRead(hDevice,identifier); | |||
|
375 | return 0; | |||
|
376 | } | |||
|
377 | ||||
|
378 | ||||
|
379 | SPACEWIRE_TRAFFIC_TYPE USBSpaceWire_GetReadTrafficType(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties, U32 nPacketNum) | |||
|
380 | { | |||
|
381 | if(resolved_USBSpaceWire_GetReadTrafficType!=NULL) | |||
|
382 | return resolved_USBSpaceWire_GetReadTrafficType(pProperties,nPacketNum); | |||
|
383 | return SPACEWIRE_TRAFFIC_UNKNOWN; | |||
|
384 | } | |||
|
385 | ||||
|
386 | ||||
|
387 | USB_SPACEWIRE_EOP_TYPE USBSpaceWire_GetReadEOPStatus(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties, U32 nPacketNum) | |||
|
388 | { | |||
|
389 | if(resolved_USBSpaceWire_GetReadEOPStatus!=NULL) | |||
|
390 | return resolved_USBSpaceWire_GetReadEOPStatus(pProperties,nPacketNum); | |||
|
391 | return SPACEWIRE_USB_NO_EOP; | |||
|
392 | } | |||
|
393 | ||||
|
394 | ||||
|
395 | void CFGSpaceWire_EnableRMAP(char useRMAP) | |||
|
396 | { | |||
|
397 | if(resolved_CFGSpaceWire_EnableRMAP!=NULL) | |||
|
398 | resolved_CFGSpaceWire_EnableRMAP(useRMAP); | |||
|
399 | } | |||
|
400 | ||||
|
401 | ||||
|
402 | void CFGSpaceWire_SetRMAPDestinationKey(U8 destinationKey) | |||
|
403 | { | |||
|
404 | if(resolved_CFGSpaceWire_SetRMAPDestinationKey!=NULL) | |||
|
405 | resolved_CFGSpaceWire_SetRMAPDestinationKey(destinationKey); | |||
|
406 | } | |||
|
407 | ||||
|
408 | ||||
|
409 | void CFGSpaceWire_StackClear() | |||
|
410 | { | |||
|
411 | if(resolved_CFGSpaceWire_StackClear!=NULL) | |||
|
412 | resolved_CFGSpaceWire_StackClear(); | |||
|
413 | } | |||
|
414 | ||||
|
415 | ||||
|
416 | void CFGSpaceWire_AddrStackPush(U8 dwAddress) | |||
|
417 | { | |||
|
418 | if(resolved_CFGSpaceWire_AddrStackPush!=NULL) | |||
|
419 | resolved_CFGSpaceWire_AddrStackPush(dwAddress); | |||
|
420 | } | |||
|
421 | ||||
|
422 | ||||
|
423 | void CFGSpaceWire_RetAddrStackPush(U8 dwAddress) | |||
|
424 | { | |||
|
425 | if(resolved_CFGSpaceWire_RetAddrStackPush!=NULL) | |||
|
426 | resolved_CFGSpaceWire_RetAddrStackPush(dwAddress); | |||
|
427 | } | |||
|
428 | ||||
|
429 | ||||
|
430 | int CFGSpaceWire_SetBrickBaseTransmitRate(star_device_handle hDevice, U32 dwBaseClk, U32 dwBaseDvdr, U32 dwEnableClk) | |||
|
431 | { | |||
|
432 | if(resolved_CFGSpaceWire_SetBrickBaseTransmitRate!=NULL) | |||
|
433 | return resolved_CFGSpaceWire_SetBrickBaseTransmitRate(hDevice, dwBaseClk, dwBaseDvdr, dwEnableClk); | |||
|
434 | return 0; | |||
|
435 | } | |||
|
436 | ||||
|
437 | ||||
|
438 | int CFGSpaceWire_GetLinkStatusControl(star_device_handle hDevice, U32 dwLinkNum, U32 *dwStatusControl) | |||
|
439 | { | |||
|
440 | if(resolved_CFGSpaceWire_GetLinkStatusControl!=NULL) | |||
|
441 | return resolved_CFGSpaceWire_GetLinkStatusControl(hDevice, dwLinkNum, dwStatusControl); | |||
|
442 | return 0; | |||
|
443 | } | |||
|
444 | ||||
|
445 | ||||
|
446 | void CFGSpaceWire_LSEnableAutoStart(U32 *dwStatusControl, char bEnabled) | |||
|
447 | { | |||
|
448 | if(resolved_CFGSpaceWire_LSEnableAutoStart!=NULL) | |||
|
449 | resolved_CFGSpaceWire_LSEnableAutoStart(dwStatusControl, bEnabled); | |||
|
450 | } | |||
|
451 | ||||
|
452 | ||||
|
453 | void CFGSpaceWire_LSEnableStart(U32 *dwStatusControl, char bEnabled) | |||
|
454 | { | |||
|
455 | if(resolved_CFGSpaceWire_LSEnableStart!=NULL) | |||
|
456 | resolved_CFGSpaceWire_LSEnableStart(dwStatusControl, bEnabled); | |||
|
457 | } | |||
|
458 | ||||
|
459 | ||||
|
460 | void CFGSpaceWire_LSEnableDisabled(U32 *dwStatusControl, char bEnabled) | |||
|
461 | { | |||
|
462 | if(resolved_CFGSpaceWire_LSEnableDisabled!=NULL) | |||
|
463 | resolved_CFGSpaceWire_LSEnableDisabled(dwStatusControl, bEnabled); | |||
|
464 | } | |||
|
465 | ||||
|
466 | ||||
|
467 | void CFGSpaceWire_LSEnableTristate(U32 *dwStatusControl, char bEnabled) | |||
|
468 | { | |||
|
469 | if(resolved_CFGSpaceWire_LSEnableTristate!=NULL) | |||
|
470 | resolved_CFGSpaceWire_LSEnableTristate(dwStatusControl, bEnabled); | |||
|
471 | } | |||
|
472 | ||||
|
473 | ||||
|
474 | void CFGSpaceWire_LSPortType(U32 dwStatusControl, U32 *dwPortType) | |||
|
475 | { | |||
|
476 | if(resolved_CFGSpaceWire_LSPortType!=NULL) | |||
|
477 | resolved_CFGSpaceWire_LSPortType(dwStatusControl, dwPortType); | |||
|
478 | } | |||
|
479 | ||||
|
480 | ||||
|
481 | void CFGSpaceWire_LSSetOperatingSpeed(U32 *dwStatusControl, U32 dwOperatingSpeed) | |||
|
482 | { | |||
|
483 | if(resolved_CFGSpaceWire_LSSetOperatingSpeed!=NULL) | |||
|
484 | resolved_CFGSpaceWire_LSSetOperatingSpeed(dwStatusControl, dwOperatingSpeed); | |||
|
485 | } | |||
|
486 | ||||
|
487 | ||||
|
488 | void CFGSpaceWire_LSConfigErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus) | |||
|
489 | { | |||
|
490 | if(resolved_CFGSpaceWire_LSConfigErrorStatus!=NULL) | |||
|
491 | resolved_CFGSpaceWire_LSConfigErrorStatus(dwStatusControl, dwErrorStatus); | |||
|
492 | } | |||
|
493 | ||||
|
494 | ||||
|
495 | void CFGSpaceWire_LSExternalErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus) | |||
|
496 | { | |||
|
497 | if(resolved_CFGSpaceWire_LSExternalErrorStatus!=NULL) | |||
|
498 | resolved_CFGSpaceWire_LSExternalErrorStatus(dwStatusControl, dwErrorStatus); | |||
|
499 | } | |||
|
500 | ||||
|
501 | ||||
|
502 | void CFGSpaceWire_LSErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus) | |||
|
503 | { | |||
|
504 | if(resolved_CFGSpaceWire_LSErrorStatus!=NULL) | |||
|
505 | resolved_CFGSpaceWire_LSErrorStatus(dwStatusControl, dwErrorStatus); | |||
|
506 | } | |||
|
507 | ||||
|
508 | ||||
|
509 | void CFGSpaceWire_LSLinkState(U32 dwStatusControl, U32 *dwLinkStatus) | |||
|
510 | { | |||
|
511 | if(resolved_CFGSpaceWire_LSLinkState!=NULL) | |||
|
512 | resolved_CFGSpaceWire_LSLinkState(dwStatusControl, dwLinkStatus); | |||
|
513 | } | |||
|
514 | ||||
|
515 | ||||
|
516 | void CFGSpaceWire_LSIsLinkRunning(U32 dwStatusControl, char *isLinkRunning) | |||
|
517 | { | |||
|
518 | if(resolved_CFGSpaceWire_LSIsLinkRunning!=NULL) | |||
|
519 | resolved_CFGSpaceWire_LSIsLinkRunning(dwStatusControl, isLinkRunning); | |||
|
520 | } | |||
|
521 | ||||
|
522 | ||||
|
523 | void CFGSpaceWire_LSIsAutoStart(U32 dwStatusControl, char *isAutoStart) | |||
|
524 | { | |||
|
525 | if(resolved_CFGSpaceWire_LSIsAutoStart!=NULL) | |||
|
526 | resolved_CFGSpaceWire_LSIsAutoStart(dwStatusControl, isAutoStart); | |||
|
527 | } | |||
|
528 | ||||
|
529 | ||||
|
530 | void CFGSpaceWire_LSIsStart(U32 dwStatusControl, char *isStart) | |||
|
531 | { | |||
|
532 | if(resolved_CFGSpaceWire_LSIsStart!=NULL) | |||
|
533 | resolved_CFGSpaceWire_LSIsStart(dwStatusControl, isStart); | |||
|
534 | } | |||
|
535 | ||||
|
536 | ||||
|
537 | void CFGSpaceWire_LSIsDisabled(U32 dwStatusControl, char *isDisabled) | |||
|
538 | { | |||
|
539 | if(resolved_CFGSpaceWire_LSIsDisabled!=NULL) | |||
|
540 | resolved_CFGSpaceWire_LSIsDisabled(dwStatusControl, isDisabled); | |||
|
541 | } | |||
|
542 | ||||
|
543 | ||||
|
544 | void CFGSpaceWire_LSIsTristate(U32 dwStatusControl, char *isTristate) | |||
|
545 | { | |||
|
546 | if(resolved_CFGSpaceWire_LSIsTristate!=NULL) | |||
|
547 | resolved_CFGSpaceWire_LSIsTristate(dwStatusControl, isTristate); | |||
|
548 | } | |||
|
549 | ||||
|
550 | ||||
|
551 | void CFGSpaceWire_LSOperatingSpeed(U32 dwStatusControl, U32 *dwOperatingSpeed) | |||
|
552 | { | |||
|
553 | if(resolved_CFGSpaceWire_LSOperatingSpeed!=NULL) | |||
|
554 | resolved_CFGSpaceWire_LSOperatingSpeed(dwStatusControl, dwOperatingSpeed); | |||
|
555 | } | |||
|
556 | ||||
|
557 | ||||
|
558 | void CFGSpaceWire_LSOutputPortConnection(U32 dwStatusControl, U32 *dwOutputPortConnection) | |||
|
559 | { | |||
|
560 | if(resolved_CFGSpaceWire_LSOutputPortConnection!=NULL) | |||
|
561 | resolved_CFGSpaceWire_LSOutputPortConnection(dwStatusControl, dwOutputPortConnection); | |||
|
562 | } | |||
|
563 | ||||
|
564 | ||||
|
565 | int CFGSpaceWire_SetLinkStatusControl(star_device_handle hDevice, U32 dwLinkNum, U32 dwStatusControl) | |||
|
566 | { | |||
|
567 | if(resolved_CFGSpaceWire_SetLinkStatusControl!=NULL) | |||
|
568 | return resolved_CFGSpaceWire_SetLinkStatusControl(hDevice, dwLinkNum, dwStatusControl); | |||
|
569 | return 0; | |||
|
570 | } | |||
|
571 | ||||
|
572 | ||||
|
573 | int CFGSpaceWire_SetAsInterface(star_device_handle hDevice, char bEnabled, char bAddIdentifier) | |||
|
574 | { | |||
|
575 | if(resolved_CFGSpaceWire_SetAsInterface!=NULL) | |||
|
576 | return resolved_CFGSpaceWire_SetAsInterface(hDevice, bEnabled, bAddIdentifier); | |||
|
577 | return 0; | |||
|
578 | } | |||
|
579 | ||||
|
580 | ||||
|
581 | int CFGSpaceWire_ClearRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress) | |||
|
582 | { | |||
|
583 | if(resolved_CFGSpaceWire_ClearRoutingTableEntry!=NULL) | |||
|
584 | return resolved_CFGSpaceWire_ClearRoutingTableEntry(hDevice,nLogicalAddress); | |||
|
585 | return 0; | |||
|
586 | } | |||
|
587 | ||||
|
588 | ||||
|
589 | void CFGSpaceWire_RTBuildRoutingTableEntry(U32 *dwRoutingTableEntry, U32 dwOutputPorts, char bDelHead, char bPriority) | |||
|
590 | { | |||
|
591 | if(resolved_CFGSpaceWire_RTBuildRoutingTableEntry!=NULL) | |||
|
592 | resolved_CFGSpaceWire_RTBuildRoutingTableEntry(dwRoutingTableEntry, dwOutputPorts, bDelHead, bPriority); | |||
|
593 | } | |||
|
594 | ||||
|
595 | ||||
|
596 | int CFGSpaceWire_SetRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress, U32 dwRoutingTableEntry) | |||
|
597 | { | |||
|
598 | if(resolved_CFGSpaceWire_SetRoutingTableEntry!=NULL) | |||
|
599 | return resolved_CFGSpaceWire_SetRoutingTableEntry(hDevice,nLogicalAddress, dwRoutingTableEntry); | |||
|
600 | return 0; | |||
|
601 | } | |||
|
602 | ||||
|
603 | ||||
|
604 | int CFGSpaceWire_GetRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress, U32 *dwRoutingTableEntry) | |||
|
605 | { | |||
|
606 | if(resolved_CFGSpaceWire_GetRoutingTableEntry!=NULL) | |||
|
607 | return resolved_CFGSpaceWire_GetRoutingTableEntry(hDevice,nLogicalAddress, dwRoutingTableEntry); | |||
|
608 | return 0; | |||
|
609 | } | |||
|
610 | ||||
|
611 | ||||
|
612 | void CFGSpaceWire_RTIsEnabled(U32 dwRoutingTableEntry, char *bEnabled) | |||
|
613 | { | |||
|
614 | if(resolved_CFGSpaceWire_RTIsEnabled!=NULL) | |||
|
615 | resolved_CFGSpaceWire_RTIsEnabled( dwRoutingTableEntry, bEnabled); | |||
|
616 | } | |||
|
617 | ||||
|
618 | ||||
|
619 | void CFGSpaceWire_RTIsDelHead(U32 dwRoutingTableEntry, char *bDelHead) | |||
|
620 | { | |||
|
621 | if(resolved_CFGSpaceWire_RTIsDelHead!=NULL) | |||
|
622 | resolved_CFGSpaceWire_RTIsDelHead( dwRoutingTableEntry, bDelHead); | |||
|
623 | } | |||
|
624 | ||||
|
625 | ||||
|
626 | void CFGSpaceWire_RTIsPriority(U32 dwRoutingTableEntry, char *bPriority) | |||
|
627 | { | |||
|
628 | if(resolved_CFGSpaceWire_RTIsPriority!=NULL) | |||
|
629 | resolved_CFGSpaceWire_RTIsPriority( dwRoutingTableEntry, bPriority); | |||
|
630 | } | |||
|
631 | ||||
|
632 | ||||
|
633 | void CFGSpaceWire_RTGetOutputPorts(U32 dwRoutingTableEntry, U32 *dwOutputPorts) | |||
|
634 | { | |||
|
635 | if(resolved_CFGSpaceWire_RTGetOutputPorts!=NULL) | |||
|
636 | resolved_CFGSpaceWire_RTGetOutputPorts( dwRoutingTableEntry, dwOutputPorts); | |||
|
637 | } | |||
|
638 | ||||
|
639 | ||||
|
640 | int CFGSpaceWire_GetTickEnableStatus(star_device_handle hDevice, U32 *dwTickEnableStatus) | |||
|
641 | { | |||
|
642 | if(resolved_CFGSpaceWire_GetTickEnableStatus!=NULL) | |||
|
643 | return resolved_CFGSpaceWire_GetTickEnableStatus( hDevice, dwTickEnableStatus); | |||
|
644 | return 0; | |||
|
645 | } | |||
|
646 | ||||
|
647 | ||||
|
648 | int CFGSpaceWire_SetTickEnableStatus(star_device_handle hDevice, U32 dwTickEnableStatus) | |||
|
649 | { | |||
|
650 | if(resolved_CFGSpaceWire_SetTickEnableStatus!=NULL) | |||
|
651 | return resolved_CFGSpaceWire_SetTickEnableStatus( hDevice, dwTickEnableStatus); | |||
|
652 | return 0; | |||
|
653 | } |
@@ -0,0 +1,372 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
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 | |||
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
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 | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef FAKESTARDUNDEESPWUSB_LIB_H | |||
|
23 | #define FAKESTARDUNDEESPWUSB_LIB_H | |||
|
24 | ||||
|
25 | typedef void *star_device_handle; | |||
|
26 | typedef void * USB_SPACEWIRE_ID; | |||
|
27 | typedef unsigned char U8; | |||
|
28 | typedef unsigned int U32; | |||
|
29 | //#include <spw_usb_api.h> | |||
|
30 | //#include <spw_config_library.h> | |||
|
31 | #include <QLibrary> | |||
|
32 | ||||
|
33 | ||||
|
34 | /* Possible bit values */ | |||
|
35 | #define BIT0 (0x00000001) | |||
|
36 | #define BIT1 (0x00000002) | |||
|
37 | #define BIT2 (0x00000004) | |||
|
38 | #define BIT3 (0x00000008) | |||
|
39 | #define BIT4 (0x00000010) | |||
|
40 | #define BIT5 (0x00000020) | |||
|
41 | #define BIT6 (0x00000040) | |||
|
42 | #define BIT7 (0x00000080) | |||
|
43 | #define BIT8 (0x00000100) | |||
|
44 | #define BIT9 (0x00000200) | |||
|
45 | #define BIT10 (0x00000400) | |||
|
46 | #define BIT11 (0x00000800) | |||
|
47 | #define BIT12 (0x00001000) | |||
|
48 | #define BIT13 (0x00002000) | |||
|
49 | #define BIT14 (0x00004000) | |||
|
50 | #define BIT15 (0x00008000) | |||
|
51 | #define BIT16 (0x00010000) | |||
|
52 | #define BIT17 (0x00020000) | |||
|
53 | #define BIT18 (0x00040000) | |||
|
54 | #define BIT19 (0x00080000) | |||
|
55 | #define BIT20 (0x00100000) | |||
|
56 | #define BIT21 (0x00200000) | |||
|
57 | #define BIT22 (0x00400000) | |||
|
58 | #define BIT23 (0x00800000) | |||
|
59 | #define BIT24 (0x01000000) | |||
|
60 | #define BIT25 (0x02000000) | |||
|
61 | #define BIT26 (0x04000000) | |||
|
62 | #define BIT27 (0x08000000) | |||
|
63 | #define BIT28 (0x10000000) | |||
|
64 | #define BIT29 (0x20000000) | |||
|
65 | #define BIT30 (0x40000000) | |||
|
66 | #define BIT31 (0x80000000) | |||
|
67 | ||||
|
68 | /* SpaceWire Port errors */ | |||
|
69 | #define CFG_SPACEWIRE_NO_ERRORS (0) | |||
|
70 | #define CFG_SPACEWIRE_ERROR_ACTIVE (BIT0) | |||
|
71 | #define CFG_SPACEWIRE_PACKET_ADDRESS_ERROR (BIT1) | |||
|
72 | #define CFG_SPACEWIRE_PORT_TIMEOUT_ERROR (BIT2) | |||
|
73 | #define CFG_SPACEWIRE_DISCONNECT_ERROR (BIT3) | |||
|
74 | #define CFG_SPACEWIRE_PARITY_ERROR (BIT4) | |||
|
75 | #define CFG_SPACEWIRE_ESCAPE_ERROR (BIT5) | |||
|
76 | #define CFG_SPACEWIRE_CREDIT_ERROR (BIT6) | |||
|
77 | #define CFG_SPACEWIRE_CHARACTER_SEQUENCE_ERROR (BIT7) | |||
|
78 | #define CFG_SPACEWIRE_ERROR_BITS (BIT0 | BIT1 | BIT2 | BIT3 | \ | |||
|
79 | BIT4 | BIT5 | BIT6 | BIT7) | |||
|
80 | ||||
|
81 | /* Config Port errors */ | |||
|
82 | #define CFG_CONFIG_NO_ERRORS (0) | |||
|
83 | #define CFG_CONFIG_ERROR_ACTIVE (BIT0) | |||
|
84 | ||||
|
85 | /* Config Port errors (non-RMAP) */ | |||
|
86 | #define CFG_CONFIG_PACKET_ADDRESS_ERROR (BIT1) | |||
|
87 | #define CFG_CONFIG_PORT_TIMEOUT_ERROR (BIT2) | |||
|
88 | #define CFG_CONFIG_CHECKSUM_ERROR (BIT3) | |||
|
89 | #define CFG_CONFIG_TOO_SHORT_ERROR (BIT4) | |||
|
90 | #define CFG_CONFIG_TOO_LONG_ERROR (BIT5) | |||
|
91 | #define CFG_CONFIG_PACKET_EEP_ERROR (BIT6) | |||
|
92 | #define CFG_CONFIG_PROTOCOL_BYTE_ERROR (BIT7) | |||
|
93 | #define CFG_CONFIG_INVALID_REGISTER_ERROR (BIT8) | |||
|
94 | #define CFG_CONFIG_ERROR_BITS (BIT0 | BIT1 | BIT2 | BIT3 | \ | |||
|
95 | BIT4 | BIT5 | BIT6 | BIT7 | \ | |||
|
96 | BIT8) | |||
|
97 | ||||
|
98 | /* Config Port errors (RMAP) */ | |||
|
99 | #define CFG_CONFIG_RMAP_PORT_TIMEOUT_ERROR (BIT1) | |||
|
100 | #define CFG_CONFIG_RMAP_INVALID_HEADER_CRC (BIT2) | |||
|
101 | #define CFG_CONFIG_RMAP_INVALID_DATA_CRC (BIT3) | |||
|
102 | #define CFG_CONFIG_RMAP_INVALID_DESTINATION_KEY (BIT4) | |||
|
103 | #define CFG_CONFIG_RMAP_COMMAND_NOT_IMPLEMENTED (BIT5) | |||
|
104 | #define CFG_CONFIG_RMAP_INVALID_DATA_LENGTH (BIT6) | |||
|
105 | #define CFG_CONFIG_RMAP_INVALID_RMW_DATA_LENGTH (BIT7) | |||
|
106 | #define CFG_CONFIG_RMAP_INVALID_DESTINATION_ADDRESS (BIT8) | |||
|
107 | #define CFG_CONFIG_RMAP_EARLY_EOP (BIT9) | |||
|
108 | #define CFG_CONFIG_RMAP_LATE_EOP (BIT10) | |||
|
109 | #define CFG_CONFIG_RMAP_EARLY_EEP (BIT11) | |||
|
110 | #define CFG_CONFIG_RMAP_LATE_EEP (BIT12) | |||
|
111 | #define CFG_CONFIG_RMAP_VERIFY_BUFFER_OVERRUN_ERROR (BIT13) | |||
|
112 | #define CFG_CONFIG_RMAP_INVALID_REGISTER_ADDRESS (BIT14) | |||
|
113 | #define CFG_CONFIG_RMAP_UNSUPPORTED_PROTOCOL_ERROR (BIT15) | |||
|
114 | #define CFG_CONFIG_RMAP_SOURCE_LOGICAL_ADDRESS_ERROR (BIT16) | |||
|
115 | #define CFG_CONFIG_RMAP_SOURCE_PATH_ADDRESS_ERROR (BIT17) | |||
|
116 | #define CFG_CONFIG_RMAP_CARGO_TOO_LARGE (BIT18) | |||
|
117 | #define CFG_CONFIG_RMAP_UNUSED_COMMAND_OR_PACKET_TYPE (BIT19) | |||
|
118 | #define CFG_CONFIG_RMAP_ERROR_BITS (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | \ | |||
|
119 | BIT5 | BIT6 | BIT7 | BIT8 | BIT9 | \ | |||
|
120 | BIT10 | BIT11 | BIT12 | BIT13 | \ | |||
|
121 | BIT14 | BIT15 | BIT16 | BIT17 | \ | |||
|
122 | BIT18 | BIT19) | |||
|
123 | ||||
|
124 | /* External Port errors */ | |||
|
125 | #define CFG_EXTERNAL_NO_ERRORS (0) | |||
|
126 | #define CFG_EXTERNAL_ERROR_ACTIVE (BIT0) | |||
|
127 | #define CFG_EXTERNAL_PACKET_ADDRESS_ERROR (BIT1) | |||
|
128 | #define CFG_EXTERNAL_PORT_TIMEOUT_ERROR (BIT2) | |||
|
129 | #define CFG_EXTERNAL_INPUT_BUFFER_EMPTY_ERROR (BIT3) | |||
|
130 | #define CFG_EXTERNAL_INPUT_BUFFER_FULL_ERROR (BIT4) | |||
|
131 | #define CFG_EXTERNAL_OUTPUT_BUFFER_EMPTY_ERROR (BIT5) | |||
|
132 | #define CFG_EXTERNAL_OUTPUT_BUFFER_FULL_ERROR (BIT6) | |||
|
133 | #define CFG_EXTERNAL_ERROR_BITS (BIT0 | BIT1 | BIT2 | BIT3 | \ | |||
|
134 | BIT4 | BIT5 | BIT6) | |||
|
135 | ||||
|
136 | /* SpaceWire Port interface state */ | |||
|
137 | #define CFG_SPACEWIRE_ERROR_RESET (0) | |||
|
138 | #define CFG_SPACEWIRE_ERROR_WAIT (BIT0) | |||
|
139 | #define CFG_SPACEWIRE_READY (BIT1) | |||
|
140 | #define CFG_SPACEWIRE_STARTED (BIT1 | BIT0) | |||
|
141 | #define CFG_SPACEWIRE_CONNECTING (BIT2) | |||
|
142 | #define CFG_SPACEWIRE_RUN (BIT2 | BIT0) | |||
|
143 | ||||
|
144 | /* Port type */ | |||
|
145 | #define CFG_CONFIGURATION_PORT (0) | |||
|
146 | #define CFG_SPACEWIRE_SERIAL_PORT (BIT0) | |||
|
147 | #define CFG_SPACEWIRE_EXTERNAL_PORT (BIT1) | |||
|
148 | ||||
|
149 | /* SpaceWire Port control bits */ | |||
|
150 | #define CFG_SPACEWIRE_INTERFACE_STATE_START (8) | |||
|
151 | #define CFG_SPACEWIRE_INTERFACE_STATE (BIT8 | BIT9 | BIT10) | |||
|
152 | #define CFG_SPACEWIRE_RUNNING (BIT11) | |||
|
153 | #define CFG_SPACEWIRE_AUTOSTART (BIT12) | |||
|
154 | #define CFG_SPACEWIRE_START (BIT13) | |||
|
155 | #define CFG_SPACEWIRE_DISABLE (BIT14) | |||
|
156 | #define CFG_SPACEWIRE_TRISTATE (BIT15) | |||
|
157 | #define CFG_SPACEWIRE_RATE (BIT16 | BIT17 | BIT18 | \ | |||
|
158 | BIT19 | BIT20 | BIT21 | BIT22) | |||
|
159 | #define CFG_SPACEWIRE_RATE_START (16) | |||
|
160 | ||||
|
161 | /* Bits in the GAR Table */ | |||
|
162 | #define CFG_GAR_OUTPUT_PORTS_START (1) | |||
|
163 | #define CFG_GAR_OUTPUT_PORTS (BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | \ | |||
|
164 | BIT6 | BIT7 | BIT8 | BIT9 | BIT10 | BIT11 | BIT12 | BIT13 | BIT14 | \ | |||
|
165 | BIT15 | BIT16 | BIT17 | BIT18 | BIT19 | BIT20 | BIT21 | BIT22 | \ | |||
|
166 | BIT23 | BIT24 | BIT25 | BIT26 | BIT27 | BIT28) | |||
|
167 | #define CFG_GAR_DEL_HEAD (BIT29) | |||
|
168 | #define CFG_GAR_PRIORITY (BIT30) | |||
|
169 | #define CFG_GAR_INVALID_ADDR (BIT31) | |||
|
170 | ||||
|
171 | /* Bits in the router control register */ | |||
|
172 | #define CFG_RC_TIMEOUT_ENABLE_START (0) | |||
|
173 | #define CFG_RC_TIMEOUT_ENABLE (BIT0) | |||
|
174 | #define CFG_RC_TIMEOUT_VALUE_START (1) | |||
|
175 | #define CFG_RC_TIMEOUT_VALUE (BIT1 | BIT2 | BIT3) | |||
|
176 | #define CFG_RC_DISABLE_ON_SILENCE (BIT4) | |||
|
177 | #define CFG_RC_DISABLE_ON_SILENCE_START (4) | |||
|
178 | #define CFG_RC_START_ON_REQUEST (BIT5) | |||
|
179 | #define CFG_RC_START_ON_REQUEST_START (5) | |||
|
180 | #define CFG_RC_SELF_ADDRESSING (BIT6) | |||
|
181 | #define CFG_RC_SELF_ADDRESSING_START (6) | |||
|
182 | #define CFG_RC_INTERFACE (BIT7) | |||
|
183 | #define CFG_RC_INTERFACE_START (7) | |||
|
184 | #define CFG_RC_INTERFACE_IDENT (BIT8) | |||
|
185 | #define CFG_RC_INTERFACE_IDENT_START (8) | |||
|
186 | ||||
|
187 | /* The bits shared by all ports */ | |||
|
188 | #define CFG_PORT_CONNECTION (BIT24 | BIT25 | BIT26 | BIT27 | BIT28) | |||
|
189 | #define CFG_PORT_CONNECTION_START (24) | |||
|
190 | #define CFG_PORT_TYPE (BIT29 | BIT30 | BIT31) | |||
|
191 | #define CFG_PORT_TYPE_START (29) | |||
|
192 | ||||
|
193 | /* Network discovery register values */ | |||
|
194 | #define CFG_NETD_TYPE (BIT0 | BIT1 | BIT2 | BIT3) | |||
|
195 | #define CFG_NETD_TYPE_START (0) | |||
|
196 | #define CFG_NETD_RETURN_PORT (BIT4 | BIT5 | BIT6 | BIT7) | |||
|
197 | #define CFG_NETD_RETURN_PORT_START (4) | |||
|
198 | #define CFG_NETD_RUNNING_PORTS (BIT8 | BIT9 | BIT10 | BIT11 | BIT12 | \ | |||
|
199 | BIT13 | BIT14 | BIT15 | BIT16 | BIT17 | BIT18 | BIT19 | BIT20 | \ | |||
|
200 | BIT21 | BIT22 | BIT23 | BIT24 | BIT25 | BIT26 | BIT27 | BIT28 | \ | |||
|
201 | BIT29 | BIT30 | BIT31) | |||
|
202 | #define CFG_NETD_RUNNING_PORTS_START (8) | |||
|
203 | ||||
|
204 | /* Values in the ID register */ | |||
|
205 | #define CFG_ID_VERSION (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | \ | |||
|
206 | BIT5 | BIT6 | BIT7) | |||
|
207 | #define CFG_ID_VERSION_START (0) | |||
|
208 | #define CFG_ID_CHIP (BIT8 | BIT9 | BIT10 | BIT11 | BIT12 | \ | |||
|
209 | BIT13 | BIT14 | BIT15) | |||
|
210 | #define CFG_ID_CHIP_START (8) | |||
|
211 | #define CFG_ID_MANUFACTURER (BIT16 | BIT17 | BIT18 | BIT19 | \ | |||
|
212 | BIT20 | BIT21 | BIT22 | BIT23) | |||
|
213 | #define CFG_ID_MANUFACTURER_START (16) | |||
|
214 | ||||
|
215 | /* Values in the Time-Code register */ | |||
|
216 | #define CFG_TC_VALUE (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | \ | |||
|
217 | BIT5) | |||
|
218 | #define CFG_TC_VALUE_START (0) | |||
|
219 | #define CFG_TC_FLAGS (BIT6 | BIT7) | |||
|
220 | #define CFG_TC_FLAGS_START (6) | |||
|
221 | ||||
|
222 | /* Values for the Router Base Clock Select */ | |||
|
223 | #define CFG_RTR_CLK_100_MBITS (0) | |||
|
224 | #define CFG_RTR_CLK_200_MBITS (BIT0) | |||
|
225 | ||||
|
226 | /* Values for the Brick Base Clock */ | |||
|
227 | #define CFG_BRK_CLK_100_MHZ (0) | |||
|
228 | #define CFG_BRK_CLK_120_MHZ (BIT0) | |||
|
229 | #define CFG_BRK_CLK_140_MHZ (BIT1) | |||
|
230 | #define CFG_BRK_CLK_160_MHZ (BIT0 | BIT1) | |||
|
231 | #define CFG_BRK_CLK_180_MHZ (BIT2) | |||
|
232 | #define CFG_BRK_CLK_200_MHZ (BIT2 | BIT0) | |||
|
233 | ||||
|
234 | /* Values for the Brick Base Divider */ | |||
|
235 | #define CFG_BRK_DVDR_1 (0) | |||
|
236 | #define CFG_BRK_DVDR_2 (BIT0) | |||
|
237 | #define CFG_BRK_DVDR_4 (BIT1) | |||
|
238 | ||||
|
239 | typedef enum | |||
|
240 | { | |||
|
241 | TRANSFER_NOT_STARTED = 0, | |||
|
242 | TRANSFER_STARTED = 1, | |||
|
243 | TRANSFER_SUCCESS = 2, | |||
|
244 | TRANSFER_ERROR_DISCONNECT = 3, | |||
|
245 | TRANSFER_ERROR_PARITY = 4, | |||
|
246 | TRANSFER_ERROR_UNKNOWN = 5, | |||
|
247 | TRANSFER_ERROR_TIMEOUT = 6, | |||
|
248 | TRANSFER_ERROR_LINK_NOT_STARTED = 7, | |||
|
249 | TRANSFER_ERROR_USER_BUFFER_LOCK_FAILED = 8, | |||
|
250 | TRANSFER_ERROR_LINK_ALREADY_IN_USE = 9, | |||
|
251 | TRANSFER_ERROR_RECEIVE_BUFFER_FULL = 0xa, | |||
|
252 | TRANSFER_ERROR_OUT_OF_MEMORY = 0xb, | |||
|
253 | TRANSFER_ERROR_NOT_FOUND = 0xc, | |||
|
254 | TRANSFER_ERROR_USB_ERROR = 0xd, | |||
|
255 | TRANSFER_ERROR_NOT_REGISTERED_TO_RECEIVE = 0xe | |||
|
256 | } USB_SPACEWIRE_STATUS, *PUSB_SPACEWIRE_STATUS; | |||
|
257 | ||||
|
258 | #define SPACEWIRE_USB_EOP_CHAR ((U8)0x80) | |||
|
259 | #define SPACEWIRE_USB_EEP_CHAR ((U8)0x40) | |||
|
260 | ||||
|
261 | typedef enum | |||
|
262 | { | |||
|
263 | SPACEWIRE_USB_NO_EOP = 0, | |||
|
264 | SPACEWIRE_USB_EOP = SPACEWIRE_USB_EOP_CHAR, | |||
|
265 | SPACEWIRE_USB_EEP = SPACEWIRE_USB_EEP_CHAR | |||
|
266 | } USB_SPACEWIRE_EOP_TYPE, *PUSB_SPACEWIRE_EOP_TYPE; | |||
|
267 | ||||
|
268 | typedef enum | |||
|
269 | { | |||
|
270 | SPACEWIRE_TRAFFIC_UNKNOWN = -1, | |||
|
271 | SPACEWIRE_TRAFFIC_PACKET = 0, | |||
|
272 | SPACEWIRE_TRAFFIC_TIMECODE = 1, | |||
|
273 | SPACEWIRE_TRAFFIC_CONTROL = 2 | |||
|
274 | } SPACEWIRE_TRAFFIC_TYPE, *PSPACEWIRE_TRAFFIC_TYPE; | |||
|
275 | ||||
|
276 | typedef struct | |||
|
277 | { | |||
|
278 | unsigned long len; | |||
|
279 | USB_SPACEWIRE_EOP_TYPE eop; | |||
|
280 | SPACEWIRE_TRAFFIC_TYPE type; | |||
|
281 | } USB_SPACEWIRE_PACKET_PROPERTIES, *PUSB_SPACEWIRE_PACKET_PROPERTIES; | |||
|
282 | ||||
|
283 | ||||
|
284 | ||||
|
285 | typedef enum | |||
|
286 | { | |||
|
287 | CFG_TRANSFER_SUCCESS = 0x00, | |||
|
288 | CFG_TRANSMIT_PACKET_FAILURE = 0x01, | |||
|
289 | CFG_REPLY_PACKET_FAILURE = 0x02, | |||
|
290 | CFG_REPLY_PACKET_TOO_BIG = 0x03, | |||
|
291 | CFG_REPLY_PACKET_TOO_SMALL = 0x04, | |||
|
292 | CFG_REPLY_PACKET_NAK = 0x05, | |||
|
293 | CFG_REPLY_PACKET_CHECKSUM_ERROR = 0x06 | |||
|
294 | } CFG_SPACEWIRE_STATUS; | |||
|
295 | ||||
|
296 | ||||
|
297 | ||||
|
298 | char USBSpaceWire_Open(star_device_handle *phDevice, int nDeviceNum); | |||
|
299 | void USBSpaceWire_Close(star_device_handle hDevice); | |||
|
300 | U32 USBSpaceWire_ListDevices(); | |||
|
301 | char USBSpaceWire_GetSerialNumber(star_device_handle hDevice, U8 pSerialNumber[11]); | |||
|
302 | void USBSpaceWire_EnableNetworkMode(star_device_handle hDevice, char enable); | |||
|
303 | char USBSpaceWire_RegisterReceiveOnAllPorts(star_device_handle hDevice); | |||
|
304 | char USBSpaceWire_UnregisterReceiveOnAllPorts(star_device_handle hDevice); | |||
|
305 | char USBSpaceWire_ClearEndpoints(star_device_handle hDevice); | |||
|
306 | void USBSpaceWire_SetTimeout(star_device_handle hDevice, double timeout); | |||
|
307 | char USBSpaceWire_TC_Reset(star_device_handle hDevice); | |||
|
308 | char USBSpaceWire_TC_EnableExternalTimecodeSelection(star_device_handle hDevice,char enable); | |||
|
309 | U32 USBSpaceWire_TC_GetClockFrequency(star_device_handle hDevice); | |||
|
310 | char USBSpaceWire_TC_SetAutoTickInFrequency(star_device_handle hDevice, U32 frequency); | |||
|
311 | char USBSpaceWire_TC_EnableAutoTickIn(star_device_handle hDevice, char enableAutoTickIns, char enableAllPorts); | |||
|
312 | char USBSpaceWire_TC_PerformTickIn(star_device_handle hDevice, U8 timein); | |||
|
313 | U32 USBSpaceWire_GetDriverSendBufferSize(star_device_handle hDevice); | |||
|
314 | U32 USBSpaceWire_GetDriverReadBufferSize(star_device_handle hDevice); | |||
|
315 | char USBSpaceWire_IsReadThrottling(star_device_handle hDevice); | |||
|
316 | ||||
|
317 | char USBSpaceWire_WaitOnReadPacketAvailable(star_device_handle hDevice, double timeout); | |||
|
318 | USB_SPACEWIRE_STATUS USBSpaceWire_SendPacket(star_device_handle hDevice, void *pBuffer, U32 nBufferSize, char bWait,USB_SPACEWIRE_ID *identifier); | |||
|
319 | char USBSpaceWire_FreeSend(star_device_handle hDevice, USB_SPACEWIRE_ID identifier); | |||
|
320 | USB_SPACEWIRE_STATUS USBSpaceWire_ReadPackets(star_device_handle hDevice, void *pBuffer, U32 nBufferSize,U32 nPacketNum, char bWait, PUSB_SPACEWIRE_PACKET_PROPERTIES properties,USB_SPACEWIRE_ID *identifier); | |||
|
321 | char USBSpaceWire_FreeRead(star_device_handle hDevice, USB_SPACEWIRE_ID identifier); | |||
|
322 | SPACEWIRE_TRAFFIC_TYPE USBSpaceWire_GetReadTrafficType(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties, U32 nPacketNum); | |||
|
323 | USB_SPACEWIRE_EOP_TYPE USBSpaceWire_GetReadEOPStatus(PUSB_SPACEWIRE_PACKET_PROPERTIES pProperties,U32 nPacketNum); | |||
|
324 | ||||
|
325 | void CFGSpaceWire_EnableRMAP(char useRMAP); | |||
|
326 | void CFGSpaceWire_SetRMAPDestinationKey(U8 destinationKey); | |||
|
327 | void CFGSpaceWire_StackClear(void); | |||
|
328 | void CFGSpaceWire_AddrStackPush(U8 dwAddress); | |||
|
329 | void CFGSpaceWire_RetAddrStackPush(U8 dwAddress); | |||
|
330 | int CFGSpaceWire_SetBrickBaseTransmitRate(star_device_handle hDevice, U32 dwBaseClk, U32 dwBaseDvdr, U32 dwEnableClk); | |||
|
331 | int CFGSpaceWire_GetLinkStatusControl(star_device_handle hDevice, U32 dwLinkNum, U32 *dwStatusControl); | |||
|
332 | void CFGSpaceWire_LSEnableAutoStart(U32 *dwStatusControl, char bEnabled); | |||
|
333 | void CFGSpaceWire_LSEnableStart(U32 *dwStatusControl, char bEnabled); | |||
|
334 | void CFGSpaceWire_LSEnableDisabled(U32 *dwStatusControl, char bEnabled); | |||
|
335 | void CFGSpaceWire_LSEnableTristate(U32 *dwStatusControl, char bEnabled); | |||
|
336 | void CFGSpaceWire_LSPortType(U32 dwStatusControl, U32 *dwPortType); | |||
|
337 | void CFGSpaceWire_LSSetOperatingSpeed(U32 *dwStatusControl, U32 dwOperatingSpeed); | |||
|
338 | void CFGSpaceWire_LSConfigErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus); | |||
|
339 | void CFGSpaceWire_LSExternalErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus); | |||
|
340 | void CFGSpaceWire_LSErrorStatus(U32 dwStatusControl, U32 *dwErrorStatus); | |||
|
341 | void CFGSpaceWire_LSLinkState(U32 dwStatusControl, U32 *dwLinkStatus); | |||
|
342 | void CFGSpaceWire_LSIsLinkRunning(U32 dwStatusControl, char *isLinkRunning); | |||
|
343 | void CFGSpaceWire_LSIsAutoStart(U32 dwStatusControl, char *isAutoStart); | |||
|
344 | void CFGSpaceWire_LSIsStart(U32 dwStatusControl, char *isStart); | |||
|
345 | void CFGSpaceWire_LSIsDisabled(U32 dwStatusControl, char *isDisabled); | |||
|
346 | void CFGSpaceWire_LSIsTristate(U32 dwStatusControl, char *isTristate); | |||
|
347 | void CFGSpaceWire_LSOperatingSpeed(U32 dwStatusControl, U32 *dwOperatingSpeed); | |||
|
348 | void CFGSpaceWire_LSOutputPortConnection(U32 dwStatusControl, U32 *dwOutputPortConnection); | |||
|
349 | int CFGSpaceWire_SetLinkStatusControl(star_device_handle hDevice, U32 dwLinkNum, U32 dwStatusControl); | |||
|
350 | int CFGSpaceWire_SetAsInterface(star_device_handle hDevice, char bEnabled, char bAddIdentifier); | |||
|
351 | int CFGSpaceWire_ClearRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress); | |||
|
352 | void CFGSpaceWire_RTBuildRoutingTableEntry(U32 *dwRoutingTableEntry,U32 dwOutputPorts, char bDelHead, char bPriority); | |||
|
353 | int CFGSpaceWire_SetRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress, U32 dwRoutingTableEntry); | |||
|
354 | int CFGSpaceWire_GetRoutingTableEntry(star_device_handle hDevice, U32 nLogicalAddress, U32 *dwRoutingTableEntry); | |||
|
355 | void CFGSpaceWire_RTIsEnabled(U32 dwRoutingTableEntry, char *bEnabled); | |||
|
356 | void CFGSpaceWire_RTIsDelHead(U32 dwRoutingTableEntry, char *bDelHead); | |||
|
357 | void CFGSpaceWire_RTIsPriority(U32 dwRoutingTableEntry, char *bPriority); | |||
|
358 | void CFGSpaceWire_RTGetOutputPorts(U32 dwRoutingTableEntry, U32 *dwOutputPorts); | |||
|
359 | int CFGSpaceWire_GetTickEnableStatus(star_device_handle hDevice, U32 *dwTickEnableStatus); | |||
|
360 | int CFGSpaceWire_SetTickEnableStatus(star_device_handle hDevice, U32 dwTickEnableStatus); | |||
|
361 | ||||
|
362 | ||||
|
363 | ||||
|
364 | ||||
|
365 | class FakeStarDundeeSpwUSB_Lib | |||
|
366 | { | |||
|
367 | public: | |||
|
368 | FakeStarDundeeSpwUSB_Lib(); | |||
|
369 | static void resolve(); | |||
|
370 | }; | |||
|
371 | ||||
|
372 | #endif // FAKESTARDUNDEESPWUSB_LIB_H |
@@ -1,330 +1,341 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "dsu3plugin.h" |
|
22 | #include "dsu3plugin.h" | |
23 | #include <QFileDialog> |
|
23 | #include <QFileDialog> | |
24 | #include <QDir> |
|
24 | #include <QDir> | |
25 | #include <socexplorerengine.h> |
|
25 | #include <socexplorerengine.h> | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | struct acceptedMemctrlr_str |
|
28 | struct acceptedMemctrlr_str | |
29 | { |
|
29 | { | |
30 | int vid; |
|
30 | int vid; | |
31 | int pid; |
|
31 | int pid; | |
32 | const char* name; |
|
32 | const char* name; | |
33 | }; |
|
33 | }; | |
34 |
|
34 | |||
35 | const struct acceptedMemctrlr_str acceptedMemctrlr[]= |
|
35 | const struct acceptedMemctrlr_str acceptedMemctrlr[]= | |
36 | { |
|
36 | { | |
37 | {0x04,0x0f,"MCTRL"}, |
|
37 | {0x04,0x0f,"MCTRL"}, | |
38 | {0x01,0x51,"FTSRCTRL"}, |
|
38 | {0x01,0x51,"FTSRCTRL"}, | |
39 | {0x20,0x01,"SRCTRLE_0WS" }, |
|
39 | {0x20,0x01,"SRCTRLE_0WS" }, | |
40 | {0x20,0x02,"SRCTRLE_1WS" } |
|
40 | {0x20,0x02,"SRCTRLE_1WS" } | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
43 | #define acceptedMemctrlrCnt 4 |
|
43 | #define acceptedMemctrlrCnt 4 | |
44 |
|
44 | |||
45 | dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) |
|
45 | dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) | |
46 | { |
|
46 | { | |
47 | this->UI = new dsu3pluginui(); |
|
47 | this->UI = new dsu3pluginui(); | |
48 | this->setWidget((QWidget*)this->UI); |
|
48 | this->setWidget((QWidget*)this->UI); | |
49 | this->elfFile = new ElfFile(); |
|
49 | this->elfFile = new ElfFile(); | |
50 | connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); |
|
50 | connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); | |
51 | connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); |
|
51 | connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); | |
52 | connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); |
|
52 | connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); | |
53 | connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*))); |
|
53 | connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*))); | |
54 | this->running = false; |
|
54 | this->running = false; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | dsu3plugin::~dsu3plugin() |
|
58 | dsu3plugin::~dsu3plugin() | |
59 | { |
|
59 | { | |
60 |
|
60 | |||
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | void dsu3plugin::openFile() |
|
64 | void dsu3plugin::openFile() | |
65 | { |
|
65 | { | |
66 | QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); |
|
66 | QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); | |
67 | if(filename!="") |
|
67 | if(filename!="") | |
68 | { |
|
68 | { | |
69 | this->openFile(filename); |
|
69 | this->openFile(filename); | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | void dsu3plugin::openFile(QString fileName) |
|
73 | void dsu3plugin::openFile(QString fileName) | |
74 | { |
|
74 | { | |
75 | this->elfFile->openFile(fileName); |
|
75 | this->elfFile->openFile(fileName); | |
76 | emit this->updateInfo(this->elfFile); |
|
76 | emit this->updateInfo(this->elfFile); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | bool dsu3plugin::configureTarget() |
|
79 | bool dsu3plugin::configureTarget() | |
80 | { |
|
80 | { | |
81 | int detectedMctrlr=-1; |
|
81 | int detectedMctrlr=-1; | |
82 | if(parent==NULL) |
|
82 | if(parent==NULL) | |
83 | return false; |
|
83 | return false; | |
84 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
84 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
85 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
85 | if(DSUBASEADDRESS == (unsigned int)-1) | |
86 | DSUBASEADDRESS = 0x90000000; |
|
86 | DSUBASEADDRESS = 0x90000000; | |
87 | unsigned int MCTRLBASEADDRESS =-1; |
|
87 | unsigned int MCTRLBASEADDRESS =-1; | |
88 | for(int i=0; i<acceptedMemctrlrCnt;i++) |
|
88 | for(int i=0; i<acceptedMemctrlrCnt;i++) | |
89 | { |
|
89 | { | |
90 | MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0); |
|
90 | MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0); | |
91 | if(MCTRLBASEADDRESS != (unsigned int)-1) |
|
91 | if(MCTRLBASEADDRESS != (unsigned int)-1) | |
92 | { |
|
92 | { | |
93 | SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1); |
|
93 | SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1); | |
94 | detectedMctrlr=i; |
|
94 | detectedMctrlr=i; | |
95 | break; |
|
95 | break; | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 | if(MCTRLBASEADDRESS == (unsigned int)-1) |
|
98 | if(MCTRLBASEADDRESS == (unsigned int)-1) | |
99 | { |
|
99 | { | |
100 | SocExplorerEngine::message(this,"Can't any compatible memory controller",1); |
|
100 | SocExplorerEngine::message(this,"Can't any compatible memory controller",1); | |
101 | return false; |
|
101 | return false; | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 |
|
104 | |||
105 | //Force a debug break |
|
105 | //Force a debug break | |
106 | WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS); |
|
106 | WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS); | |
107 | WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20); |
|
107 | WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20); | |
108 | //Clear time tag counter |
|
108 | //Clear time tag counter | |
109 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8); |
|
109 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8); | |
110 |
|
110 | |||
111 | //Clear ASR registers |
|
111 | //Clear ASR registers | |
112 | WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040); |
|
112 | WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
113 | WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024); |
|
113 | WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024); | |
114 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); |
|
114 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
115 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48); |
|
115 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48); | |
116 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C); |
|
116 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C); | |
117 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040); |
|
117 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
118 |
|
118 | |||
119 | // {0x04,0x0f,"MCTRL"}, |
|
119 | // {0x04,0x0f,"MCTRL"}, | |
120 | // {0x01,0x51,"FTSRCTRL"}, |
|
120 | // {0x01,0x51,"FTSRCTRL"}, | |
121 | // {0x20,0x01,"SRCTRLE_0WS" }, |
|
121 | // {0x20,0x01,"SRCTRLE_0WS" }, | |
122 | // {0x20,0x02,"SRCTRLE_1WS" } |
|
122 | // {0x20,0x02,"SRCTRLE_1WS" } | |
123 | if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" ) |
|
123 | if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" ) | |
124 | { |
|
124 | { | |
125 | WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); |
|
125 | WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); | |
126 | } |
|
126 | } | |
127 | if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" ) |
|
127 | if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" ) | |
128 | { |
|
128 | { | |
129 | //let's perform a mem Wash |
|
129 | //let's perform a mem Wash | |
130 | unsigned int val = ReadReg(MCTRLBASEADDRESS); |
|
130 | unsigned int val = ReadReg(MCTRLBASEADDRESS); | |
131 | val |=1<<31; |
|
131 | val |=1<<31; | |
132 | WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS); |
|
132 | WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS); | |
133 | usleep(1000*1000); |
|
133 | usleep(1000*1000); | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 |
|
136 | |||
137 | WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); |
|
137 | WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
138 | WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); |
|
138 | WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); | |
139 |
|
139 | |||
140 | memSet(DSUBASEADDRESS+0x300000,0,1567); |
|
140 | memSet(DSUBASEADDRESS+0x300000,0,1567); | |
141 | WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); |
|
141 | WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); | |
142 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x403ffff0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020); |
|
142 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x403ffff0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020); | |
143 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); |
|
143 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); | |
144 |
|
144 | |||
145 | //Disable interrupts |
|
145 | //Disable interrupts | |
146 | unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0); |
|
146 | unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0); | |
147 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) |
|
147 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) | |
148 | return false; |
|
148 | return false; | |
149 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); |
|
149 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); | |
150 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); |
|
150 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); | |
151 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); |
|
151 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); | |
152 |
|
152 | |||
153 | //Set up timer |
|
153 | //Set up timer | |
154 | unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0); |
|
154 | unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0); | |
155 | if(APBTIMERBASEADD == (unsigned int)-1) |
|
155 | if(APBTIMERBASEADD == (unsigned int)-1) | |
156 | return false; |
|
156 | return false; | |
157 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); |
|
157 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); | |
158 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); |
|
158 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); | |
159 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); |
|
159 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); | |
160 | return true; |
|
160 | return true; | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | bool dsu3plugin::cacheDisable() |
|
163 | bool dsu3plugin::cacheDisable() | |
164 | { |
|
164 | { | |
165 | return setCacheEnable(false); |
|
165 | return setCacheEnable(false); | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | bool dsu3plugin::cacheEnable() |
|
168 | bool dsu3plugin::cacheEnable() | |
169 | { |
|
169 | { | |
170 | return setCacheEnable(true); |
|
170 | return setCacheEnable(true); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | bool dsu3plugin::setCacheEnable(bool enabled) |
|
173 | bool dsu3plugin::setCacheEnable(bool enabled) | |
174 | { |
|
174 | { | |
175 | if(parent==NULL) |
|
175 | if(parent==NULL) | |
176 | return false; |
|
176 | return false; | |
177 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
177 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
178 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
178 | if(DSUBASEADDRESS == (unsigned int)-1) | |
179 | DSUBASEADDRESS = 0x90000000; |
|
179 | DSUBASEADDRESS = 0x90000000; | |
180 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); |
|
180 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); | |
181 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); |
|
181 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); | |
182 | if(enabled) |
|
182 | if(enabled) | |
183 | { |
|
183 | { | |
184 | WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000); |
|
184 | WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000); | |
185 | //flushes cache. |
|
185 | //flushes cache. | |
186 | WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000); |
|
186 | WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000); | |
187 | } |
|
187 | } | |
188 | else |
|
188 | else | |
189 | { |
|
189 | { | |
190 | WriteRegs(uIntlist()<<((!0x0001000F)®),DSUBASEADDRESS+0x700000); |
|
190 | WriteRegs(uIntlist()<<((!0x0001000F)®),DSUBASEADDRESS+0x700000); | |
191 | WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000); |
|
191 | WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000); | |
192 | } |
|
192 | } | |
193 | return true; |
|
193 | return true; | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | bool dsu3plugin::flashTarget() |
|
196 | bool dsu3plugin::flashTarget() | |
197 | { |
|
197 | { | |
198 | stop(); |
|
198 | stop(); | |
199 | cacheDisable(); |
|
199 | cacheDisable(); | |
200 | configureTarget(); |
|
200 | configureTarget(); | |
201 | /*Write .text*/ |
|
201 | /*Write .text*/ | |
202 | this->writeSection(".text"); |
|
202 | this->writeSection(".text"); | |
203 | /*Write .data*/ |
|
203 | /*Write .data*/ | |
204 | this->writeSection(".data"); |
|
204 | this->writeSection(".data"); | |
205 | return true; |
|
205 | return true; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | void dsu3plugin::run() |
|
208 | void dsu3plugin::run() | |
209 | { |
|
209 | { | |
210 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
210 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
211 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
211 | if(DSUBASEADDRESS == (unsigned int)-1) | |
212 | DSUBASEADDRESS = 0x90000000; |
|
212 | DSUBASEADDRESS = 0x90000000; | |
213 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); |
|
213 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); | |
214 | this->running = true; |
|
214 | this->running = true; | |
215 | this->UI->setRunning(true); |
|
215 | this->UI->setRunning(true); | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | void dsu3plugin::stop() |
|
218 | void dsu3plugin::stop() | |
219 | { |
|
219 | { | |
220 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
220 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
221 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
221 | if(DSUBASEADDRESS == (unsigned int)-1) | |
222 | DSUBASEADDRESS = 0x90000000; |
|
222 | DSUBASEADDRESS = 0x90000000; | |
223 | WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020); |
|
223 | WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020); | |
224 | this->running = false; |
|
224 | this->running = false; | |
225 | this->UI->setRunning(false); |
|
225 | this->UI->setRunning(false); | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | void dsu3plugin::toggleRun() |
|
228 | void dsu3plugin::toggleRun() | |
229 | { |
|
229 | { | |
230 | if(this->running) |
|
230 | if(this->running) | |
231 | this->stop(); |
|
231 | this->stop(); | |
232 | else |
|
232 | else | |
233 | this->run(); |
|
233 | this->run(); | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format) |
|
236 | bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format) | |
237 | { |
|
237 | { | |
238 | if(this->elfFile->isopened()) |
|
238 | if(this->elfFile->isopened()) | |
239 | { |
|
239 | { | |
240 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); |
|
240 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); | |
241 | if(symbolIndex!=-1) |
|
241 | if(symbolIndex!=-1) | |
242 | return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format); |
|
242 | return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format); | |
243 | } |
|
243 | } | |
244 | return false; |
|
244 | return false; | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
|
247 | QVariantList dsu3plugin::readSymbol(const QString &symbolName) | |||
|
248 | { | |||
|
249 | if(this->elfFile->isopened()) | |||
|
250 | { | |||
|
251 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); | |||
|
252 | if(symbolIndex!=-1) | |||
|
253 | return socexplorerplugin::Read((unsigned int)this->elfFile->getSymbolAddress(symbolIndex),(unsigned int)this->elfFile->getSymbolSize(symbolIndex)/4); | |||
|
254 | } | |||
|
255 | return QVariantList(); | |||
|
256 | } | |||
|
257 | ||||
247 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) |
|
258 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) | |
248 | { |
|
259 | { | |
249 | unsigned int* buff; |
|
260 | unsigned int* buff; | |
250 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); |
|
261 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); | |
251 | for(int i=0;i<Values.count();i++) |
|
262 | for(int i=0;i<Values.count();i++) | |
252 | { |
|
263 | { | |
253 | buff[i]=Values.at(i); |
|
264 | buff[i]=Values.at(i); | |
254 | } |
|
265 | } | |
255 | parent->Write(buff,(unsigned int)Values.count(),address); |
|
266 | parent->Write(buff,(unsigned int)Values.count(),address); | |
256 | free(buff); |
|
267 | free(buff); | |
257 | } |
|
268 | } | |
258 |
|
269 | |||
259 | unsigned int dsu3plugin::ReadReg(unsigned int address) |
|
270 | unsigned int dsu3plugin::ReadReg(unsigned int address) | |
260 | { |
|
271 | { | |
261 | unsigned int buff; |
|
272 | unsigned int buff; | |
262 | parent->Read(&buff,1,address); |
|
273 | parent->Read(&buff,1,address); | |
263 | return buff; |
|
274 | return buff; | |
264 | } |
|
275 | } | |
265 |
|
276 | |||
266 | void dsu3plugin::writeSection(int index) |
|
277 | void dsu3plugin::writeSection(int index) | |
267 | { |
|
278 | { | |
268 | char* buffch=NULL; |
|
279 | char* buffch=NULL; | |
269 | unsigned int* buff; |
|
280 | unsigned int* buff; | |
270 | int size = this->elfFile->getSectionDatasz(index); |
|
281 | int size = this->elfFile->getSectionDatasz(index); | |
271 | int sizeInt = size/4; |
|
282 | int sizeInt = size/4; | |
272 | if(parent==NULL) |
|
283 | if(parent==NULL) | |
273 | return; |
|
284 | return; | |
274 | this->elfFile->getSectionData(index,&buffch); |
|
285 | this->elfFile->getSectionData(index,&buffch); | |
275 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); |
|
286 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); | |
276 | for(int i=0;i<sizeInt;i++) |
|
287 | for(int i=0;i<sizeInt;i++) | |
277 | { |
|
288 | { | |
278 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); |
|
289 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); | |
279 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1])); |
|
290 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1])); | |
280 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2])); |
|
291 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2])); | |
281 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3])); |
|
292 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3])); | |
282 | } |
|
293 | } | |
283 | if(size%4) |
|
294 | if(size%4) | |
284 | { |
|
295 | { | |
285 | buff[sizeInt]=0; |
|
296 | buff[sizeInt]=0; | |
286 | for(int i=(size%4);i>0;i--) |
|
297 | for(int i=(size%4);i>0;i--) | |
287 | { |
|
298 | { | |
288 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); |
|
299 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); | |
289 | } |
|
300 | } | |
290 | sizeInt++; |
|
301 | sizeInt++; | |
291 | } |
|
302 | } | |
292 | parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index)); |
|
303 | parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index)); | |
293 | free(buff); |
|
304 | free(buff); | |
294 | } |
|
305 | } | |
295 |
|
306 | |||
296 | void dsu3plugin::writeSection(const QString &name) |
|
307 | void dsu3plugin::writeSection(const QString &name) | |
297 | { |
|
308 | { | |
298 | if(elfFile->isopened()) |
|
309 | if(elfFile->isopened()) | |
299 | { |
|
310 | { | |
300 | writeSection(this->elfFile->getSectionIndex(name)); |
|
311 | writeSection(this->elfFile->getSectionIndex(name)); | |
301 | } |
|
312 | } | |
302 | } |
|
313 | } | |
303 |
|
314 | |||
304 |
|
315 | |||
305 | unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) |
|
316 | unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) | |
306 | { |
|
317 | { | |
307 | if(parent!=NULL) |
|
318 | if(parent!=NULL) | |
308 | return parent->Write(Value,count,address); |
|
319 | return parent->Write(Value,count,address); | |
309 | return 0; |
|
320 | return 0; | |
310 | } |
|
321 | } | |
311 |
|
322 | |||
312 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) |
|
323 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) | |
313 | { |
|
324 | { | |
314 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); |
|
325 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
315 | if(buffer!=NULL) |
|
326 | if(buffer!=NULL) | |
316 | { |
|
327 | { | |
317 | memset((void*)buffer,value,count*sizeof(unsigned int)); |
|
328 | memset((void*)buffer,value,count*sizeof(unsigned int)); | |
318 | parent->Write(buffer,count,address); |
|
329 | parent->Write(buffer,count,address); | |
319 | free(buffer ); |
|
330 | free(buffer ); | |
320 | return true; |
|
331 | return true; | |
321 | } |
|
332 | } | |
322 | return false; |
|
333 | return false; | |
323 | } |
|
334 | } | |
324 |
|
335 | |||
325 | unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address) |
|
336 | unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address) | |
326 | { |
|
337 | { | |
327 | if(parent!=NULL) |
|
338 | if(parent!=NULL) | |
328 | return parent->Read(Value,count,address); |
|
339 | return parent->Read(Value,count,address); | |
329 | return 0; |
|
340 | return 0; | |
330 | } |
|
341 | } |
@@ -1,73 +1,73 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #ifndef DSU3PLUGIN_H |
|
22 | #ifndef DSU3PLUGIN_H | |
23 | #define DSU3PLUGIN_H |
|
23 | #define DSU3PLUGIN_H | |
24 | #include "dsu3pluginui.h" |
|
24 | #include "dsu3pluginui.h" | |
25 | #include <QMenuBar> |
|
25 | #include <QMenuBar> | |
26 | #include <QMenu> |
|
26 | #include <QMenu> | |
27 | #include <QAction> |
|
27 | #include <QAction> | |
28 | #include <QMainWindow> |
|
28 | #include <QMainWindow> | |
29 | #include <QList> |
|
29 | #include <QList> | |
30 | #include "elfparser.h" |
|
30 | #include "elfparser.h" | |
31 | #include <elffile.h> |
|
31 | #include <elffile.h> | |
32 | #include <socexplorerplugin.h> |
|
32 | #include <socexplorerplugin.h> | |
33 | #include <socexplorerengine.h> |
|
33 | #include <socexplorerengine.h> | |
34 |
|
34 | |||
35 | typedef QList<unsigned int> uIntlist; |
|
35 | typedef QList<unsigned int> uIntlist; | |
36 |
|
36 | |||
37 | class dsu3plugin : public socexplorerplugin |
|
37 | class dsu3plugin : public socexplorerplugin | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | public: |
|
40 | public: | |
41 | explicit dsu3plugin(QWidget *parent = 0); |
|
41 | explicit dsu3plugin(QWidget *parent = 0); | |
42 | ~dsu3plugin(); |
|
42 | ~dsu3plugin(); | |
43 | bool memSet(unsigned int address, int value, unsigned int count); |
|
43 | bool memSet(unsigned int address, int value, unsigned int count); | |
44 | public slots: |
|
44 | public slots: | |
45 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
45 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); | |
46 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
46 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
47 | void openFile(); |
|
47 | void openFile(); | |
48 | void openFile(QString fileName); |
|
48 | void openFile(QString fileName); | |
49 | bool configureTarget(); |
|
49 | bool configureTarget(); | |
50 | bool cacheDisable(); |
|
50 | bool cacheDisable(); | |
51 | bool cacheEnable(); |
|
51 | bool cacheEnable(); | |
52 | bool setCacheEnable(bool enabled); |
|
52 | bool setCacheEnable(bool enabled); | |
53 | bool flashTarget(); |
|
53 | bool flashTarget(); | |
54 | void run(); |
|
54 | void run(); | |
55 | void stop(); |
|
55 | void stop(); | |
56 | void toggleRun(); |
|
56 | void toggleRun(); | |
57 | //added for python backward compatibility |
|
57 | //added for python backward compatibility | |
58 | void loadFile(){this->flashTarget();} |
|
58 | void loadFile(){this->flashTarget();} | |
59 | bool dumpSymbol(const QString& symbolName,QString file,const QString& format); |
|
59 | bool dumpSymbol(const QString& symbolName,QString file,const QString& format); | |
60 |
|
60 | QVariantList readSymbol(const QString& symbolName); | ||
61 | signals: |
|
61 | signals: | |
62 | void updateInfo(ElfFile* elfFile); |
|
62 | void updateInfo(ElfFile* elfFile); | |
63 | private: |
|
63 | private: | |
64 | void WriteRegs(uIntlist Values, unsigned int address); |
|
64 | void WriteRegs(uIntlist Values, unsigned int address); | |
65 | unsigned int ReadReg(unsigned int address); |
|
65 | unsigned int ReadReg(unsigned int address); | |
66 | void writeSection(int index); |
|
66 | void writeSection(int index); | |
67 | void writeSection(const QString& name); |
|
67 | void writeSection(const QString& name); | |
68 | dsu3pluginui* UI; |
|
68 | dsu3pluginui* UI; | |
69 | ElfFile* elfFile; |
|
69 | ElfFile* elfFile; | |
70 | bool running; |
|
70 | bool running; | |
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 | #endif // DSU3PLUGIN_H |
|
73 | #endif // DSU3PLUGIN_H |
@@ -1,300 +1,301 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "stardundeegui.h" |
|
22 | #include "stardundeegui.h" | |
23 |
|
23 | |||
24 | #include "ui_stardundeeGUI.h" |
|
24 | #include "ui_stardundeeGUI.h" | |
25 |
#include |
|
25 | #include "fakestardundeespwusb_lib.h" | |
26 |
#include <spw_ |
|
26 | //#include <spw_usb_api.h> | |
|
27 | //#include <spw_config_library.h> | |||
27 |
|
28 | |||
28 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : |
|
29 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : | |
29 | QWidget(parent),ui(new Ui::StarDundeeUI) |
|
30 | QWidget(parent),ui(new Ui::StarDundeeUI) | |
30 | { |
|
31 | { | |
31 | resetBytesPacketsStatistics(); |
|
32 | resetBytesPacketsStatistics(); | |
32 |
|
33 | |||
33 | this->ui->setupUi(this); |
|
34 | this->ui->setupUi(this); | |
34 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); |
|
35 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); | |
35 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); |
|
36 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); | |
36 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); |
|
37 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); | |
37 | // connect(this->ui->sourceAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); |
|
38 | // connect(this->ui->sourceAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); | |
38 | connect(this->ui->sourceAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(sourceLogicalAddressChanged(QString))); |
|
39 | connect(this->ui->sourceAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(sourceLogicalAddressChanged(QString))); | |
39 | connect(this->ui->destinationAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); |
|
40 | connect(this->ui->destinationAddressLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); | |
40 | connect(this->ui->destinationKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); |
|
41 | connect(this->ui->destinationKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); | |
41 | connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString))); |
|
42 | connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString))); | |
42 | connect(this->ui->timecodeFrequencyLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(timecodeFrequencyChange(QString))); |
|
43 | connect(this->ui->timecodeFrequencyLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(timecodeFrequencyChange(QString))); | |
43 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); |
|
44 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); | |
44 | connect(this->ui->setInterfaceModeQrb, SIGNAL(toggled(bool)), this, SIGNAL(brickModeChanged(bool))); |
|
45 | connect(this->ui->setInterfaceModeQrb, SIGNAL(toggled(bool)), this, SIGNAL(brickModeChanged(bool))); | |
45 | connect(this->ui->resetStatsQpb, SIGNAL(clicked()), this, SLOT(resetStatistics())); |
|
46 | connect(this->ui->resetStatsQpb, SIGNAL(clicked()), this, SLOT(resetStatistics())); | |
46 | connect(this->ui->spwTimecodes, SIGNAL(toggled(bool)), this, SIGNAL(startSendingTimecode(bool))); |
|
47 | connect(this->ui->spwTimecodes, SIGNAL(toggled(bool)), this, SIGNAL(startSendingTimecode(bool))); | |
47 | } |
|
48 | } | |
48 |
|
49 | |||
49 | int StarDundeeGUI::getBrickSelection() |
|
50 | int StarDundeeGUI::getBrickSelection() | |
50 | { |
|
51 | { | |
51 | return ui->selectBrickCmbx->currentIndex(); |
|
52 | return ui->selectBrickCmbx->currentIndex(); | |
52 | } |
|
53 | } | |
53 |
|
54 | |||
54 | int StarDundeeGUI::getLinkNumberSelection() |
|
55 | int StarDundeeGUI::getLinkNumberSelection() | |
55 | { |
|
56 | { | |
56 | return ui->selectLinkCmbx->currentIndex(); |
|
57 | return ui->selectLinkCmbx->currentIndex(); | |
57 | } |
|
58 | } | |
58 |
|
59 | |||
59 | QString StarDundeeGUI::getLinkSpeedSelection() |
|
60 | QString StarDundeeGUI::getLinkSpeedSelection() | |
60 | { |
|
61 | { | |
61 | return ui->setLinkSpeedCmbx->currentText(); |
|
62 | return ui->setLinkSpeedCmbx->currentText(); | |
62 | } |
|
63 | } | |
63 |
|
64 | |||
64 | QString StarDundeeGUI::getSourceAddress() |
|
65 | QString StarDundeeGUI::getSourceAddress() | |
65 | { |
|
66 | { | |
66 | return ui->sourceAddressLineEdit->text(); |
|
67 | return ui->sourceAddressLineEdit->text(); | |
67 | } |
|
68 | } | |
68 |
|
69 | |||
69 | QString StarDundeeGUI::getDestinationAddress() |
|
70 | QString StarDundeeGUI::getDestinationAddress() | |
70 | { |
|
71 | { | |
71 | return ui->destinationAddressLineEdit->text(); |
|
72 | return ui->destinationAddressLineEdit->text(); | |
72 | } |
|
73 | } | |
73 |
|
74 | |||
74 | QString StarDundeeGUI::getDestinationKey() |
|
75 | QString StarDundeeGUI::getDestinationKey() | |
75 | { |
|
76 | { | |
76 | return ui->destinationKeyLineEdit->text(); |
|
77 | return ui->destinationKeyLineEdit->text(); | |
77 | } |
|
78 | } | |
78 |
|
79 | |||
79 | QString StarDundeeGUI::getRmapTimeout() |
|
80 | QString StarDundeeGUI::getRmapTimeout() | |
80 | { |
|
81 | { | |
81 | return ui->RMAPTimeoutLineEdit->text(); |
|
82 | return ui->RMAPTimeoutLineEdit->text(); | |
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 | QString StarDundeeGUI::getTimecodeFrequency() |
|
85 | QString StarDundeeGUI::getTimecodeFrequency() | |
85 | { |
|
86 | { | |
86 | return ui->timecodeFrequencyLineEdit->text(); |
|
87 | return ui->timecodeFrequencyLineEdit->text(); | |
87 | } |
|
88 | } | |
88 |
|
89 | |||
89 | bool StarDundeeGUI::getStartSendingTimecodes() |
|
90 | bool StarDundeeGUI::getStartSendingTimecodes() | |
90 | { |
|
91 | { | |
91 | return ui->spwTimecodes->isChecked(); |
|
92 | return ui->spwTimecodes->isChecked(); | |
92 | } |
|
93 | } | |
93 |
|
94 | |||
94 | bool StarDundeeGUI::isBrickSetAsAnInterface() |
|
95 | bool StarDundeeGUI::isBrickSetAsAnInterface() | |
95 | { |
|
96 | { | |
96 | return ui->setInterfaceModeQrb->isChecked(); |
|
97 | return ui->setInterfaceModeQrb->isChecked(); | |
97 | } |
|
98 | } | |
98 |
|
99 | |||
99 | void StarDundeeGUI::setBrickAsAnInterface( bool interfaceMode ) |
|
100 | void StarDundeeGUI::setBrickAsAnInterface( bool interfaceMode ) | |
100 | { |
|
101 | { | |
101 | if (interfaceMode == true) |
|
102 | if (interfaceMode == true) | |
102 | { |
|
103 | { | |
103 | this->ui->setInterfaceModeQrb->setChecked( true ); |
|
104 | this->ui->setInterfaceModeQrb->setChecked( true ); | |
104 | } |
|
105 | } | |
105 | else |
|
106 | else | |
106 | { |
|
107 | { | |
107 | this->ui->setRouterModeQrb->setChecked( true ); |
|
108 | this->ui->setRouterModeQrb->setChecked( true ); | |
108 | } |
|
109 | } | |
109 | } |
|
110 | } | |
110 |
|
111 | |||
111 | void StarDundeeGUI::setBrickAsARouter( bool interfaceMode ) |
|
112 | void StarDundeeGUI::setBrickAsARouter( bool interfaceMode ) | |
112 | { |
|
113 | { | |
113 | if (interfaceMode==true) |
|
114 | if (interfaceMode==true) | |
114 | { |
|
115 | { | |
115 | this->ui->setRouterModeQrb->setChecked( true ); |
|
116 | this->ui->setRouterModeQrb->setChecked( true ); | |
116 | } |
|
117 | } | |
117 | else |
|
118 | else | |
118 | { |
|
119 | { | |
119 | this->ui->setInterfaceModeQrb->setChecked( true ); |
|
120 | this->ui->setInterfaceModeQrb->setChecked( true ); | |
120 | } |
|
121 | } | |
121 |
|
122 | |||
122 | } |
|
123 | } | |
123 |
|
124 | |||
124 | void StarDundeeGUI::lock(bool lock) |
|
125 | void StarDundeeGUI::lock(bool lock) | |
125 | { |
|
126 | { | |
126 | this->ui->selectBrickCmbx->setDisabled(lock); |
|
127 | this->ui->selectBrickCmbx->setDisabled(lock); | |
127 | this->ui->selectLinkCmbx->setDisabled(lock); |
|
128 | this->ui->selectLinkCmbx->setDisabled(lock); | |
128 | this->ui->setLinkSpeedCmbx->setDisabled(lock); |
|
129 | this->ui->setLinkSpeedCmbx->setDisabled(lock); | |
129 | this->ui->sourceAddressLineEdit->setDisabled(lock); |
|
130 | this->ui->sourceAddressLineEdit->setDisabled(lock); | |
130 | this->ui->destinationAddressLineEdit->setDisabled(lock); |
|
131 | this->ui->destinationAddressLineEdit->setDisabled(lock); | |
131 | this->ui->destinationKeyLineEdit->setDisabled(lock); |
|
132 | this->ui->destinationKeyLineEdit->setDisabled(lock); | |
132 | this->ui->RMAPTimeoutLineEdit->setDisabled(lock); |
|
133 | this->ui->RMAPTimeoutLineEdit->setDisabled(lock); | |
133 | this->ui->setInterfaceModeQrb->setDisabled(lock); |
|
134 | this->ui->setInterfaceModeQrb->setDisabled(lock); | |
134 | this->ui->setRouterModeQrb->setDisabled(lock); |
|
135 | this->ui->setRouterModeQrb->setDisabled(lock); | |
135 | if(lock) |
|
136 | if(lock) | |
136 | this->ui->connectQpb->setText("Disconnect"); |
|
137 | this->ui->connectQpb->setText("Disconnect"); | |
137 | else |
|
138 | else | |
138 | this->ui->connectQpb->setText("Connect"); |
|
139 | this->ui->connectQpb->setText("Connect"); | |
139 | } |
|
140 | } | |
140 |
|
141 | |||
141 | void StarDundeeGUI::updateAvailableBrickCount(int count) |
|
142 | void StarDundeeGUI::updateAvailableBrickCount(int count) | |
142 | { |
|
143 | { | |
143 | this->ui->selectBrickCmbx->clear(); |
|
144 | this->ui->selectBrickCmbx->clear(); | |
144 | this->ui->selectBrickCmbx->addItem("none"); |
|
145 | this->ui->selectBrickCmbx->addItem("none"); | |
145 | for(int i =0;i<32;i++) |
|
146 | for(int i =0;i<32;i++) | |
146 | { |
|
147 | { | |
147 | if((count&1)==1) |
|
148 | if((count&1)==1) | |
148 | { |
|
149 | { | |
149 | star_device_handle hDevice; |
|
150 | star_device_handle hDevice; | |
150 | char serial[11]=""; |
|
151 | char serial[11]=""; | |
151 | if (USBSpaceWire_Open(&hDevice, 0)) |
|
152 | if (USBSpaceWire_Open(&hDevice, 0)) | |
152 | { |
|
153 | { | |
153 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); |
|
154 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); | |
154 | USBSpaceWire_Close(hDevice); |
|
155 | USBSpaceWire_Close(hDevice); | |
155 | } |
|
156 | } | |
156 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); |
|
157 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); | |
157 | } |
|
158 | } | |
158 | count>>=1; |
|
159 | count>>=1; | |
159 | } |
|
160 | } | |
160 | } |
|
161 | } | |
161 |
|
162 | |||
162 | void StarDundeeGUI::setRmapTimeout(const QString &timeout) |
|
163 | void StarDundeeGUI::setRmapTimeout(const QString &timeout) | |
163 | { |
|
164 | { | |
164 | this->ui->RMAPTimeoutLineEdit->setText(timeout); |
|
165 | this->ui->RMAPTimeoutLineEdit->setText(timeout); | |
165 | } |
|
166 | } | |
166 |
|
167 | |||
167 | void StarDundeeGUI::selectBrick(int brickIndex) |
|
168 | void StarDundeeGUI::selectBrick(int brickIndex) | |
168 | { |
|
169 | { | |
169 | if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count()) |
|
170 | if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count()) | |
170 | { |
|
171 | { | |
171 | this->ui->selectBrickCmbx->setCurrentIndex(brickIndex); |
|
172 | this->ui->selectBrickCmbx->setCurrentIndex(brickIndex); | |
172 | } |
|
173 | } | |
173 | } |
|
174 | } | |
174 |
|
175 | |||
175 | void StarDundeeGUI::selectLinkNumber(int linkNumber) |
|
176 | void StarDundeeGUI::selectLinkNumber(int linkNumber) | |
176 | { |
|
177 | { | |
177 | if(linkNumber==1 || linkNumber==2) |
|
178 | if(linkNumber==1 || linkNumber==2) | |
178 | { |
|
179 | { | |
179 | this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1); |
|
180 | this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1); | |
180 | } |
|
181 | } | |
181 | } |
|
182 | } | |
182 |
|
183 | |||
183 | void StarDundeeGUI::selectLinkSpeed(int linkSpeed) |
|
184 | void StarDundeeGUI::selectLinkSpeed(int linkSpeed) | |
184 | { |
|
185 | { | |
185 | #define MHz *(1000*1000) |
|
186 | #define MHz *(1000*1000) | |
186 | if(linkSpeed==10 MHz) |
|
187 | if(linkSpeed==10 MHz) | |
187 | { |
|
188 | { | |
188 | this->ui->selectLinkCmbx->setCurrentIndex(0); |
|
189 | this->ui->selectLinkCmbx->setCurrentIndex(0); | |
189 | } |
|
190 | } | |
190 | } |
|
191 | } | |
191 |
|
192 | |||
192 | void StarDundeeGUI::setSourceAddress(const QString &address) |
|
193 | void StarDundeeGUI::setSourceAddress(const QString &address) | |
193 | { |
|
194 | { | |
194 | bool ok; |
|
195 | bool ok; | |
195 | address.toInt(&ok,10); |
|
196 | address.toInt(&ok,10); | |
196 | if(ok) |
|
197 | if(ok) | |
197 | { |
|
198 | { | |
198 | this->ui->sourceAddressLineEdit->setText(address); |
|
199 | this->ui->sourceAddressLineEdit->setText(address); | |
199 | } |
|
200 | } | |
200 | } |
|
201 | } | |
201 |
|
202 | |||
202 | void StarDundeeGUI::setDestinationAddress(const QString &address) |
|
203 | void StarDundeeGUI::setDestinationAddress(const QString &address) | |
203 | { |
|
204 | { | |
204 | bool ok; |
|
205 | bool ok; | |
205 | address.toInt(&ok,10); |
|
206 | address.toInt(&ok,10); | |
206 | if(ok) |
|
207 | if(ok) | |
207 | { |
|
208 | { | |
208 | this->ui->destinationAddressLineEdit->setText(address); |
|
209 | this->ui->destinationAddressLineEdit->setText(address); | |
209 | } |
|
210 | } | |
210 | } |
|
211 | } | |
211 |
|
212 | |||
212 | void StarDundeeGUI::setDestinationKey(const QString &key) |
|
213 | void StarDundeeGUI::setDestinationKey(const QString &key) | |
213 | { |
|
214 | { | |
214 | bool ok; |
|
215 | bool ok; | |
215 | key.toInt(&ok,10); |
|
216 | key.toInt(&ok,10); | |
216 | if(ok) |
|
217 | if(ok) | |
217 | { |
|
218 | { | |
218 | this->ui->destinationKeyLineEdit->setText(key); |
|
219 | this->ui->destinationKeyLineEdit->setText(key); | |
219 | } |
|
220 | } | |
220 | } |
|
221 | } | |
221 |
|
222 | |||
222 | void StarDundeeGUI::setTimecodeFrequency( double frequency ) |
|
223 | void StarDundeeGUI::setTimecodeFrequency( double frequency ) | |
223 | { |
|
224 | { | |
224 | this->ui->timecodeFrequencyLineEdit->setText( QString::number( frequency, 'g', 3 ) ); |
|
225 | this->ui->timecodeFrequencyLineEdit->setText( QString::number( frequency, 'g', 3 ) ); | |
225 | } |
|
226 | } | |
226 |
|
227 | |||
227 | void StarDundeeGUI::setStartSendingTimecodes( bool onOff ) |
|
228 | void StarDundeeGUI::setStartSendingTimecodes( bool onOff ) | |
228 | { |
|
229 | { | |
229 | if (this->ui->spwTimecodes->isChecked()) |
|
230 | if (this->ui->spwTimecodes->isChecked()) | |
230 | { |
|
231 | { | |
231 | if (onOff==false) this->ui->spwTimecodes->setChecked(false); |
|
232 | if (onOff==false) this->ui->spwTimecodes->setChecked(false); | |
232 | } |
|
233 | } | |
233 | else |
|
234 | else | |
234 | { |
|
235 | { | |
235 | if (onOff==true) this->ui->spwTimecodes->setChecked(true); |
|
236 | if (onOff==true) this->ui->spwTimecodes->setChecked(true); | |
236 | } |
|
237 | } | |
237 | } |
|
238 | } | |
238 |
|
239 | |||
239 | int StarDundeeGUI::getAvailableBrickCount( void ) |
|
240 | int StarDundeeGUI::getAvailableBrickCount( void ) | |
240 | { |
|
241 | { | |
241 | int list = USBSpaceWire_ListDevices(); |
|
242 | int list = USBSpaceWire_ListDevices(); | |
242 | emit updateAvailableBrickCount(list); |
|
243 | emit updateAvailableBrickCount(list); | |
243 | QCoreApplication::processEvents(); |
|
244 | QCoreApplication::processEvents(); | |
244 | return list; |
|
245 | return list; | |
245 | } |
|
246 | } | |
246 |
|
247 | |||
247 | void StarDundeeGUI::resetBytesPacketsStatistics( void ) |
|
248 | void StarDundeeGUI::resetBytesPacketsStatistics( void ) | |
248 | { |
|
249 | { | |
249 | nbBytesReceivedFromSpw = 0; |
|
250 | nbBytesReceivedFromSpw = 0; | |
250 | nbBytesTransmittedToSpw = 0; |
|
251 | nbBytesTransmittedToSpw = 0; | |
251 | nbPacketsReceivedFromSpw = 0; |
|
252 | nbPacketsReceivedFromSpw = 0; | |
252 | nbPacketsTransmittedToSpw = 0; |
|
253 | nbPacketsTransmittedToSpw = 0; | |
253 | nbCCSDSPacketsTransmittedToSpw = 0; |
|
254 | nbCCSDSPacketsTransmittedToSpw = 0; | |
254 | } |
|
255 | } | |
255 |
|
256 | |||
256 | void StarDundeeGUI::resetStatistics( void ) |
|
257 | void StarDundeeGUI::resetStatistics( void ) | |
257 | { |
|
258 | { | |
258 | nbBytesReceivedFromSpw = 0; |
|
259 | nbBytesReceivedFromSpw = 0; | |
259 | nbBytesTransmittedToSpw = 0; |
|
260 | nbBytesTransmittedToSpw = 0; | |
260 | nbPacketsReceivedFromSpw = 0; |
|
261 | nbPacketsReceivedFromSpw = 0; | |
261 | nbPacketsTransmittedToSpw = 0; |
|
262 | nbPacketsTransmittedToSpw = 0; | |
262 |
|
263 | |||
263 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); |
|
264 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); | |
264 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); |
|
265 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); | |
265 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); |
|
266 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); | |
266 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); |
|
267 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); | |
267 | } |
|
268 | } | |
268 |
|
269 | |||
269 | void StarDundeeGUI::updateNbReceivedBytesFromSpw( unsigned int nbBytes) |
|
270 | void StarDundeeGUI::updateNbReceivedBytesFromSpw( unsigned int nbBytes) | |
270 | { |
|
271 | { | |
271 | nbBytesReceivedFromSpw = nbBytesReceivedFromSpw + nbBytes; |
|
272 | nbBytesReceivedFromSpw = nbBytesReceivedFromSpw + nbBytes; | |
272 | nbPacketsReceivedFromSpw = nbPacketsReceivedFromSpw + 1; |
|
273 | nbPacketsReceivedFromSpw = nbPacketsReceivedFromSpw + 1; | |
273 |
|
274 | |||
274 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); |
|
275 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); | |
275 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); |
|
276 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); | |
276 | } |
|
277 | } | |
277 |
|
278 | |||
278 | void StarDundeeGUI::updateNbTransmittedBytesToSpw( unsigned int nbBytes) |
|
279 | void StarDundeeGUI::updateNbTransmittedBytesToSpw( unsigned int nbBytes) | |
279 | { |
|
280 | { | |
280 | nbBytesTransmittedToSpw = nbBytesTransmittedToSpw + nbBytes; |
|
281 | nbBytesTransmittedToSpw = nbBytesTransmittedToSpw + nbBytes; | |
281 | nbPacketsTransmittedToSpw = nbPacketsTransmittedToSpw + 1; |
|
282 | nbPacketsTransmittedToSpw = nbPacketsTransmittedToSpw + 1; | |
282 |
|
283 | |||
283 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); |
|
284 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); | |
284 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); |
|
285 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); | |
285 | } |
|
286 | } | |
286 |
|
287 | |||
287 | void StarDundeeGUI::updateCCSDSPacketTransmittedToSpw( void ) |
|
288 | void StarDundeeGUI::updateCCSDSPacketTransmittedToSpw( void ) | |
288 | { |
|
289 | { | |
289 | nbCCSDSPacketsTransmittedToSpw = nbCCSDSPacketsTransmittedToSpw + 1; |
|
290 | nbCCSDSPacketsTransmittedToSpw = nbCCSDSPacketsTransmittedToSpw + 1; | |
290 | } |
|
291 | } | |
291 |
|
292 | |||
292 | unsigned int StarDundeeGUI::getNbCCSDSPacketsTransmittedToSpw(void) |
|
293 | unsigned int StarDundeeGUI::getNbCCSDSPacketsTransmittedToSpw(void) | |
293 | { |
|
294 | { | |
294 | return this->nbCCSDSPacketsTransmittedToSpw; |
|
295 | return this->nbCCSDSPacketsTransmittedToSpw; | |
295 | } |
|
296 | } | |
296 |
|
297 | |||
297 | unsigned int StarDundeeGUI::getNbPacketsTransmittedToSpw() |
|
298 | unsigned int StarDundeeGUI::getNbPacketsTransmittedToSpw() | |
298 | { |
|
299 | { | |
299 | return this->nbPacketsTransmittedToSpw; |
|
300 | return this->nbPacketsTransmittedToSpw; | |
300 | } |
|
301 | } |
@@ -1,1102 +1,1103 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "stardundeespw_usb.h" |
|
23 | #include "stardundeespw_usb.h" | |
|
24 | #include "fakestardundeespwusb_lib.h" | |||
24 | #include <socexplorerengine.h> |
|
25 | #include <socexplorerengine.h> | |
25 | #include <qhexedit.h> |
|
26 | #include <qhexedit.h> | |
26 |
|
27 | |||
27 | QString dwLinkStatusQString[6] = { |
|
28 | QString dwLinkStatusQString[6] = { | |
28 | "CFG_SPACEWIRE_ERROR_RESET", |
|
29 | "CFG_SPACEWIRE_ERROR_RESET", | |
29 | "CFG_SPACEWIRE_ERROR_WAIT", |
|
30 | "CFG_SPACEWIRE_ERROR_WAIT", | |
30 | "CFG_SPACEWIRE_READY", |
|
31 | "CFG_SPACEWIRE_READY", | |
31 | "CFG_SPACEWIRE_STARTED", |
|
32 | "CFG_SPACEWIRE_STARTED", | |
32 | "CFG_SPACEWIRE_CONNECTING", |
|
33 | "CFG_SPACEWIRE_CONNECTING", | |
33 | "CFG_SPACEWIRE_RUN" |
|
34 | "CFG_SPACEWIRE_RUN" | |
34 | }; |
|
35 | }; | |
35 |
|
36 | |||
36 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
37 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
37 | abstractSpwBridge(parent) |
|
38 | abstractSpwBridge(parent) | |
38 | { |
|
39 | { | |
39 | Q_UNUSED(parent) |
|
40 | Q_UNUSED(parent) | |
40 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
41 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
41 | makeGUI(parent); |
|
42 | makeGUI(parent); | |
42 | this->manager->start(); |
|
43 | this->manager->start(); | |
43 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); |
|
44 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); | |
44 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); |
|
45 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); | |
45 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); |
|
46 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); | |
46 | connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw())); |
|
47 | connect(this->manager, SIGNAL(ccsdsPacketTransmittedToSpw()), this, SIGNAL(CCSDSPacketTransmittedToSpw())); | |
47 | } |
|
48 | } | |
48 |
|
49 | |||
49 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
50 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
50 | { |
|
51 | { | |
51 | this->manager->requestInterruption(); |
|
52 | this->manager->requestInterruption(); | |
52 | while(this->manager->isRunning()); |
|
53 | while(this->manager->isRunning()); | |
53 | } |
|
54 | } | |
54 |
|
55 | |||
55 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
56 | void stardundeeSPW_USB::toggleBridgeConnection() | |
56 | { |
|
57 | { | |
57 | if(this->plugin->isConnected()) |
|
58 | if(this->plugin->isConnected()) | |
58 | { |
|
59 | { | |
59 | this->disconnectBridge(); |
|
60 | this->disconnectBridge(); | |
60 | } |
|
61 | } | |
61 | else |
|
62 | else | |
62 | { |
|
63 | { | |
63 | this->connectBridge(); |
|
64 | this->connectBridge(); | |
64 | } |
|
65 | } | |
65 | } |
|
66 | } | |
66 |
|
67 | |||
67 | bool stardundeeSPW_USB::connectBridge() |
|
68 | bool stardundeeSPW_USB::connectBridge() | |
68 | { |
|
69 | { | |
69 | if(this->manager->connectBridge()) |
|
70 | if(this->manager->connectBridge()) | |
70 | { |
|
71 | { | |
71 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); |
|
72 | this->timecodeFrequencyChanged( ((StarDundeeGUI*)this->p_GUI)->getTimecodeFrequency()); | |
72 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); |
|
73 | this->startSendingTimecodes( ((StarDundeeGUI*)this->p_GUI)->getStartSendingTimecodes()); | |
73 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
74 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
74 | emit setConnected(true); |
|
75 | emit setConnected(true); | |
75 | return true; |
|
76 | return true; | |
76 | } |
|
77 | } | |
77 | return false; |
|
78 | return false; | |
78 | } |
|
79 | } | |
79 |
|
80 | |||
80 | bool stardundeeSPW_USB::disconnectBridge() |
|
81 | bool stardundeeSPW_USB::disconnectBridge() | |
81 | { |
|
82 | { | |
82 | if(this->manager->disconnectBridge()) |
|
83 | if(this->manager->disconnectBridge()) | |
83 | { |
|
84 | { | |
84 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
85 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
85 | emit setConnected(false); |
|
86 | emit setConnected(false); | |
86 | return true; |
|
87 | return true; | |
87 | } |
|
88 | } | |
88 | return false; |
|
89 | return false; | |
89 | } |
|
90 | } | |
90 |
|
91 | |||
91 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
92 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
92 | { |
|
93 | { | |
93 | return this->manager->sendPacket(packet,size); |
|
94 | return this->manager->sendPacket(packet,size); | |
94 | } |
|
95 | } | |
95 |
|
96 | |||
96 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
97 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
97 | { |
|
98 | { | |
98 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
99 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; | |
99 | char *RMAPAckBuff; |
|
100 | char *RMAPAckBuff; | |
100 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
101 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
101 | int transactionID = 0; |
|
102 | int transactionID = 0; | |
102 | int written=0; |
|
103 | int written=0; | |
103 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
104 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
104 | QProgressBar* progress=NULL; |
|
105 | QProgressBar* progress=NULL; | |
105 | SocExplorerAutoProgressBar autopb; |
|
106 | SocExplorerAutoProgressBar autopb; | |
106 | if(count>RMAP_MAX_XFER_SIZE) |
|
107 | if(count>RMAP_MAX_XFER_SIZE) | |
107 | { |
|
108 | { | |
108 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
109 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
109 | autopb.setProgressBar(progress); |
|
110 | autopb.setProgressBar(progress); | |
110 | } |
|
111 | } | |
111 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
112 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
112 | while(count>=RMAP_MAX_XFER_SIZE) |
|
113 | while(count>=RMAP_MAX_XFER_SIZE) | |
113 | { |
|
114 | { | |
114 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
115 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
115 | { |
|
116 | { | |
116 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
118 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
118 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
119 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
119 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
120 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
120 | } |
|
121 | } | |
121 | transactionID=manager->getRMAPtransactionID(); |
|
122 | transactionID=manager->getRMAPtransactionID(); | |
122 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
123 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
123 | RMAP_build_tx_request_header( |
|
124 | RMAP_build_tx_request_header( | |
124 | this->manager->destinationLogicalAddress, |
|
125 | this->manager->destinationLogicalAddress, | |
125 | this->manager->destinationKey, |
|
126 | this->manager->destinationKey, | |
126 | this->manager->sourceLogicalAddress, |
|
127 | this->manager->sourceLogicalAddress, | |
127 | transactionID, |
|
128 | transactionID, | |
128 | address+(written*4), |
|
129 | address+(written*4), | |
129 | RMAP_MAX_XFER_SIZE*4, |
|
130 | RMAP_MAX_XFER_SIZE*4, | |
130 | writeBuffer+1); |
|
131 | writeBuffer+1); | |
131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
132 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
133 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
133 | free(RMAPAckBuff); |
|
134 | free(RMAPAckBuff); | |
134 | written+=RMAP_MAX_XFER_SIZE; |
|
135 | written+=RMAP_MAX_XFER_SIZE; | |
135 | count-=RMAP_MAX_XFER_SIZE; |
|
136 | count-=RMAP_MAX_XFER_SIZE; | |
136 | progress->setValue(written); |
|
137 | progress->setValue(written); | |
137 | qApp->processEvents(); |
|
138 | qApp->processEvents(); | |
138 | } |
|
139 | } | |
139 | if(count>0) |
|
140 | if(count>0) | |
140 | { |
|
141 | { | |
141 | for(int i=0;i<((int)count);i++) |
|
142 | for(int i=0;i<((int)count);i++) | |
142 | { |
|
143 | { | |
143 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
145 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
145 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
146 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
146 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
147 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
147 | } |
|
148 | } | |
148 | transactionID=manager->getRMAPtransactionID(); |
|
149 | transactionID=manager->getRMAPtransactionID(); | |
149 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
150 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
150 | RMAP_build_tx_request_header( |
|
151 | RMAP_build_tx_request_header( | |
151 | this->manager->destinationLogicalAddress, |
|
152 | this->manager->destinationLogicalAddress, | |
152 | this->manager->destinationKey, |
|
153 | this->manager->destinationKey, | |
153 | this->manager->sourceLogicalAddress, |
|
154 | this->manager->sourceLogicalAddress, | |
154 | transactionID, |
|
155 | transactionID, | |
155 | address+(written*4), |
|
156 | address+(written*4), | |
156 | count*4, |
|
157 | count*4, | |
157 | writeBuffer+1); |
|
158 | writeBuffer+1); | |
158 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
159 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
159 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
160 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
160 | free(RMAPAckBuff); |
|
161 | free(RMAPAckBuff); | |
161 | written+=count; |
|
162 | written+=count; | |
162 | if(progress!=NULL) |
|
163 | if(progress!=NULL) | |
163 | { |
|
164 | { | |
164 | progress->setValue(written); |
|
165 | progress->setValue(written); | |
165 | qApp->processEvents(); |
|
166 | qApp->processEvents(); | |
166 | } |
|
167 | } | |
167 | } |
|
168 | } | |
168 | return written; |
|
169 | return written; | |
169 | } |
|
170 | } | |
170 |
|
171 | |||
171 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
172 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
172 | { |
|
173 | { | |
173 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
174 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
174 | char* RMAP_AnswerBuffer; |
|
175 | char* RMAP_AnswerBuffer; | |
175 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
176 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
176 | int transactionID = 0; |
|
177 | int transactionID = 0; | |
177 | int read=0; |
|
178 | int read=0; | |
178 | QProgressBar* progress=NULL; |
|
179 | QProgressBar* progress=NULL; | |
179 | SocExplorerAutoProgressBar autopb; |
|
180 | SocExplorerAutoProgressBar autopb; | |
180 | if(count>RMAP_MAX_XFER_SIZE) |
|
181 | if(count>RMAP_MAX_XFER_SIZE) | |
181 | { |
|
182 | { | |
182 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
183 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
183 | autopb.setProgressBar(progress); |
|
184 | autopb.setProgressBar(progress); | |
184 | } |
|
185 | } | |
185 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
186 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); | |
186 |
|
187 | |||
187 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
188 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
188 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
189 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
189 | { |
|
190 | { | |
190 | transactionID = manager->getRMAPtransactionID(); |
|
191 | transactionID = manager->getRMAPtransactionID(); | |
191 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
192 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
192 | RMAP_build_rx_request_header( |
|
193 | RMAP_build_rx_request_header( | |
193 | this->manager->destinationLogicalAddress, |
|
194 | this->manager->destinationLogicalAddress, | |
194 | this->manager->destinationKey, |
|
195 | this->manager->destinationKey, | |
195 | this->manager->sourceLogicalAddress, |
|
196 | this->manager->sourceLogicalAddress, | |
196 | transactionID, |
|
197 | transactionID, | |
197 | address+(read*4), |
|
198 | address+(read*4), | |
198 | RMAP_MAX_XFER_SIZE*4, |
|
199 | RMAP_MAX_XFER_SIZE*4, | |
199 | requestBuffer+1); |
|
200 | requestBuffer+1); | |
200 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
201 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
201 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
202 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
202 | if(len==-1) |
|
203 | if(len==-1) | |
203 | { |
|
204 | { | |
204 | this->toggleBridgeConnection(); |
|
205 | this->toggleBridgeConnection(); | |
205 | return 0; |
|
206 | return 0; | |
206 | } |
|
207 | } | |
207 | for(int i=0;i<((len-13)/4);i++) |
|
208 | for(int i=0;i<((len-13)/4);i++) | |
208 | { |
|
209 | { | |
209 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
210 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
210 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
211 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
211 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
212 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
212 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
213 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
213 | } |
|
214 | } | |
214 | free(RMAP_AnswerBuffer); |
|
215 | free(RMAP_AnswerBuffer); | |
215 | read+=RMAP_MAX_XFER_SIZE; |
|
216 | read+=RMAP_MAX_XFER_SIZE; | |
216 | count-=RMAP_MAX_XFER_SIZE; |
|
217 | count-=RMAP_MAX_XFER_SIZE; | |
217 | progress->setValue(read); |
|
218 | progress->setValue(read); | |
218 | qApp->processEvents(); |
|
219 | qApp->processEvents(); | |
219 | } |
|
220 | } | |
220 | if((int)count>0) |
|
221 | if((int)count>0) | |
221 | { |
|
222 | { | |
222 | transactionID = manager->getRMAPtransactionID(); |
|
223 | transactionID = manager->getRMAPtransactionID(); | |
223 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
224 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
224 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
225 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
225 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
226 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
226 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
227 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
227 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
228 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
228 | RMAP_build_rx_request_header( |
|
229 | RMAP_build_rx_request_header( | |
229 | this->manager->destinationLogicalAddress, |
|
230 | this->manager->destinationLogicalAddress, | |
230 | this->manager->destinationKey, |
|
231 | this->manager->destinationKey, | |
231 | this->manager->sourceLogicalAddress, |
|
232 | this->manager->sourceLogicalAddress, | |
232 | transactionID, |
|
233 | transactionID, | |
233 | address+(read*4), |
|
234 | address+(read*4), | |
234 | count*4, |
|
235 | count*4, | |
235 | requestBuffer+1); |
|
236 | requestBuffer+1); | |
236 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
237 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
237 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
238 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
238 | if(len==-1) |
|
239 | if(len==-1) | |
239 | { |
|
240 | { | |
240 | this->toggleBridgeConnection(); |
|
241 | this->toggleBridgeConnection(); | |
241 | return 0; |
|
242 | return 0; | |
242 | } |
|
243 | } | |
243 | for(int i=0;i<((len-13)/4);i++) |
|
244 | for(int i=0;i<((len-13)/4);i++) | |
244 | { |
|
245 | { | |
245 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
246 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
246 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
247 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
247 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
248 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
248 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
249 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
249 | } |
|
250 | } | |
250 | free(RMAP_AnswerBuffer); |
|
251 | free(RMAP_AnswerBuffer); | |
251 | read+=count; |
|
252 | read+=count; | |
252 | if(progress!=NULL) |
|
253 | if(progress!=NULL) | |
253 | { |
|
254 | { | |
254 | progress->setValue(read); |
|
255 | progress->setValue(read); | |
255 | qApp->processEvents(); |
|
256 | qApp->processEvents(); | |
256 | } |
|
257 | } | |
257 | } |
|
258 | } | |
258 | return read; |
|
259 | return read; | |
259 | } |
|
260 | } | |
260 |
|
261 | |||
261 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
262 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
262 | { |
|
263 | { | |
263 | this->manager->selectedBrick = brickIndex-1; |
|
264 | this->manager->selectedBrick = brickIndex-1; | |
264 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
265 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); | |
265 | } |
|
266 | } | |
266 |
|
267 | |||
267 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
268 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
268 | { |
|
269 | { | |
269 | this->manager->linkNumber = linkIndex + 1; |
|
270 | this->manager->linkNumber = linkIndex + 1; | |
270 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
271 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); | |
271 | } |
|
272 | } | |
272 |
|
273 | |||
273 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
274 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
274 | { |
|
275 | { | |
275 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
276 | this->manager->linkSpeed = linkSpeed.toInt(); | |
276 |
|
277 | |||
277 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
278 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); | |
278 | } |
|
279 | } | |
279 |
|
280 | |||
280 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) |
|
281 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) | |
281 | { |
|
282 | { | |
282 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); |
|
283 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); | |
283 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); |
|
284 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); | |
284 | } |
|
285 | } | |
285 |
|
286 | |||
286 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) |
|
287 | void stardundeeSPW_USB::destinationAddressChanged(const QString &rmapaddress) | |
287 | { |
|
288 | { | |
288 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); |
|
289 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); | |
289 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); |
|
290 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); | |
290 | } |
|
291 | } | |
291 |
|
292 | |||
292 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) |
|
293 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) | |
293 | { |
|
294 | { | |
294 | this->manager->destinationKey = key.toInt(); |
|
295 | this->manager->destinationKey = key.toInt(); | |
295 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); |
|
296 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); | |
296 | } |
|
297 | } | |
297 |
|
298 | |||
298 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) |
|
299 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) | |
299 | { |
|
300 | { | |
300 | this->manager->interfaceMode = interfaceMode; |
|
301 | this->manager->interfaceMode = interfaceMode; | |
301 | } |
|
302 | } | |
302 |
|
303 | |||
303 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) |
|
304 | void stardundeeSPW_USB::timecodeFrequencyChanged(const QString &frequency) | |
304 | { |
|
305 | { | |
305 | this->manager->timecodeFrequency = frequency.toDouble(); |
|
306 | this->manager->timecodeFrequency = frequency.toDouble(); | |
306 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); |
|
307 | this->manager->setTimecodeFrequency( this->manager->timecodeFrequency); | |
307 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); |
|
308 | SocExplorerEngine::message(plugin,QString("Changing timecode frequency: %1").arg(manager->timecodeFrequency),1); | |
308 | } |
|
309 | } | |
309 |
|
310 | |||
310 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) |
|
311 | void stardundeeSPW_USB::startSendingTimecodes(bool onOff ) | |
311 | { |
|
312 | { | |
312 | this->manager->sendTimecodePeriodically( onOff ); |
|
313 | this->manager->sendTimecodePeriodically( onOff ); | |
313 | } |
|
314 | } | |
314 |
|
315 | |||
315 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
316 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) | |
316 | { |
|
317 | { | |
317 | int tim=timeout.toInt(); |
|
318 | int tim=timeout.toInt(); | |
318 | if(tim<50) |
|
319 | if(tim<50) | |
319 | { |
|
320 | { | |
320 | tim = 50; |
|
321 | tim = 50; | |
321 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
322 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); | |
322 | } |
|
323 | } | |
323 | this->manager->RMAPtimeout = tim; |
|
324 | this->manager->RMAPtimeout = tim; | |
324 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
325 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); | |
325 | } |
|
326 | } | |
326 |
|
327 | |||
327 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
328 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
328 | { |
|
329 | { | |
329 | Q_UNUSED(parent) |
|
330 | Q_UNUSED(parent) | |
330 | this->p_GUI = new StarDundeeGUI(); |
|
331 | this->p_GUI = new StarDundeeGUI(); | |
331 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
332 | // this->mainLayout = new QGridLayout(this->p_GUI); | |
332 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
333 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
333 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
334 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
334 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
335 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
336 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
337 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); |
|
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); | |
338 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); |
|
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(destinationAddressChanged(QString))); | |
339 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); |
|
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
340 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); | |
341 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); |
|
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); | |
342 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); |
|
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(timecodeFrequencyChange(QString)), this, SLOT(timecodeFrequencyChanged(QString))); | |
343 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); |
|
344 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(startSendingTimecode(bool)), this, SLOT(startSendingTimecodes(bool))); | |
344 |
|
345 | |||
345 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
346 | this->brickSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
346 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
347 | this->linkNumberSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
347 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
348 | this->linkSpeedSelectionChanged( ((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
348 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); |
|
349 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getSourceAddress()); | |
349 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); |
|
350 | this->destinationAddressChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationAddress()); | |
350 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); |
|
351 | this->destinationKeyChanged( ((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
351 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); |
|
352 | this->rmapTimeoutChanged( ((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
352 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); |
|
353 | this->brickModeChanged( ((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |
353 |
|
354 | |||
354 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
355 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
355 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
356 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
356 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); |
|
357 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |
357 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); |
|
358 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |
358 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); |
|
359 | connect(this,SIGNAL(SetDestinationAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationAddress(QString))); | |
359 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); |
|
360 | connect(this,SIGNAL(SetSourceAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setSourceAddress(QString))); | |
360 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); |
|
361 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |
361 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); |
|
362 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |
362 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); |
|
363 | connect(this,SIGNAL(GetNbPacketsTransmittedToSpw()),((StarDundeeGUI*)this->p_GUI),SLOT(getNbPacketsTransmittedToSpw())); | |
363 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), |
|
364 | connect(this,SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()), | |
364 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); |
|
365 | ((StarDundeeGUI*)this->p_GUI),SLOT(getNbCCSDSPacketsTransmittedToSpw())); | |
365 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); |
|
366 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |
366 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); |
|
367 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |
367 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); |
|
368 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |
368 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); |
|
369 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |
369 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); |
|
370 | connect(this,SIGNAL(CCSDSPacketTransmittedToSpw()), ((StarDundeeGUI*)this->p_GUI),SLOT(updateCCSDSPacketTransmittedToSpw())); | |
370 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); |
|
371 | connect(this,SIGNAL(SetTimecodeFrequency(double)), ((StarDundeeGUI*)this->p_GUI),SLOT(setTimecodeFrequency(double))); | |
371 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); |
|
372 | connect(this,SIGNAL(StartSendingTimecodes(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setStartSendingTimecodes(bool))); | |
372 |
|
373 | |||
373 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); |
|
374 | connect(this,SIGNAL(SendOneTimecode(unsigned char)),this->manager, SLOT(sendOneTimecode(unsigned char))); | |
374 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); |
|
375 | connect(this,SIGNAL(GetLinkNumber()), this->manager, SLOT(getLinkNumber())); | |
375 | } |
|
376 | } | |
376 |
|
377 | |||
377 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) |
|
378 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) | |
378 | { |
|
379 | { | |
379 | char* data; |
|
380 | char* data; | |
380 | int i; |
|
381 | int i; | |
381 |
|
382 | |||
382 | data = (char *) malloc( size + 5 ); |
|
383 | data = (char *) malloc( size + 5 ); | |
383 |
|
384 | |||
384 | data[0] = this->manager->linkNumber; |
|
385 | data[0] = this->manager->linkNumber; | |
385 | data[1] = this->manager->destinationLogicalAddress; // target logical address |
|
386 | data[1] = this->manager->destinationLogicalAddress; // target logical address | |
386 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier |
|
387 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier | |
387 | data[3] = 0x00; // reserved |
|
388 | data[3] = 0x00; // reserved | |
388 | data[4] = 0x00; // user application |
|
389 | data[4] = 0x00; // user application | |
389 |
|
390 | |||
390 | for ( i=0; i<size; i++ ) |
|
391 | for ( i=0; i<size; i++ ) | |
391 | { |
|
392 | { | |
392 | data[i+5] = packet[i]; |
|
393 | data[i+5] = packet[i]; | |
393 | } |
|
394 | } | |
394 |
|
395 | |||
395 | this->manager->sendPacket( data, size + 5); |
|
396 | this->manager->sendPacket( data, size + 5); | |
396 |
|
397 | |||
397 | free(data); |
|
398 | free(data); | |
398 | free(packet); |
|
399 | free(packet); | |
399 | } |
|
400 | } | |
400 |
|
401 | |||
401 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
402 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
402 | :QThread((QObject*)parent) |
|
403 | :QThread((QObject*)parent) | |
403 | { |
|
404 | { | |
404 | this->RMAPtimeout = 2000; |
|
405 | this->RMAPtimeout = 2000; | |
405 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
406 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
406 | // this->handleMutex = new QMutex(QMutex::Recursive); |
|
407 | // this->handleMutex = new QMutex(QMutex::Recursive); | |
407 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
408 | this->RMAP_AnswersSem = new QSemaphore(0); | |
408 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
409 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
409 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
410 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
410 | this->plugin = plugin; |
|
411 | this->plugin = plugin; | |
411 | connected = false; |
|
412 | connected = false; | |
412 | // TODO remove this crap! |
|
413 | // TODO remove this crap! | |
413 | this->initDialog(); |
|
414 | this->initDialog(); | |
414 | // this->moveToThread(this); |
|
415 | // this->moveToThread(this); | |
415 | } |
|
416 | } | |
416 |
|
417 | |||
417 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
418 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
418 | { |
|
419 | { | |
419 | this->terminate(); |
|
420 | this->terminate(); | |
420 | while (!this->isFinished()) { |
|
421 | while (!this->isFinished()) { | |
421 | this->usleep(1000); |
|
422 | this->usleep(1000); | |
422 | } |
|
423 | } | |
423 | } |
|
424 | } | |
424 |
|
425 | |||
425 | void stardundeeSPW_USB_Manager::run() |
|
426 | void stardundeeSPW_USB_Manager::run() | |
426 | { |
|
427 | { | |
427 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
428 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
428 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
429 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
429 | USB_SPACEWIRE_STATUS stat; |
|
430 | USB_SPACEWIRE_STATUS stat; | |
430 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
431 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
431 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
432 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
432 | while (!this->isInterruptionRequested()) |
|
433 | while (!this->isInterruptionRequested()) | |
433 | { |
|
434 | { | |
434 | if(this->connected) |
|
435 | if(this->connected) | |
435 | { |
|
436 | { | |
436 | this->handleMutex->lock(); |
|
437 | this->handleMutex->lock(); | |
437 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
438 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
438 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
439 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
439 | { |
|
440 | { | |
440 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
441 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
441 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
442 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
442 | if (stat == TRANSFER_SUCCESS) |
|
443 | if (stat == TRANSFER_SUCCESS) | |
443 | { |
|
444 | { | |
444 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
445 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
445 | { |
|
446 | { | |
446 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
447 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
447 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
448 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
448 | { |
|
449 | { | |
449 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
450 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); | |
450 | emit bytesReceivedFromSpw( properties.len ); |
|
451 | emit bytesReceivedFromSpw( properties.len ); | |
451 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
452 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
452 | { |
|
453 | { | |
453 | RMAP_Answer* packet; |
|
454 | RMAP_Answer* packet; | |
454 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
455 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
455 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
456 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
456 | char* packetbuffer = (char*)malloc(properties.len); |
|
457 | char* packetbuffer = (char*)malloc(properties.len); | |
457 | memcpy(packetbuffer,buffer,properties.len); |
|
458 | memcpy(packetbuffer,buffer,properties.len); | |
458 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
459 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
459 | pIdentifier = NULL; |
|
460 | pIdentifier = NULL; | |
460 | this->handleMutex->unlock(); |
|
461 | this->handleMutex->unlock(); | |
461 | if(properties.len==8) |
|
462 | if(properties.len==8) | |
462 | { |
|
463 | { | |
463 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
464 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); | |
464 | } |
|
465 | } | |
465 | else |
|
466 | else | |
466 | { |
|
467 | { | |
467 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
468 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
468 | } |
|
469 | } | |
469 | RMAP_AnswersMtx->lock(); |
|
470 | RMAP_AnswersMtx->lock(); | |
470 | RMAP_Answers.append(packet); |
|
471 | RMAP_Answers.append(packet); | |
471 | RMAP_AnswersMtx->unlock(); |
|
472 | RMAP_AnswersMtx->unlock(); | |
472 | RMAP_AnswersSem->release(); |
|
473 | RMAP_AnswersSem->release(); | |
473 | } |
|
474 | } | |
474 | else //any non-rmap packet will be pushed to the network |
|
475 | else //any non-rmap packet will be pushed to the network | |
475 | { |
|
476 | { | |
476 | char* packetbuffer = (char*)malloc(properties.len); |
|
477 | char* packetbuffer = (char*)malloc(properties.len); | |
477 | memcpy(packetbuffer,buffer,properties.len); |
|
478 | memcpy(packetbuffer,buffer,properties.len); | |
478 | emit emitPacket(packetbuffer,properties.len); |
|
479 | emit emitPacket(packetbuffer,properties.len); | |
479 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
480 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
480 | this->handleMutex->unlock(); |
|
481 | this->handleMutex->unlock(); | |
481 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
482 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
482 | } |
|
483 | } | |
483 | } |
|
484 | } | |
484 | else |
|
485 | else | |
485 | { |
|
486 | { | |
486 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
487 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
487 | this->handleMutex->unlock(); |
|
488 | this->handleMutex->unlock(); | |
488 | } |
|
489 | } | |
489 | } |
|
490 | } | |
490 |
|
491 | |||
491 | } |
|
492 | } | |
492 | else |
|
493 | else | |
493 | { |
|
494 | { | |
494 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
495 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
495 | this->handleMutex->unlock(); |
|
496 | this->handleMutex->unlock(); | |
496 | } |
|
497 | } | |
497 | } |
|
498 | } | |
498 | else |
|
499 | else | |
499 | { |
|
500 | { | |
500 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
501 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
501 | this->handleMutex->unlock(); |
|
502 | this->handleMutex->unlock(); | |
502 | } |
|
503 | } | |
503 | } |
|
504 | } | |
504 | else |
|
505 | else | |
505 | { |
|
506 | { | |
506 | //do some sanity checks! |
|
507 | //do some sanity checks! | |
507 | int list = USBSpaceWire_ListDevices(); |
|
508 | int list = USBSpaceWire_ListDevices(); | |
508 | if(this->brickList!=list) |
|
509 | if(this->brickList!=list) | |
509 | { |
|
510 | { | |
510 | this->brickList = list; |
|
511 | this->brickList = list; | |
511 | emit updateAvailableBrickCount(this->brickList); |
|
512 | emit updateAvailableBrickCount(this->brickList); | |
512 | } |
|
513 | } | |
513 | usleep(RMAPtimeout/2); |
|
514 | usleep(RMAPtimeout/2); | |
514 | } |
|
515 | } | |
515 | usleep(1000); |
|
516 | usleep(1000); | |
516 | } |
|
517 | } | |
517 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
518 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
518 | } |
|
519 | } | |
519 |
|
520 | |||
520 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
521 | bool stardundeeSPW_USB_Manager::connectBridge() | |
521 | { |
|
522 | { | |
522 | bool ret; |
|
523 | bool ret; | |
523 |
|
524 | |||
524 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) |
|
525 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) | |
525 | { |
|
526 | { | |
526 | ret = connectBridgeAsInterface(); |
|
527 | ret = connectBridgeAsInterface(); | |
527 | } |
|
528 | } | |
528 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) |
|
529 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) | |
529 | { |
|
530 | { | |
530 | ret = connectBridgeAsRouter(); |
|
531 | ret = connectBridgeAsRouter(); | |
531 | } |
|
532 | } | |
532 | else |
|
533 | else | |
533 | { |
|
534 | { | |
534 | ret = false; |
|
535 | ret = false; | |
535 | } |
|
536 | } | |
536 |
|
537 | |||
537 | return ret; |
|
538 | return ret; | |
538 | } |
|
539 | } | |
539 |
|
540 | |||
540 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() |
|
541 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() | |
541 | { |
|
542 | { | |
542 | this->handleMutex->lock(); |
|
543 | this->handleMutex->lock(); | |
543 | int status; |
|
544 | int status; | |
544 | U32 statusControl; |
|
545 | U32 statusControl; | |
545 | this->connected = false; |
|
546 | this->connected = false; | |
546 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
547 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
547 | { |
|
548 | { | |
548 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
549 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
549 | this->handleMutex->unlock(); |
|
550 | this->handleMutex->unlock(); | |
550 | return false; |
|
551 | return false; | |
551 | } |
|
552 | } | |
552 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
553 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
553 |
|
554 | |||
554 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
555 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
555 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
556 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
556 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
557 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
557 |
|
558 | |||
558 | // Set the path and return path to the device |
|
559 | // Set the path and return path to the device | |
559 | CFGSpaceWire_StackClear(); |
|
560 | CFGSpaceWire_StackClear(); | |
560 | CFGSpaceWire_AddrStackPush(0); |
|
561 | CFGSpaceWire_AddrStackPush(0); | |
561 | CFGSpaceWire_AddrStackPush(254); |
|
562 | CFGSpaceWire_AddrStackPush(254); | |
562 | CFGSpaceWire_RetAddrStackPush(254); |
|
563 | CFGSpaceWire_RetAddrStackPush(254); | |
563 | // set the base transmit rate to 100 MHz |
|
564 | // set the base transmit rate to 100 MHz | |
564 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
565 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
565 | if (status != CFG_TRANSFER_SUCCESS) |
|
566 | if (status != CFG_TRANSFER_SUCCESS) | |
566 | { |
|
567 | { | |
567 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
568 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
568 | this->handleMutex->unlock(); |
|
569 | this->handleMutex->unlock(); | |
569 | return false; |
|
570 | return false; | |
570 | } |
|
571 | } | |
571 | else |
|
572 | else | |
572 | { |
|
573 | { | |
573 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
574 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
574 | } |
|
575 | } | |
575 |
|
576 | |||
576 | // read the link status |
|
577 | // read the link status | |
577 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
578 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
578 | { |
|
579 | { | |
579 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
580 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
580 | this->handleMutex->unlock(); |
|
581 | this->handleMutex->unlock(); | |
581 | return false; |
|
582 | return false; | |
582 | } |
|
583 | } | |
583 | else |
|
584 | else | |
584 | { |
|
585 | { | |
585 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
586 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
586 |
|
587 | |||
587 | // Set the link status control register properties |
|
588 | // Set the link status control register properties | |
588 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
589 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
589 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
590 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
590 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
591 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
591 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
592 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
592 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
593 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
593 |
|
594 | |||
594 | // Set the link status control register |
|
595 | // Set the link status control register | |
595 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
596 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
596 | { |
|
597 | { | |
597 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
598 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
598 | this->handleMutex->unlock(); |
|
599 | this->handleMutex->unlock(); | |
599 | return false; |
|
600 | return false; | |
600 | } |
|
601 | } | |
601 | else |
|
602 | else | |
602 | { |
|
603 | { | |
603 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
604 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
604 | } |
|
605 | } | |
605 | } |
|
606 | } | |
606 |
|
607 | |||
607 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
608 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
608 | { |
|
609 | { | |
609 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
610 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
610 | this->handleMutex->unlock(); |
|
611 | this->handleMutex->unlock(); | |
611 | return false; |
|
612 | return false; | |
612 | } |
|
613 | } | |
613 | else |
|
614 | else | |
614 | { |
|
615 | { | |
615 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
616 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
616 | } |
|
617 | } | |
617 |
|
618 | |||
618 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
619 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
619 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
620 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
620 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
621 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
621 | this->handleMutex->unlock(); |
|
622 | this->handleMutex->unlock(); | |
622 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
623 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
623 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
624 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
624 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
625 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
625 | this->connected = true; |
|
626 | this->connected = true; | |
626 | return true; |
|
627 | return true; | |
627 | } |
|
628 | } | |
628 |
|
629 | |||
629 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() |
|
630 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() | |
630 | { |
|
631 | { | |
631 | // QMutexLocker mlock(&this->handleMutex); |
|
632 | // QMutexLocker mlock(&this->handleMutex); | |
632 | this->handleMutex->lock(); |
|
633 | this->handleMutex->lock(); | |
633 | int status; |
|
634 | int status; | |
634 | U32 statusControl; |
|
635 | U32 statusControl; | |
635 | unsigned int linkStatus1; |
|
636 | unsigned int linkStatus1; | |
636 | unsigned int linkStatus2; |
|
637 | unsigned int linkStatus2; | |
637 | unsigned char linkNumber; |
|
638 | unsigned char linkNumber; | |
638 | unsigned char deviceIsAnInterface; |
|
639 | unsigned char deviceIsAnInterface; | |
639 |
|
640 | |||
640 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
641 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
641 | { |
|
642 | { | |
642 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); |
|
643 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |
643 | this->handleMutex->unlock(); |
|
644 | this->handleMutex->unlock(); | |
644 | return false; |
|
645 | return false; | |
645 | } |
|
646 | } | |
646 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " |
|
647 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " | |
647 | + QString::number(this->selectedBrick)); |
|
648 | + QString::number(this->selectedBrick)); | |
648 |
|
649 | |||
649 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
650 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
650 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
651 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
651 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
652 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
652 |
|
653 | |||
653 | // Set the path and return path to the device |
|
654 | // Set the path and return path to the device | |
654 | // This affects just the operations performed by the Configuration Library and does not affect the packets |
|
655 | // This affects just the operations performed by the Configuration Library and does not affect the packets | |
655 | // sent and received using the driver API. |
|
656 | // sent and received using the driver API. | |
656 | CFGSpaceWire_StackClear(); |
|
657 | CFGSpaceWire_StackClear(); | |
657 | CFGSpaceWire_AddrStackPush(0); |
|
658 | CFGSpaceWire_AddrStackPush(0); | |
658 | CFGSpaceWire_AddrStackPush(254); |
|
659 | CFGSpaceWire_AddrStackPush(254); | |
659 | CFGSpaceWire_RetAddrStackPush(254); |
|
660 | CFGSpaceWire_RetAddrStackPush(254); | |
660 |
|
661 | |||
661 | // set the base transmit rate to 100 MHz |
|
662 | // set the base transmit rate to 100 MHz | |
662 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
663 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
663 | if (status != CFG_TRANSFER_SUCCESS) |
|
664 | if (status != CFG_TRANSFER_SUCCESS) | |
664 | { |
|
665 | { | |
665 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); |
|
666 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |
666 | } |
|
667 | } | |
667 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); |
|
668 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |
668 |
|
669 | |||
669 | //********************* |
|
670 | //********************* | |
670 | // LINK 1 CONFIGURATION |
|
671 | // LINK 1 CONFIGURATION | |
671 | linkNumber = 1; |
|
672 | linkNumber = 1; | |
672 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
673 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
673 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
674 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
674 | else |
|
675 | else | |
675 | { |
|
676 | { | |
676 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
677 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
677 |
|
678 | |||
678 | // Set the link status control register properties |
|
679 | // Set the link status control register properties | |
679 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
680 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
680 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
681 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
681 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
682 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
682 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
683 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
683 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
684 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
684 |
|
685 | |||
685 | // Set the link status control register |
|
686 | // Set the link status control register | |
686 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
687 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
687 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
688 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
688 | else |
|
689 | else | |
689 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); |
|
690 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); | |
690 | } |
|
691 | } | |
691 |
|
692 | |||
692 | //********************* |
|
693 | //********************* | |
693 | // LINK 2 CONFIGURATION |
|
694 | // LINK 2 CONFIGURATION | |
694 | linkNumber = 2; |
|
695 | linkNumber = 2; | |
695 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
696 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
696 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); |
|
697 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |
697 | else |
|
698 | else | |
698 | { |
|
699 | { | |
699 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); |
|
700 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |
700 |
|
701 | |||
701 | // Set the link status control register properties |
|
702 | // Set the link status control register properties | |
702 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
703 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
703 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
704 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
704 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
705 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
705 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
706 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
706 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
707 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
707 |
|
708 | |||
708 | // Set the link status control register |
|
709 | // Set the link status control register | |
709 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
710 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
710 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); |
|
711 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |
711 | else |
|
712 | else | |
712 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); |
|
713 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); | |
713 | } |
|
714 | } | |
714 |
|
715 | |||
715 | //*************************** |
|
716 | //*************************** | |
716 | // SET THE DEVICE AS A ROUTER |
|
717 | // SET THE DEVICE AS A ROUTER | |
717 | deviceIsAnInterface = 0; // 0 = router, 1 = interface |
|
718 | deviceIsAnInterface = 0; // 0 = router, 1 = interface | |
718 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) |
|
719 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) | |
719 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); |
|
720 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); | |
720 | else |
|
721 | else | |
721 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); |
|
722 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); | |
722 |
|
723 | |||
723 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 |
|
724 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 | |
724 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 |
|
725 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 | |
725 |
|
726 | |||
726 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only |
|
727 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only | |
727 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
728 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
728 |
|
729 | |||
729 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); |
|
730 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |
730 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); |
|
731 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |
731 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); |
|
732 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |
732 |
|
733 | |||
733 | //************ |
|
734 | //************ | |
734 | // test Link 1 and Link 2 |
|
735 | // test Link 1 and Link 2 | |
735 | linkStatus1 = getLinkStatus(0x01); |
|
736 | linkStatus1 = getLinkStatus(0x01); | |
736 | linkStatus2 = getLinkStatus(0x02); |
|
737 | linkStatus2 = getLinkStatus(0x02); | |
737 | this->handleMutex->unlock(); |
|
738 | this->handleMutex->unlock(); | |
738 |
|
739 | |||
739 | if ((linkStatus1==1) || (linkStatus2==1)) |
|
740 | if ((linkStatus1==1) || (linkStatus2==1)) | |
740 | { |
|
741 | { | |
741 | initializeTimecodeGeneration(); |
|
742 | initializeTimecodeGeneration(); | |
742 | this->connected=true; |
|
743 | this->connected=true; | |
743 | return true; |
|
744 | return true; | |
744 | } |
|
745 | } | |
745 | else |
|
746 | else | |
746 | { |
|
747 | { | |
747 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); |
|
748 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |
748 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); |
|
749 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |
749 | starDundeeStatusQueryDialog->exec(); |
|
750 | starDundeeStatusQueryDialog->exec(); | |
750 | this->connected = false; |
|
751 | this->connected = false; | |
751 | return false; |
|
752 | return false; | |
752 | } |
|
753 | } | |
753 | } |
|
754 | } | |
754 |
|
755 | |||
755 | void stardundeeSPW_USB_Manager::initDialog( void ) |
|
756 | void stardundeeSPW_USB_Manager::initDialog( void ) | |
756 | { |
|
757 | { | |
757 | // STAR DUNDEE STATUS QUERY DIALOG |
|
758 | // STAR DUNDEE STATUS QUERY DIALOG | |
758 | starDundeeStatusQueryDialog = new QDialog; |
|
759 | starDundeeStatusQueryDialog = new QDialog; | |
759 | starDundeeStatusQueryDialogLayout = new QGridLayout; |
|
760 | starDundeeStatusQueryDialogLayout = new QGridLayout; | |
760 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); |
|
761 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); | |
761 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); |
|
762 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); | |
762 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); |
|
763 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); | |
763 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); |
|
764 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); | |
764 | statusLink1 = new QLabel(tr("Link 1 status code: -")); |
|
765 | statusLink1 = new QLabel(tr("Link 1 status code: -")); | |
765 | statusLink2 = new QLabel(tr("Link 2 status code: -")); |
|
766 | statusLink2 = new QLabel(tr("Link 2 status code: -")); | |
766 |
|
767 | |||
767 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); |
|
768 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); | |
768 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); |
|
769 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); | |
769 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); |
|
770 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); | |
770 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); |
|
771 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); | |
771 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); |
|
772 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); | |
772 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); |
|
773 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); | |
773 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); |
|
774 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); | |
774 | } |
|
775 | } | |
775 |
|
776 | |||
776 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) |
|
777 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) | |
777 | { |
|
778 | { | |
778 | U32 routingTableEntry; |
|
779 | U32 routingTableEntry; | |
779 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber |
|
780 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber | |
780 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) |
|
781 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) | |
781 | { |
|
782 | { | |
782 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); |
|
783 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); | |
783 | } |
|
784 | } | |
784 | // Build the routing table entry |
|
785 | // Build the routing table entry | |
785 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, |
|
786 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, | |
786 | dwOutputPorts, // route out of port dwOutputPorts |
|
787 | dwOutputPorts, // route out of port dwOutputPorts | |
787 | bDelHead, // header deletion is enabled [1] or disabled [0] |
|
788 | bDelHead, // header deletion is enabled [1] or disabled [0] | |
788 | 0); // priority normal |
|
789 | 0); // priority normal | |
789 | // Set the routing table entry for logical address tableEntry |
|
790 | // Set the routing table entry for logical address tableEntry | |
790 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
791 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
791 | { |
|
792 | { | |
792 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); |
|
793 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); | |
793 | } |
|
794 | } | |
794 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); |
|
795 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); | |
795 | return 1; |
|
796 | return 1; | |
796 | } |
|
797 | } | |
797 |
|
798 | |||
798 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) |
|
799 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) | |
799 | { |
|
800 | { | |
800 | U32 routingTableEntry, outputPorts; |
|
801 | U32 routingTableEntry, outputPorts; | |
801 | char enabled, delHead, priority; |
|
802 | char enabled, delHead, priority; | |
802 | int portNum; |
|
803 | int portNum; | |
803 |
|
804 | |||
804 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); |
|
805 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); | |
805 | // Read the routing table entry |
|
806 | // Read the routing table entry | |
806 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) |
|
807 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) | |
807 | { |
|
808 | { | |
808 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); |
|
809 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); | |
809 | } |
|
810 | } | |
810 | else |
|
811 | else | |
811 | { |
|
812 | { | |
812 | // Display the routing table entry properties |
|
813 | // Display the routing table entry properties | |
813 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); |
|
814 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); | |
814 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); |
|
815 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); | |
815 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); |
|
816 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); | |
816 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); |
|
817 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); | |
817 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); |
|
818 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); | |
818 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); |
|
819 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); | |
819 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); |
|
820 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); | |
820 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); |
|
821 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); | |
821 | for (portNum = 0; portNum < 32; portNum++) |
|
822 | for (portNum = 0; portNum < 32; portNum++) | |
822 | { |
|
823 | { | |
823 | if (outputPorts & (1 << portNum)) |
|
824 | if (outputPorts & (1 << portNum)) | |
824 | { |
|
825 | { | |
825 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); |
|
826 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); | |
826 | } |
|
827 | } | |
827 | } |
|
828 | } | |
828 | } |
|
829 | } | |
829 |
|
830 | |||
830 | return 1; |
|
831 | return 1; | |
831 | } |
|
832 | } | |
832 |
|
833 | |||
833 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() |
|
834 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() | |
834 | { |
|
835 | { | |
835 | U32 dwTickEnableStatus; |
|
836 | U32 dwTickEnableStatus; | |
836 | U32 rtr_clk_freq; |
|
837 | U32 rtr_clk_freq; | |
837 |
|
838 | |||
838 | // (1) RESET |
|
839 | // (1) RESET | |
839 | if (!USBSpaceWire_TC_Reset(hDevice)) |
|
840 | if (!USBSpaceWire_TC_Reset(hDevice)) | |
840 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); |
|
841 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); | |
841 |
|
842 | |||
842 | // (2) Clear the tick enable register |
|
843 | // (2) Clear the tick enable register | |
843 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) |
|
844 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) | |
844 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); |
|
845 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); | |
845 | else |
|
846 | else | |
846 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); |
|
847 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); | |
847 |
|
848 | |||
848 | // (3) get the tick status |
|
849 | // (3) get the tick status | |
849 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); |
|
850 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); | |
850 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); |
|
851 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); | |
851 |
|
852 | |||
852 | // (4) enable external timecode selection |
|
853 | // (4) enable external timecode selection | |
853 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
854 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
854 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); |
|
855 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); | |
855 |
|
856 | |||
856 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
857 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
857 |
|
858 | |||
858 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); |
|
859 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); | |
859 |
|
860 | |||
860 | //************************************************** |
|
861 | //************************************************** | |
861 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
862 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
862 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) |
|
863 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) | |
863 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
864 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
864 | } |
|
865 | } | |
865 |
|
866 | |||
866 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) |
|
867 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) | |
867 | { |
|
868 | { | |
868 | U32 statusControl, errorStatus, portType; |
|
869 | U32 statusControl, errorStatus, portType; | |
869 | U32 linkStatus, operatingSpeed, outputPortConnection; |
|
870 | U32 linkStatus, operatingSpeed, outputPortConnection; | |
870 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; |
|
871 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; | |
871 |
|
872 | |||
872 | // Read the link status control register |
|
873 | // Read the link status control register | |
873 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
874 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) | |
874 | { |
|
875 | { | |
875 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); |
|
876 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); | |
876 | } |
|
877 | } | |
877 | else |
|
878 | else | |
878 | { |
|
879 | { | |
879 | // Display the link status control register properties |
|
880 | // Display the link status control register properties | |
880 | CFGSpaceWire_LSPortType(statusControl, &portType); |
|
881 | CFGSpaceWire_LSPortType(statusControl, &portType); | |
881 | if (portType == CFG_CONFIGURATION_PORT) |
|
882 | if (portType == CFG_CONFIGURATION_PORT) | |
882 | { |
|
883 | { | |
883 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); |
|
884 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); | |
884 | } |
|
885 | } | |
885 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) |
|
886 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) | |
886 | { |
|
887 | { | |
887 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); |
|
888 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); | |
888 | } |
|
889 | } | |
889 | else |
|
890 | else | |
890 | { |
|
891 | { | |
891 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); |
|
892 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); | |
892 | } |
|
893 | } | |
893 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); |
|
894 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); | |
894 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); |
|
895 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); | |
895 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); |
|
896 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); | |
896 | CFGSpaceWire_LSIsStart(statusControl, &isStart); |
|
897 | CFGSpaceWire_LSIsStart(statusControl, &isStart); | |
897 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); |
|
898 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); | |
898 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); |
|
899 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); | |
899 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); |
|
900 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); | |
900 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); |
|
901 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); | |
901 | } |
|
902 | } | |
902 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) |
|
903 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) | |
903 | +" is " + dwLinkStatusQString[linkStatus]); |
|
904 | +" is " + dwLinkStatusQString[linkStatus]); | |
904 | if (linkStatus == 5) |
|
905 | if (linkStatus == 5) | |
905 | { |
|
906 | { | |
906 | return 1; |
|
907 | return 1; | |
907 | } |
|
908 | } | |
908 | else return 0; |
|
909 | else return 0; | |
909 | } |
|
910 | } | |
910 |
|
911 | |||
911 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
912 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
912 | { |
|
913 | { | |
913 | this->handleMutex->lock(); |
|
914 | this->handleMutex->lock(); | |
914 | USBSpaceWire_Close(hDevice); // Close the device |
|
915 | USBSpaceWire_Close(hDevice); // Close the device | |
915 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
916 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
916 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
917 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
917 | this->handleMutex->unlock(); |
|
918 | this->handleMutex->unlock(); | |
918 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
919 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
919 | this->RMAP_pending_transaction_IDs.clear(); |
|
920 | this->RMAP_pending_transaction_IDs.clear(); | |
920 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
921 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
921 | this->RMAP_AnswersMtx->lock(); |
|
922 | this->RMAP_AnswersMtx->lock(); | |
922 | this->RMAP_Answers.clear(); |
|
923 | this->RMAP_Answers.clear(); | |
923 | this->RMAP_AnswersMtx->unlock(); |
|
924 | this->RMAP_AnswersMtx->unlock(); | |
924 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
925 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
925 | return true; |
|
926 | return true; | |
926 | } |
|
927 | } | |
927 |
|
928 | |||
928 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
929 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
929 | { |
|
930 | { | |
930 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
931 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
931 | int ID=0; |
|
932 | int ID=0; | |
932 | bool found=true; |
|
933 | bool found=true; | |
933 | while(ID<511) |
|
934 | while(ID<511) | |
934 | { |
|
935 | { | |
935 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
936 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
936 | { |
|
937 | { | |
937 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
938 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
938 | } |
|
939 | } | |
939 | if(found==true)break; |
|
940 | if(found==true)break; | |
940 | ID++; |
|
941 | ID++; | |
941 | found = true; |
|
942 | found = true; | |
942 | } |
|
943 | } | |
943 | if(found) |
|
944 | if(found) | |
944 | { |
|
945 | { | |
945 | RMAP_pending_transaction_IDs.append(ID); |
|
946 | RMAP_pending_transaction_IDs.append(ID); | |
946 | } |
|
947 | } | |
947 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
948 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
948 | return ID; |
|
949 | return ID; | |
949 | } |
|
950 | } | |
950 |
|
951 | |||
951 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
952 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
952 | { |
|
953 | { | |
953 | QTime timeout; |
|
954 | QTime timeout; | |
954 | *buffer=NULL; |
|
955 | *buffer=NULL; | |
955 | int count=0; |
|
956 | int count=0; | |
956 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
957 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
957 | timeout.start(); |
|
958 | timeout.start(); | |
958 | while (*buffer==NULL) |
|
959 | while (*buffer==NULL) | |
959 | { |
|
960 | { | |
960 | this->RMAP_AnswersMtx->lock(); |
|
961 | this->RMAP_AnswersMtx->lock(); | |
961 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
962 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
962 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
963 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
963 | for(int i=0;i<RMAP_Answers.count();i++) |
|
964 | for(int i=0;i<RMAP_Answers.count();i++) | |
964 | { |
|
965 | { | |
965 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
966 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); | |
966 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
967 | if(RMAP_Answers[i]->transactionID==transactionID) | |
967 | { |
|
968 | { | |
968 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
969 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
969 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
970 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
970 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
971 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
971 | { |
|
972 | { | |
972 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
973 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
973 | { |
|
974 | { | |
974 | RMAP_pending_transaction_IDs.removeAt(j); |
|
975 | RMAP_pending_transaction_IDs.removeAt(j); | |
975 | } |
|
976 | } | |
976 | } |
|
977 | } | |
977 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
978 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
978 | *buffer = RMAP_Answers[i]->data; |
|
979 | *buffer = RMAP_Answers[i]->data; | |
979 | count = RMAP_Answers[i]->len; |
|
980 | count = RMAP_Answers[i]->len; | |
980 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
981 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
981 | RMAP_Answers.removeAt(i); |
|
982 | RMAP_Answers.removeAt(i); | |
982 | delete tmp; |
|
983 | delete tmp; | |
983 | } |
|
984 | } | |
984 | } |
|
985 | } | |
985 | this->RMAP_AnswersMtx->unlock(); |
|
986 | this->RMAP_AnswersMtx->unlock(); | |
986 | //if no answer found in the stack wait until a new packet is pushed |
|
987 | //if no answer found in the stack wait until a new packet is pushed | |
987 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
988 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
988 | if(*buffer==NULL) |
|
989 | if(*buffer==NULL) | |
989 | { |
|
990 | { | |
990 | while (0==this->RMAP_AnswersSem->available()) |
|
991 | while (0==this->RMAP_AnswersSem->available()) | |
991 | { |
|
992 | { | |
992 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
993 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
993 | if(timeout.elapsed()>=RMAPtimeout) |
|
994 | if(timeout.elapsed()>=RMAPtimeout) | |
994 | { |
|
995 | { | |
995 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
996 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
996 | return -1; |
|
997 | return -1; | |
997 | } |
|
998 | } | |
998 | usleep(1000); |
|
999 | usleep(1000); | |
999 | } |
|
1000 | } | |
1000 | this->RMAP_AnswersSem->acquire(); |
|
1001 | this->RMAP_AnswersSem->acquire(); | |
1001 | } |
|
1002 | } | |
1002 | } |
|
1003 | } | |
1003 | return count; |
|
1004 | return count; | |
1004 | } |
|
1005 | } | |
1005 |
|
1006 | |||
1006 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
1007 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
1007 | { |
|
1008 | { | |
1008 | char protocoleIdentifier; |
|
1009 | char protocoleIdentifier; | |
1009 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; |
|
1010 | USB_SPACEWIRE_STATUS result=TRANSFER_ERROR_NOT_FOUND; | |
1010 | USB_SPACEWIRE_ID pIdentifier; |
|
1011 | USB_SPACEWIRE_ID pIdentifier; | |
1011 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
1012 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
1012 | this->handleMutex->lock(); |
|
1013 | this->handleMutex->lock(); | |
1013 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
1014 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
1014 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
1015 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
1015 | this->handleMutex->unlock(); |
|
1016 | this->handleMutex->unlock(); | |
1016 | if (result != TRANSFER_SUCCESS) |
|
1017 | if (result != TRANSFER_SUCCESS) | |
1017 | { |
|
1018 | { | |
1018 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
1019 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
1019 | return false; |
|
1020 | return false; | |
1020 | } |
|
1021 | } | |
1021 | else |
|
1022 | else | |
1022 | { |
|
1023 | { | |
1023 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link |
|
1024 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link | |
1024 | // read the protocole identifier |
|
1025 | // read the protocole identifier | |
1025 | protocoleIdentifier = packet[2]; |
|
1026 | protocoleIdentifier = packet[2]; | |
1026 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) |
|
1027 | if (protocoleIdentifier == SPW_PROTO_ID_CCSDS) | |
1027 | emit ccsdsPacketTransmittedToSpw(); |
|
1028 | emit ccsdsPacketTransmittedToSpw(); | |
1028 |
|
1029 | |||
1029 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
1030 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
1030 | } |
|
1031 | } | |
1031 | // this->handleMutex->unlock(); |
|
1032 | // this->handleMutex->unlock(); | |
1032 | return true; |
|
1033 | return true; | |
1033 | } |
|
1034 | } | |
1034 |
|
1035 | |||
1035 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
1036 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
1036 | { |
|
1037 | { | |
1037 | char* packetbuffer = (char*)malloc(len); |
|
1038 | char* packetbuffer = (char*)malloc(len); | |
1038 | memcpy(packetbuffer,packet,len); |
|
1039 | memcpy(packetbuffer,packet,len); | |
1039 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
1040 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
1040 | RMAP_AnswersMtx->lock(); |
|
1041 | RMAP_AnswersMtx->lock(); | |
1041 | RMAP_Answers.append(RMPAPpacket); |
|
1042 | RMAP_Answers.append(RMPAPpacket); | |
1042 | RMAP_AnswersMtx->unlock(); |
|
1043 | RMAP_AnswersMtx->unlock(); | |
1043 | } |
|
1044 | } | |
1044 |
|
1045 | |||
1045 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) |
|
1046 | void stardundeeSPW_USB_Manager::sendTimecodePeriodically( bool onOff ) | |
1046 | { |
|
1047 | { | |
1047 | if (onOff == true) |
|
1048 | if (onOff == true) | |
1048 | { |
|
1049 | { | |
1049 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) |
|
1050 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 1, 1)) | |
1050 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); |
|
1051 | SocExplorerEngine::message(this->plugin,"Could not enable auto tick-in"); | |
1051 | } |
|
1052 | } | |
1052 | else |
|
1053 | else | |
1053 | { |
|
1054 | { | |
1054 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) |
|
1055 | if (!USBSpaceWire_TC_EnableAutoTickIn(hDevice, 0, 0)) | |
1055 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); |
|
1056 | SocExplorerEngine::message(this->plugin,"Could not disable auto tick-in"); | |
1056 | } |
|
1057 | } | |
1057 | } |
|
1058 | } | |
1058 |
|
1059 | |||
1059 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) |
|
1060 | int stardundeeSPW_USB_Manager::getLinkNumber( void ) | |
1060 | { |
|
1061 | { | |
1061 | return this->linkNumber; |
|
1062 | return this->linkNumber; | |
1062 | } |
|
1063 | } | |
1063 |
|
1064 | |||
1064 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) |
|
1065 | void stardundeeSPW_USB_Manager::setTimecodeFrequency(double requestedFrequency) | |
1065 | { |
|
1066 | { | |
1066 | U32 rtr_clk_freq=0; |
|
1067 | U32 rtr_clk_freq=0; | |
1067 | U32 freqCount=0; |
|
1068 | U32 freqCount=0; | |
1068 | double freqCountInDouble=0.0; |
|
1069 | double freqCountInDouble=0.0; | |
1069 | double currentFrequency=0.0; |
|
1070 | double currentFrequency=0.0; | |
1070 |
|
1071 | |||
1071 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); |
|
1072 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |
1072 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; |
|
1073 | freqCountInDouble = ((double) rtr_clk_freq) / requestedFrequency; | |
1073 | freqCount = (unsigned int) freqCountInDouble; |
|
1074 | freqCount = (unsigned int) freqCountInDouble; | |
1074 |
|
1075 | |||
1075 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); |
|
1076 | currentFrequency = ((double) rtr_clk_freq) / ((double) freqCount); | |
1076 |
|
1077 | |||
1077 | //************************************************** |
|
1078 | //************************************************** | |
1078 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount |
|
1079 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |
1079 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) |
|
1080 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, freqCount) ) | |
1080 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); |
|
1081 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |
1081 | else |
|
1082 | else | |
1082 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" |
|
1083 | SocExplorerEngine::message(this->plugin,"tick frequency set to " + QString::number(currentFrequency) +" Hz" | |
1083 | + " (freqCount set to " + QString::number(freqCount) + ")" ); |
|
1084 | + " (freqCount set to " + QString::number(freqCount) + ")" ); | |
1084 | } |
|
1085 | } | |
1085 |
|
1086 | |||
1086 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) |
|
1087 | void stardundeeSPW_USB_Manager::sendOneTimecode( unsigned char nTimein ) | |
1087 | { |
|
1088 | { | |
1088 | // enable external timecode selection |
|
1089 | // enable external timecode selection | |
1089 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) |
|
1090 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,1)) | |
1090 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); |
|
1091 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** enable external timecode selection"); | |
1091 |
|
1092 | |||
1092 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) |
|
1093 | if (!USBSpaceWire_TC_PerformTickIn( hDevice, nTimein) ) | |
1093 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); |
|
1094 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** ERR *** Could not send the requested timecode: " + QString::number(nTimein) ); | |
1094 | else |
|
1095 | else | |
1095 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); |
|
1096 | SocExplorerEngine::message( this->plugin,"sendOneTimecode *** OK *** timecode sent " + QString::number(nTimein) ); | |
1096 |
|
1097 | |||
1097 | // disable external timecode selection |
|
1098 | // disable external timecode selection | |
1098 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) |
|
1099 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |
1099 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); |
|
1100 | SocExplorerEngine::message(this->plugin,"sendOneTimecode *** ERR *** disable external timecode selection"); | |
1100 | } |
|
1101 | } | |
1101 |
|
1102 | |||
1102 |
|
1103 |
@@ -1,161 +1,163 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #ifndef STARDUNDEESPW_USB_H |
|
22 | #ifndef STARDUNDEESPW_USB_H | |
23 | #define STARDUNDEESPW_USB_H |
|
23 | #define STARDUNDEESPW_USB_H | |
24 |
|
24 | |||
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <spw_usb_api.h> |
|
26 | //#include <spw_usb_api.h> | |
27 | #include <spw_config_library.h> |
|
27 | //#include <spw_config_library.h> | |
|
28 | ||||
|
29 | #include "fakestardundeespwusb_lib.h" | |||
28 | #include <socexplorerplugin.h> |
|
30 | #include <socexplorerplugin.h> | |
29 | #include <abstractspwbridge.h> |
|
31 | #include <abstractspwbridge.h> | |
30 | #include <QThread> |
|
32 | #include <QThread> | |
31 | #include <QMutex> |
|
33 | #include <QMutex> | |
32 | #include <QSemaphore> |
|
34 | #include <QSemaphore> | |
33 | #include <QGridLayout> |
|
35 | #include <QGridLayout> | |
34 | #include <QPushButton> |
|
36 | #include <QPushButton> | |
35 | #include <QComboBox> |
|
37 | #include <QComboBox> | |
36 | #include <QLabel> |
|
38 | #include <QLabel> | |
37 | #include "stardundeegui.h" |
|
39 | #include "stardundeegui.h" | |
38 |
|
40 | |||
39 | #define BRICK_IS_SET_AS_AN_INTERFACE true |
|
41 | #define BRICK_IS_SET_AS_AN_INTERFACE true | |
40 | #define BRICK_IS_SET_AS_A_ROUTER false |
|
42 | #define BRICK_IS_SET_AS_A_ROUTER false | |
41 |
|
43 | |||
42 | class stardundeeSPW_USB_Manager: public QThread |
|
44 | class stardundeeSPW_USB_Manager: public QThread | |
43 | { |
|
45 | { | |
44 | Q_OBJECT |
|
46 | Q_OBJECT | |
45 | public: |
|
47 | public: | |
46 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
48 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
47 | ~stardundeeSPW_USB_Manager(); |
|
49 | ~stardundeeSPW_USB_Manager(); | |
48 | void run(); |
|
50 | void run(); | |
49 | bool connectBridge(); |
|
51 | bool connectBridge(); | |
50 | bool connectBridgeAsInterface(); |
|
52 | bool connectBridgeAsInterface(); | |
51 | bool connectBridgeAsRouter(); |
|
53 | bool connectBridgeAsRouter(); | |
52 | void initDialog( void ); |
|
54 | void initDialog( void ); | |
53 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); |
|
55 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); | |
54 | unsigned int getRoutingTableEntry(int tableEntry); |
|
56 | unsigned int getRoutingTableEntry(int tableEntry); | |
55 | void initializeTimecodeGeneration(); |
|
57 | void initializeTimecodeGeneration(); | |
56 | void setTimecodeFrequency(double requestedFrequency); |
|
58 | void setTimecodeFrequency(double requestedFrequency); | |
57 | unsigned int getLinkStatus(unsigned char link); |
|
59 | unsigned int getLinkStatus(unsigned char link); | |
58 | bool disconnectBridge(); |
|
60 | bool disconnectBridge(); | |
59 | int getRMAPtransactionID(); |
|
61 | int getRMAPtransactionID(); | |
60 | int getRMAPanswer(int transactionID,char** buffer); |
|
62 | int getRMAPanswer(int transactionID,char** buffer); | |
61 | bool sendPacket(char* packet,int size); |
|
63 | bool sendPacket(char* packet,int size); | |
62 |
|
64 | |||
63 | signals: |
|
65 | signals: | |
64 | void updateAvailableBrickCount(int count); |
|
66 | void updateAvailableBrickCount(int count); | |
65 | void emitPacket(char* packet,int size); |
|
67 | void emitPacket(char* packet,int size); | |
66 | void bytesReceivedFromSpw( unsigned int ); |
|
68 | void bytesReceivedFromSpw( unsigned int ); | |
67 | void bytesTransmittedToSpw( unsigned int); |
|
69 | void bytesTransmittedToSpw( unsigned int); | |
68 | void ccsdsPacketTransmittedToSpw( void ); |
|
70 | void ccsdsPacketTransmittedToSpw( void ); | |
69 |
|
71 | |||
70 | public slots: |
|
72 | public slots: | |
71 | void sendTimecodePeriodically( bool onOff ); |
|
73 | void sendTimecodePeriodically( bool onOff ); | |
72 | void sendOneTimecode(unsigned char nTimein); |
|
74 | void sendOneTimecode(unsigned char nTimein); | |
73 | int getLinkNumber( void ); |
|
75 | int getLinkNumber( void ); | |
74 |
|
76 | |||
75 | private: |
|
77 | private: | |
76 | QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; |
|
78 | QMutex *handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; | |
77 | QSemaphore* RMAP_AnswersSem; |
|
79 | QSemaphore* RMAP_AnswersSem; | |
78 | void pushRmapPacket(char* packet,int len); |
|
80 | void pushRmapPacket(char* packet,int len); | |
79 | star_device_handle hDevice; |
|
81 | star_device_handle hDevice; | |
80 | socexplorerplugin* plugin; |
|
82 | socexplorerplugin* plugin; | |
81 | bool connected; |
|
83 | bool connected; | |
82 | char* SPWPacketBuff; |
|
84 | char* SPWPacketBuff; | |
83 | QList<RMAP_Answer*> RMAP_Answers; |
|
85 | QList<RMAP_Answer*> RMAP_Answers; | |
84 | QList<int> RMAP_pending_transaction_IDs; |
|
86 | QList<int> RMAP_pending_transaction_IDs; | |
85 |
|
87 | |||
86 | QLabel *starDundeeStatusQueryDialogLabel; |
|
88 | QLabel *starDundeeStatusQueryDialogLabel; | |
87 | QPushButton *starDundeeStatusQueryRetryButton; |
|
89 | QPushButton *starDundeeStatusQueryRetryButton; | |
88 | QPushButton *starDundeeStatusQueryAbortButton; |
|
90 | QPushButton *starDundeeStatusQueryAbortButton; | |
89 | QLabel *statusLink1; |
|
91 | QLabel *statusLink1; | |
90 | QLabel *statusLink2; |
|
92 | QLabel *statusLink2; | |
91 | QPushButton *starDundeeStatusQueryContinueButton; |
|
93 | QPushButton *starDundeeStatusQueryContinueButton; | |
92 | QDialog *starDundeeStatusQueryDialog; |
|
94 | QDialog *starDundeeStatusQueryDialog; | |
93 | QGridLayout *starDundeeStatusQueryDialogLayout; |
|
95 | QGridLayout *starDundeeStatusQueryDialogLayout; | |
94 |
|
96 | |||
95 | public: |
|
97 | public: | |
96 | int selectedBrick; |
|
98 | int selectedBrick; | |
97 | int linkNumber; |
|
99 | int linkNumber; | |
98 | int brickList; |
|
100 | int brickList; | |
99 | int linkSpeed; |
|
101 | int linkSpeed; | |
100 | int sourceLogicalAddress; |
|
102 | int sourceLogicalAddress; | |
101 | int destinationLogicalAddress; |
|
103 | int destinationLogicalAddress; | |
102 | int destinationKey; |
|
104 | int destinationKey; | |
103 | int RMAPtimeout; |
|
105 | int RMAPtimeout; | |
104 | double timecodeFrequency; |
|
106 | double timecodeFrequency; | |
105 | bool interfaceMode; // 1 => interface mode, 0 => router mode |
|
107 | bool interfaceMode; // 1 => interface mode, 0 => router mode | |
106 | }; |
|
108 | }; | |
107 |
|
109 | |||
108 | class stardundeeSPW_USB : public abstractSpwBridge |
|
110 | class stardundeeSPW_USB : public abstractSpwBridge | |
109 | { |
|
111 | { | |
110 | Q_OBJECT |
|
112 | Q_OBJECT | |
111 | public: |
|
113 | public: | |
112 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); |
|
114 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); | |
113 | ~stardundeeSPW_USB(); |
|
115 | ~stardundeeSPW_USB(); | |
114 |
|
116 | |||
115 | signals: |
|
117 | signals: | |
116 |
|
118 | |||
117 | void setRmapTimeout(const QString & timeout); |
|
119 | void setRmapTimeout(const QString & timeout); | |
118 | void SelectBrick(int brickIndex); |
|
120 | void SelectBrick(int brickIndex); | |
119 | void SelectLinkNumber(int linkIndex); |
|
121 | void SelectLinkNumber(int linkIndex); | |
120 | void SelectLinkSpeed(int linkSpeed); |
|
122 | void SelectLinkSpeed(int linkSpeed); | |
121 | void SetDestinationKey(const QString & destKey); |
|
123 | void SetDestinationKey(const QString & destKey); | |
122 | void SetSourceAddress(const QString & address); |
|
124 | void SetSourceAddress(const QString & address); | |
123 | void SetDestinationAddress(const QString & address); |
|
125 | void SetDestinationAddress(const QString & address); | |
124 | void SetRmapTimeout(const QString & timeout); |
|
126 | void SetRmapTimeout(const QString & timeout); | |
125 | void SetTimecodeFrequency( double ); |
|
127 | void SetTimecodeFrequency( double ); | |
126 | void SetBrickAsAnInterface( bool ); |
|
128 | void SetBrickAsAnInterface( bool ); | |
127 | void SetBrickAsARouter( bool ); |
|
129 | void SetBrickAsARouter( bool ); | |
128 | int GetAvailableBrickCount( void ); |
|
130 | int GetAvailableBrickCount( void ); | |
129 | unsigned int GetNbPacketsTransmittedToSpw( void ); |
|
131 | unsigned int GetNbPacketsTransmittedToSpw( void ); | |
130 | unsigned int GetNbCCSDSPacketsTransmittedToSpw( void ); |
|
132 | unsigned int GetNbCCSDSPacketsTransmittedToSpw( void ); | |
131 | void BytesReceivedFromSpw( unsigned int ); |
|
133 | void BytesReceivedFromSpw( unsigned int ); | |
132 | void BytesTransmittedToSpw( unsigned int ); |
|
134 | void BytesTransmittedToSpw( unsigned int ); | |
133 | void CCSDSPacketTransmittedToSpw( void ); |
|
135 | void CCSDSPacketTransmittedToSpw( void ); | |
134 | void StartSendingTimecodes( bool ); |
|
136 | void StartSendingTimecodes( bool ); | |
135 | void SendOneTimecode( unsigned char ); |
|
137 | void SendOneTimecode( unsigned char ); | |
136 | int GetLinkNumber(); |
|
138 | int GetLinkNumber(); | |
137 |
|
139 | |||
138 | public slots: |
|
140 | public slots: | |
139 | void toggleBridgeConnection(); |
|
141 | void toggleBridgeConnection(); | |
140 | bool connectBridge(); |
|
142 | bool connectBridge(); | |
141 | bool disconnectBridge(); |
|
143 | bool disconnectBridge(); | |
142 | int pushRMAPPacket(char* packet,int size); |
|
144 | int pushRMAPPacket(char* packet,int size); | |
143 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
145 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
144 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
146 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
145 | void brickSelectionChanged(int brickIndex); |
|
147 | void brickSelectionChanged(int brickIndex); | |
146 | void linkNumberSelectionChanged(int linkIndex); |
|
148 | void linkNumberSelectionChanged(int linkIndex); | |
147 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
149 | void linkSpeedSelectionChanged(const QString & linkSpeed); | |
148 | void sourceLogicalAddressChanged(const QString & destKey); |
|
150 | void sourceLogicalAddressChanged(const QString & destKey); | |
149 | void destinationAddressChanged(const QString & rmapaddress); |
|
151 | void destinationAddressChanged(const QString & rmapaddress); | |
150 | void brickModeChanged( bool interfaceMode ); |
|
152 | void brickModeChanged( bool interfaceMode ); | |
151 | void destinationKeyChanged(const QString & key); |
|
153 | void destinationKeyChanged(const QString & key); | |
152 | void rmapTimeoutChanged(const QString & timeout); |
|
154 | void rmapTimeoutChanged(const QString & timeout); | |
153 | void sendPacketComingFromTCPServer(char *packet, int size); |
|
155 | void sendPacketComingFromTCPServer(char *packet, int size); | |
154 | void timecodeFrequencyChanged(const QString &frequency); |
|
156 | void timecodeFrequencyChanged(const QString &frequency); | |
155 | void startSendingTimecodes( bool onOff ); |
|
157 | void startSendingTimecodes( bool onOff ); | |
156 | private: |
|
158 | private: | |
157 | void makeGUI(socexplorerplugin *parent); |
|
159 | void makeGUI(socexplorerplugin *parent); | |
158 | stardundeeSPW_USB_Manager* manager; |
|
160 | stardundeeSPW_USB_Manager* manager; | |
159 | }; |
|
161 | }; | |
160 |
|
162 | |||
161 | #endif // STARDUNDEESPW_USB_H |
|
163 | #endif // STARDUNDEESPW_USB_H |
@@ -1,181 +1,183 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "spwplugin.h" |
|
23 | #include "spwplugin.h" | |
24 | #include "stardundeespw_usb.h" |
|
24 | #include "stardundeespw_usb.h" | |
25 | #include "gr_esb_bridge.h" |
|
25 | #include "gr_esb_bridge.h" | |
26 | #include <socexplorerproxy.h> |
|
26 | #include <socexplorerproxy.h> | |
|
27 | #include "fakestardundeespwusb_lib.h" | |||
27 |
|
28 | |||
28 |
|
29 | |||
29 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) | |
30 | { |
|
31 | { | |
31 | Q_UNUSED(parent) |
|
32 | Q_UNUSED(parent) | |
|
33 | FakeStarDundeeSpwUSB_Lib::resolve(); | |||
32 | this->bridge = NULL; |
|
34 | this->bridge = NULL; | |
33 | this->scanDone = false; |
|
35 | this->scanDone = false; | |
34 | // this->pyObject = new spwPyWrapper(this); |
|
36 | // this->pyObject = new spwPyWrapper(this); | |
35 | this->tcpServer = new SpwTcpPacketServer(this); |
|
37 | this->tcpServer = new SpwTcpPacketServer(this); | |
36 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
38 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); | |
37 | this->bridgeSelector = new QComboBox(this); |
|
39 | this->bridgeSelector = new QComboBox(this); | |
38 | this->mainTabWidgt = new QTabWidget(this); |
|
40 | this->mainTabWidgt = new QTabWidget(this); | |
39 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
41 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); | |
40 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
42 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); | |
41 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
43 | this->mainLayout = new QGridLayout(this->mainGroupBox); | |
42 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
44 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); | |
43 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
45 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); | |
44 | this->setWidget(this->mainTabWidgt); |
|
46 | this->setWidget(this->mainTabWidgt); | |
45 | this->bridgeSelector->addItem("none"); |
|
47 | this->bridgeSelector->addItem("none"); | |
46 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
48 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); | |
47 | this->bridgeSelector->addItem("GR-ESB"); |
|
49 | this->bridgeSelector->addItem("GR-ESB"); | |
48 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
50 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); | |
49 | connect(this,SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
51 | connect(this,SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); | |
50 | connect(this,SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
52 | connect(this,SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); | |
51 | connect(this,SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
53 | connect(this,SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); | |
52 | connect(this,SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); |
|
54 | connect(this,SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); | |
53 | connect(this,SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); |
|
55 | connect(this,SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); | |
54 | } |
|
56 | } | |
55 |
|
57 | |||
56 |
|
58 | |||
57 | spwplugin::~spwplugin() |
|
59 | spwplugin::~spwplugin() | |
58 | { |
|
60 | { | |
59 |
|
61 | |||
60 | } |
|
62 | } | |
61 |
|
63 | |||
62 |
|
64 | |||
63 |
|
65 | |||
64 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
66 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
65 | { |
|
67 | { | |
66 | if(Connected) |
|
68 | if(Connected) | |
67 | { |
|
69 | { | |
68 | return bridge->Read(Value,count,address); |
|
70 | return bridge->Read(Value,count,address); | |
69 | } |
|
71 | } | |
70 | return 0; |
|
72 | return 0; | |
71 | } |
|
73 | } | |
72 |
|
74 | |||
73 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
75 | void spwplugin::bridgeSelectionChanged(const QString &text) | |
74 | { |
|
76 | { | |
75 | printf("test"); |
|
77 | printf("test"); | |
76 | if(text=="none") |
|
78 | if(text=="none") | |
77 | { |
|
79 | { | |
78 | if(this->bridge!=NULL) |
|
80 | if(this->bridge!=NULL) | |
79 | { |
|
81 | { | |
80 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
82 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
81 | this->disconnect(this,SLOT(setConnected(bool))); |
|
83 | this->disconnect(this,SLOT(setConnected(bool))); | |
82 | delete this->bridge; |
|
84 | delete this->bridge; | |
83 | this->bridge= NULL; |
|
85 | this->bridge= NULL; | |
84 | } |
|
86 | } | |
85 | } |
|
87 | } | |
86 | if(text=="STAR-Dundee Spw USB Brick") |
|
88 | if(text=="STAR-Dundee Spw USB Brick") | |
87 | { |
|
89 | { | |
88 | if(this->bridge!=NULL) |
|
90 | if(this->bridge!=NULL) | |
89 | { |
|
91 | { | |
90 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
92 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
91 | this->disconnect(this,SLOT(setConnected(bool))); |
|
93 | this->disconnect(this,SLOT(setConnected(bool))); | |
92 | delete this->bridge; |
|
94 | delete this->bridge; | |
93 | } |
|
95 | } | |
94 | this->bridge = new stardundeeSPW_USB(this); |
|
96 | this->bridge = new stardundeeSPW_USB(this); | |
95 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
97 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
96 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
98 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
97 | connect(this,SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
99 | connect(this,SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); | |
98 | connect(this,SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
100 | connect(this,SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); | |
99 | connect(this,SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
101 | connect(this,SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); | |
100 | connect(this,SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString))); |
|
102 | connect(this,SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString))); | |
101 | connect(this,SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString))); |
|
103 | connect(this,SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString))); | |
102 | connect(this,SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
104 | connect(this,SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); | |
103 | connect(this,SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
105 | connect(this,SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); | |
104 | connect(this,SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
106 | connect(this,SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); | |
105 | connect(this,SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
107 | connect(this,SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); | |
106 | connect(this,SIGNAL(StarDundeeGetAvailableBrickCount()), |
|
108 | connect(this,SIGNAL(StarDundeeGetAvailableBrickCount()), | |
107 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); |
|
109 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); | |
108 | connect(this,SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()), |
|
110 | connect(this,SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()), | |
109 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw())); |
|
111 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw())); | |
110 | connect(this,SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()), |
|
112 | connect(this,SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()), | |
111 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw())); |
|
113 | ((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw())); | |
112 | connect(this,SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber())); |
|
114 | connect(this,SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber())); | |
113 | connect(this,SIGNAL(StarDundeeSetBrickAsAninterface(bool)), |
|
115 | connect(this,SIGNAL(StarDundeeSetBrickAsAninterface(bool)), | |
114 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); |
|
116 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); | |
115 | connect(this,SIGNAL(StarDundeeSetBrickAsARouter(bool)), |
|
117 | connect(this,SIGNAL(StarDundeeSetBrickAsARouter(bool)), | |
116 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); |
|
118 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); | |
117 | connect(this,SIGNAL(StarDundeeStartTimecodes(bool)), |
|
119 | connect(this,SIGNAL(StarDundeeStartTimecodes(bool)), | |
118 | ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool))); |
|
120 | ((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool))); | |
119 | connect(this,SIGNAL(StarDundeeSetTimecodeFrequency(double)), |
|
121 | connect(this,SIGNAL(StarDundeeSetTimecodeFrequency(double)), | |
120 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double))); |
|
122 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double))); | |
121 | connect(this,SIGNAL(StarDundeeSendOneTimecode(unsigned char)), |
|
123 | connect(this,SIGNAL(StarDundeeSendOneTimecode(unsigned char)), | |
122 | ((stardundeeSPW_USB*)bridge),SIGNAL(SendOneTimecode(unsigned char))); |
|
124 | ((stardundeeSPW_USB*)bridge),SIGNAL(SendOneTimecode(unsigned char))); | |
123 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); |
|
125 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); | |
124 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); |
|
126 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); | |
125 | } |
|
127 | } | |
126 | if(text=="GR-ESB") |
|
128 | if(text=="GR-ESB") | |
127 | { |
|
129 | { | |
128 | if(this->bridge!=NULL) |
|
130 | if(this->bridge!=NULL) | |
129 | { |
|
131 | { | |
130 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
132 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
131 | this->disconnect(this,SLOT(setConnected(bool))); |
|
133 | this->disconnect(this,SLOT(setConnected(bool))); | |
132 | delete this->bridge; |
|
134 | delete this->bridge; | |
133 | } |
|
135 | } | |
134 | this->bridge = new GR_ESB_bridge(this); |
|
136 | this->bridge = new GR_ESB_bridge(this); | |
135 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
137 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
136 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
138 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
137 | } |
|
139 | } | |
138 | } |
|
140 | } | |
139 |
|
141 | |||
140 |
|
142 | |||
141 | void spwplugin::selectBridge(const QString &text) |
|
143 | void spwplugin::selectBridge(const QString &text) | |
142 | { |
|
144 | { | |
143 |
|
145 | |||
144 | if(text=="none") |
|
146 | if(text=="none") | |
145 | { |
|
147 | { | |
146 | this->bridgeSelector->setCurrentIndex(0); |
|
148 | this->bridgeSelector->setCurrentIndex(0); | |
147 | } |
|
149 | } | |
148 | if(text=="STAR-Dundee Spw USB Brick") |
|
150 | if(text=="STAR-Dundee Spw USB Brick") | |
149 | { |
|
151 | { | |
150 | this->bridgeSelector->setCurrentIndex(1); |
|
152 | this->bridgeSelector->setCurrentIndex(1); | |
151 | } |
|
153 | } | |
152 | } |
|
154 | } | |
153 |
|
155 | |||
154 | void spwplugin::setConnected(bool connected) |
|
156 | void spwplugin::setConnected(bool connected) | |
155 | { |
|
157 | { | |
156 | this->bridgeSelector->setDisabled(connected); |
|
158 | this->bridgeSelector->setDisabled(connected); | |
157 | this->Connected = connected; |
|
159 | this->Connected = connected; | |
158 | emit activateSig(connected); |
|
160 | emit activateSig(connected); | |
159 | if(!this->scanDone) |
|
161 | if(!this->scanDone) | |
160 | { |
|
162 | { | |
161 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
163 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
162 | this->scanDone=true; |
|
164 | this->scanDone=true; | |
163 | } |
|
165 | } | |
164 | } |
|
166 | } | |
165 |
|
167 | |||
166 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
168 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
167 | { |
|
169 | { | |
168 | if(Connected) |
|
170 | if(Connected) | |
169 | { |
|
171 | { | |
170 | return bridge->Write(Value,count,address); |
|
172 | return bridge->Write(Value,count,address); | |
171 | } |
|
173 | } | |
172 | return 0; |
|
174 | return 0; | |
173 | } |
|
175 | } | |
174 |
|
176 | |||
175 |
|
177 | |||
176 |
|
178 | |||
177 |
|
179 | |||
178 |
|
180 | |||
179 |
|
181 | |||
180 |
|
182 | |||
181 |
|
183 |
@@ -1,88 +1,93 | |||||
1 | # |
|
1 | # | |
2 | # Project created by QtCreator 2011-09-20T08:15:30 |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
3 | # |
|
3 | # | |
4 | #------------------------------------------------- |
|
4 | #------------------------------------------------- | |
5 |
|
5 | |||
6 | CONFIG += socexplorerplugin |
|
6 | CONFIG += socexplorerplugin | |
7 | QT += network webkit |
|
7 | QT += network webkit | |
8 | greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets |
|
8 | greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets | |
9 |
|
9 | |||
|
10 | QMAKE_CXXFLAGS += -std=c++11 | |||
|
11 | QMAKE_CFLAGS += -std=c++11 | |||
|
12 | ||||
10 | win32:CONFIG += dll |
|
13 | win32:CONFIG += dll | |
11 | win32:CONFIG -= static |
|
14 | win32:CONFIG -= static | |
12 | VERSION=0.6.0 |
|
15 | VERSION=0.6.0 | |
13 | TARGET = spwplugin |
|
16 | TARGET = spwplugin | |
14 | DEFINES += PLUGIN=spwplugin |
|
17 | DEFINES += PLUGIN=spwplugin | |
15 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" |
|
18 | DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" | |
16 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" |
|
19 | DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" | |
17 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org; Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\" |
|
20 | DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org; Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\" | |
18 | DEFINES += driver_Description="\"\\\"This plugin allows you to use spacewire's RMAP protocol with Stardundee USB brick v1"\\\"\" |
|
21 | DEFINES += driver_Description="\"\\\"This plugin allows you to use spacewire's RMAP protocol with Stardundee USB brick v1"\\\"\" | |
19 | DEFINES += driver_can_be_root=1 |
|
22 | DEFINES += driver_can_be_root=1 | |
20 | DEFINES += driver_can_be_child=0 |
|
23 | DEFINES += driver_can_be_child=0 | |
21 | DEFINES += driver_VID=0 |
|
24 | DEFINES += driver_VID=0 | |
22 | DEFINES += driver_PID=0 |
|
25 | DEFINES += driver_PID=0 | |
23 |
|
26 | |||
24 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ |
|
27 | STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ | |
25 |
|
28 | |||
26 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ |
|
29 | LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ | |
27 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so |
|
30 | $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so | |
28 |
|
31 | |||
29 | INCLUDEPATH += \ |
|
32 | INCLUDEPATH += \ | |
30 | $${PWD} \ |
|
33 | $${PWD} \ | |
31 | $$STARTDUNDEEPATH/inc \ |
|
34 | $$STARTDUNDEEPATH/inc \ | |
32 | StarDundee \ |
|
35 | StarDundee \ | |
33 | SpwTcpPacketServer \ |
|
36 | SpwTcpPacketServer \ | |
34 | GR-ESB |
|
37 | GR-ESB | |
35 |
|
38 | |||
36 | HEADERS += \ |
|
39 | HEADERS += \ | |
37 | spwplugin.h \ |
|
40 | spwplugin.h \ | |
38 | StarDundee/stardundeespw_usb.h \ |
|
41 | StarDundee/stardundeespw_usb.h \ | |
39 | abstractspwbridge.h \ |
|
42 | abstractspwbridge.h \ | |
40 | spw.h \ |
|
43 | spw.h \ | |
41 | StarDundee/stardundeegui.h \ |
|
44 | StarDundee/stardundeegui.h \ | |
42 | SpwTcpPacketServer/spwtcppacketserver.h \ |
|
45 | SpwTcpPacketServer/spwtcppacketserver.h \ | |
43 | GR-ESB/gr_esb_bridge.h \ |
|
46 | GR-ESB/gr_esb_bridge.h \ | |
44 | GR-ESB/gr_esb_ui.h \ |
|
47 | GR-ESB/gr_esb_ui.h \ | |
45 | SpwTcpPacketServer/incomingpacketparser.h |
|
48 | SpwTcpPacketServer/incomingpacketparser.h \ | |
|
49 | StarDundee/fakestardundeespwusb_lib.h | |||
46 |
|
50 | |||
47 |
|
51 | |||
48 | SOURCES += \ |
|
52 | SOURCES += \ | |
49 | spwplugin.cpp \ |
|
53 | spwplugin.cpp \ | |
50 | StarDundee/stardundeespw_usb.cpp \ |
|
54 | StarDundee/stardundeespw_usb.cpp \ | |
51 | abstractspwbridge.cpp \ |
|
55 | abstractspwbridge.cpp \ | |
52 | StarDundee/stardundeegui.cpp \ |
|
56 | StarDundee/stardundeegui.cpp \ | |
53 | SpwTcpPacketServer/spwtcppacketserver.cpp \ |
|
57 | SpwTcpPacketServer/spwtcppacketserver.cpp \ | |
54 | GR-ESB/gr_esb_bridge.cpp \ |
|
58 | GR-ESB/gr_esb_bridge.cpp \ | |
55 | GR-ESB/gr_esb_ui.cpp \ |
|
59 | GR-ESB/gr_esb_ui.cpp \ | |
56 | SpwTcpPacketServer/incomingpacketparser.cpp |
|
60 | SpwTcpPacketServer/incomingpacketparser.cpp \ | |
|
61 | StarDundee/fakestardundeespwusb_lib.cpp | |||
57 |
|
62 | |||
58 | FORMS += \ |
|
63 | FORMS += \ | |
59 | StarDundee/stardundeeGUI.ui \ |
|
64 | StarDundee/stardundeeGUI.ui \ | |
60 | SpwTcpPacketServer/spwtcppacketserver.ui \ |
|
65 | SpwTcpPacketServer/spwtcppacketserver.ui \ | |
61 | GR-ESB/gr_esb_ui.ui |
|
66 | GR-ESB/gr_esb_ui.ui | |
62 |
|
67 | |||
63 | RESOURCES += \ |
|
68 | RESOURCES += \ | |
64 | spwRessources.qrc |
|
69 | spwRessources.qrc | |
65 |
|
70 | |||
66 |
|
71 | |||
67 |
|
72 | |||
68 |
|
73 | |||
69 |
|
74 | |||
70 |
|
75 | |||
71 |
|
76 | |||
72 |
|
77 | |||
73 |
|
78 | |||
74 |
|
79 | |||
75 |
|
80 | |||
76 |
|
81 | |||
77 |
|
82 | |||
78 |
|
83 | |||
79 |
|
84 | |||
80 |
|
85 | |||
81 |
|
86 | |||
82 |
|
87 | |||
83 |
|
88 | |||
84 |
|
89 | |||
85 |
|
90 | |||
86 |
|
91 | |||
87 |
|
92 | |||
88 |
|
93 |
General Comments 0
You need to be logged in to leave comments.
Login now