usbtmc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. #ifndef _USBTMC_H_
  2. #define _USBTMC_H_
  3. #include "usbtmc_main.h"
  4. // =======================================================================================================
  5. // see "Gpib Programming Tutorial Programming a GPIB based instrument designed at the Electronics Group PDF"
  6. //
  7. //
  8. #define PUDI (udi->usbtmcGpib.StateMachine)
  9. #define _STB (PUDI.STB)
  10. #define _ESR (PUDI.ESR)
  11. #define _ESE (PUDI.ESE)
  12. #define _SRE (PUDI.SRE)
  13. //#define GPIB_SETONCOMPLETE_OPC() (PUDI.SETOPC=1) // ôëàã òîãî, ÷òî íóæíî äåðíóòü OPC áèò ïî çàâåðøåíèè. äëÿ êîììàíäû *OPC
  14. //#define GPIB_CLRONCOMPLETE_OPC() (PUDI.SETOPC=0)
  15. #define USB_MAX_ERROR_QUEUE RAM_ERRORQUEUE_SIZE // bytes. íóæíî ó÷èòûâàòü ÷òî íà óïðàâëþùèå ñòðóêòóðû î÷åðåäè òîæå íóæíî ìåòî
  16. #define STATE_MACHINE() (USBTMC_StateMachine_Modified( &PUDI ))
  17. // --------- -- Bits of STB Register --------------
  18. #define STB_MAV 4 // Message Available
  19. #define GPIB_SET_MAV() ((_STB |= (1<<STB_MAV)) && STATE_MACHINE() )
  20. #define GPIB_CLR_MAV() ((_STB &= (~(1<<STB_MAV))) && STATE_MACHINE() )
  21. #define GPIB_GET_MAV() (_STB & (1<<STB_MAV) )
  22. #define STB_EAV 2 // Error/Event Available
  23. #define GPIB_SET_EAV() ((_STB |= (1<<STB_EAV)) && STATE_MACHINE() )
  24. #define GPIB_CLR_EAV() ((_STB &= (~(1<<STB_EAV))) && STATE_MACHINE() )
  25. #define GPIB_GET_EAV() (_STB & (1<<STB_EAV) )
  26. #define STB_ESB 5 // Standart Event status Bit
  27. #define GPIB_SET_ESB() ((_STB |= (1<<STB_ESB)) && STATE_MACHINE() )
  28. #define GPIB_CLR_ESB() ((_STB &= (~(1<<STB_ESB))) && STATE_MACHINE() )
  29. #define GPIB_GET_ESB() (_STB & (1<<STB_ESB) )
  30. #define STB_RQS_MSS 6 // Service Request or Master Summary Status (MSS)
  31. #define GPIB_SET_RQS() ((_STB |= (1<<STB_RQS_MSS)) && STATE_MACHINE() )
  32. #define GPIB_CLR_RQS__() ((_STB &= (~(1<<STB_RQS_MSS))))
  33. #define GPIB_CLR_RQS() ( GPIB_CLR_RQS__() && STATE_MACHINE() )
  34. #define GPIB_SET_MSS() ((_STB |= (1<<STB_RQS_MSS)) && STATE_MACHINE() )
  35. #define GPIB_CLR_MSS__() ((_STB &= (~(1<<STB_RQS_MSS))))
  36. #define GPIB_CLR_MSS() ( GPIB_CLR_RQS__() && STATE_MACHINE() )
  37. //#define GPIB_GET_RQS() ( (_STB & STB_RQS) && (GPIB_CLR_RQS__() || TRUE) )
  38. #define GPIB_GET_RQS() ((_STB & (1<<STB_RQS_MSS)) )
  39. #define GPIB_GET_MSS() ((_STB & (1<<STB_RQS_MSS)) )
  40. #define GPIB_CLR_ESR() (_ESR = 0, STATE_MACHINE(), TRUE)
  41. #define GPIB_GET_ESR() (_ESR)
  42. // ---------- -- Bits of ESR ----------------------
  43. #define ESR_PWN 7 // Power On cycle
  44. #define GPIB_SET_PWN() ((_ESR |= (1<<ESR_PWN)) && STATE_MACHINE() )
  45. #define GPIB_CLR_PWN() ((_ESR &= (~(1<<ESR_PWN))) && STATE_MACHINE() )
  46. #define GPIB_GET_PWN() (_ESR & (1<<ESR_PWN) )
  47. #define ESR_URQ 6 // User request
  48. #define GPIB_SET_URQ() ((_ESR |= (1<<ESR_URQ)) && STATE_MACHINE() )
  49. #define GPIB_CLR_URQ() ((_ESR &= (~(1<<ESR_URQ))) && STATE_MACHINE() )
  50. #define GPIB_GET_URQ() (_ESR & (1<<ESR_URQ) )
  51. #define ESR_CME 5 // Command Error
  52. #define GPIB_SET_CME() ((_ESR |= (1<<ESR_CME)) && STATE_MACHINE() )
  53. #define GPIB_CLR_CME() ((_ESR &= (~(1<<ESR_CME))) && STATE_MACHINE() )
  54. #define GPIB_GET_CME() (_ESR & (1<<ESR_CME) )
  55. #define ESR_EXE 4 // Execution Error
  56. #define GPIB_SET_EXE() ((_ESR |= (1<<ESR_EXE)) && STATE_MACHINE() )
  57. #define GPIB_CLR_EXE() ((_ESR &= (~(1<<ESR_EXE))) && STATE_MACHINE() )
  58. #define GPIB_GET_EXE() (_ESR & (1<<ESR_EXE) )
  59. #define ESR_DDE 3 // Dev Dependent Error
  60. #define GPIB_SET_DDE() ((_ESR |= (1<<ESR_DDE)) && STATE_MACHINE() )
  61. #define GPIB_CLR_DDE() ((_ESR &= (~(1<<ESR_DDE))) && STATE_MACHINE() )
  62. #define GPIB_GET_DDE() (_ESR & (1<<ESR_DDE) )
  63. #define ESR_QRE 2 // Query Error
  64. #define GPIB_SET_QRE() ((_ESR |= (1<<ESR_QRE)) && STATE_MACHINE() )
  65. #define GPIB_CLR_QRE() ((_ESR &= (~(1<<ESR_QRE))) && STATE_MACHINE() )
  66. #define GPIB_GET_QRE() (_ESR & (1<<ESR_QRE) )
  67. #define ESR_RQE 1 // Request Error
  68. #define GPIB_SET_RQE() ((_ESR |= (1<<ESR_RQE)) && STATE_MACHINE() )
  69. #define GPIB_CLR_RQE() ((_ESR &= (~(1<<ESR_RQE))) && STATE_MACHINE() )
  70. #define GPIB_GET_RQE() (_ESR & (1<<ESR_RQE) )
  71. #define ESR_OPC 0 // Operation Complete
  72. #define GPIB_SET_OPC() ((_ESR |= (1<<ESR_OPC)) && STATE_MACHINE() )
  73. #define GPIB_CLR_OPC() ((_ESR &= (~(1<<ESR_OPC))) && STATE_MACHINE() )
  74. #define GPIB_GET_OPC() (_ESR & (1<<ESR_OPC) )
  75. typedef enum
  76. {
  77. errClass_Autodetect, // autodetect the class error by error code
  78. //------------------
  79. errClass_Command, // IEEE 488.2, 11.5.1.1.4
  80. /*
  81. Command Errors are detected by the Parser, see 6.1.6. This event bit indicates that one of the following events has
  82. occurred:
  83. 1) An IEEE 488.2 syntax error has been detected by the parser. That is, a controller-to-device message was
  84. received that is in violation of this standard. Possible violations include a data element that violates the device
  85. listening formats or whose type is unacceptable to the device, see 7.1.2.2.
  86. 2) A semantic error has occurred indicating that an unrecognized header was received. Unrecognized headers
  87. include incorrect device-specific headers and incorrect or unimplemented IEEE 488.2 common commands,
  88. see Section 10.. A valid macro label, which is not the same as a device-specific <COMMAND PROGRAM
  89. HEADER> or <QUERY PROGRAM HEADER>, that is received by a device with its macros disabled shall
  90. be considered an unrecognized header.
  91. 3) A Group Execute Trigger (GET) was entered into the Input Buffer inside of a <PROGRAM MESSAGE>, see
  92. 6.1.6.1.1 and 6.4.3.
  93. When a device detects a Command Error, parser synchronization may be lost. See 6.1.6.1.1 for discussion of parser
  94. action after a Command Error.
  95. */
  96. errClass_Execution, // IEEE 488.2, 11.5.1.1.5
  97. /*
  98. Execution Errors are detected by the Execution Control Block, see 6.1.7. This event bit indicates that:
  99. 1) A <PROGRAM DATA> element following a header was evaluated by the device as outside of its legal input
  100. range or is otherwise inconsistent with the device's capabilities.
  101. 2) A valid program message could not be properly executed due to some device condition.
  102. Following an Execution Error, the device shall continue parsing the input stream. The device may continue executing
  103. parsed commands or the device may discard parsed commands. Devices shall resume execution of parsed commands
  104. after a <PROGRAM MESSAGE TERMINATOR>. It is recommended that this choice be documented.
  105. Execution Errors shall be reported by the device after rounding and expression evaluation operations have taken place.
  106. Rounding a numeric data element, for example, shall not be reported as an Execution Error.
  107. Events that generate Execution Errors shall not also generate Command Errors, Query Errors, or Device-Specific
  108. Errors. See other bit definitions in this section.
  109. NOTE — The device designer has the responsibility to ensure that devices incorporate effective checking to prevent execution of
  110. commands after an Execution Error that could result in undesireable conditions. Documentation should indicate any
  111. known conditions that cannot be checked by the device.
  112. */
  113. errClass_Device, // IEEE 488.2, 11.5.1.1.6
  114. /*
  115. Device-Specific Errors are detected by Device Functions, see 6.1.8. This event bit indicates that an error has occurred
  116. that is neither a Command Error, a Query Error, nor an Execution Error.
  117. A Device-Specific Error is any executed device operation that did not properly complete due to some condition, such
  118. as overrange.
  119. Following a Device-Specific Error, the device shall continue to process the input stream.
  120. Device-Specific Errors are to be used at the discretion of the device designer.
  121. Events that generate Device-Specific Errors shall not also generate Command Errors, Query Errors, or Execution Errors.
  122. */
  123. errClass_Query, // IEEE 488.2, 11.5.1.1.7
  124. /*
  125. Query Errors are detected by the Output Queue Control, see 6.1.10. This event bit indicates that either
  126. 1) An attempt is being made to read data from the Output Queue when no output is either present or pending, or
  127. 2) Data in the Output Queue has been lost.
  128. See 6.5.7 for a complete description.
  129. The Query Error bit shall not be set to report any other condition. Events that generate Query Errors shall not also
  130. generate Execution Errors, Command Errors, or Device-Specific Errors.
  131. */
  132. }
  133. GPIB_ErrorClass_t;
  134. // ---------------------------------------------------------------------------------------------------------
  135. // ------ Questinable status
  136. #define GPIB_QUES_VOLTage 0
  137. #define GPIB_QUES_CURRent 1
  138. #define GPIB_QUES_TIME 2
  139. #define GPIB_QUES_POWer 3
  140. #define GPIB_QUES_TEMPerature 4
  141. #define GPIB_QUES_FREQuency 5
  142. #define GPIB_QUES_PHASe 6
  143. #define GPIB_QUES_MODulation 7
  144. #define GPIB_QUES_CALibration 8
  145. #define GPIB_QUES_INSTrumentSummary 13
  146. #define GPIB_QUES_COMWarinig 14
  147. // -------- Operation Status
  148. #define GPIB_OPER_CALibration 0
  149. #define GPIB_OPER_SETTing 1
  150. #define GPIB_OPER_RANGing 2
  151. #define GPIB_OPER_SWEeping 3
  152. #define GPIB_OPER_MEASuring 4
  153. #define GPIB_OPER_WTRGSummary 5
  154. #define GPIB_OPER_WARMSummary 6
  155. #define GPIB_OPER_CORRecting 7
  156. #define GPIB_OPER_INSTSummary 13
  157. #define GPIB_OPER_PROGRunning 14
  158. #define MIN(A1,B2) ((A1<B2)?A1:B2)
  159. #define MAX(A2,B1) ((A2>B1)?A2:B1)
  160. extern const __root char * GPIBErrors[];
  161. #define GPIB_ERROR_NOERROR 0
  162. // Size of IDN string is only 72
  163. #define MAX_USBTMC_IDNSTRING_SIZE 71
  164. // ---------------------------------------------------------------------------------------------------------
  165. // ============================================= MsgID =============================================================================================================================================
  166. // --------------- All macroses are defined appropriate USBTMC spec. rev. 1.0, page 6
  167. #define DEV_DEP_MSG_OUT 0x01 // - The USBTMC message is a USBTMC device dependent command message.
  168. #define DEV_DEP_MSG_IN 0x02 // - The USBTMC message in a USBTMC response message to the REQUEST_DEV_DEP_MSG_IN
  169. #define REQUEST_DEV_DEP_MSG_IN 0x02 // - The USBTMC message is a USBTMC command message that requests the device to send a USBTMC response message on the Bulk-IN endpoint.
  170. #define VENDOR_SPECIFIC_OUT 0x7E // - The USBTMC message in a USBTMC vendor specific command message.
  171. #define REQUEST_VENDOR_SPECIFIC_IN 0x7F // - The USBTMC message in a USBTMC command message that requests the device sto send a vendor specific USBTMC response message on the Bulk-IN endpoint
  172. #define VENDOR_SPECIFIC_IN 0x7F // - The USBTMC message is a USBTMC response message to the REQUEST_VENDOR_SPECIFIC_IN
  173. // See USB488 spec, rev 1.0, 2003, page 4, table 1
  174. #define TRIGGER 0x80
  175. // ===================================== macro: bits in respond GET_CAPABILITES ===================================================================================================================
  176. #define USBTMC_SUPPORT__LISTEN_ONLY 0
  177. #define USBTMC_SUPPORT__TALK_ONLY 1
  178. #define USBTMC_SUPPORT__INDICATOR_PULSE 2
  179. #define USBTMC_SUPPORT__TERMCHAR 0
  180. #define USBTMC_EOM_INDEX 1
  181. #define USBTMC_BITMAP_EOM 0x01 // mask
  182. // =========================================== USBTMC Control-EP-Protocol Requests ================================================================================================================
  183. // see "USBTMC spec., rev. 1.0, 2003": "page 18":"Table 15"
  184. #define INITIATE_ABORT_BULK_OUT 0x01 // Aborts a bulk-out TRANSFER
  185. #define CHECK_ABORT_BULK_OUT_STATUS 0x02 // returns the status of the previously sent INITIATE_ABORT_BULK_OUT request
  186. #define INITIATE_ABORT_BULK_IN 0x03 // Aborts a bulk-in TRANSFER
  187. #define CHECK_ABORT_BULK_IN_STATUS 0x04 // returns the status of the previously sent INITIATE_ABORT_BULK_IN request
  188. #define INITIATE_CLEAR 0x05 // Clear all previously send pending and unprocessed Bulk-Out USBTMC message content and clears all pending Bulk-In transfers from the USBTMC interface
  189. #define CHECK_CLEAR_STATUS 0x06 // Returns the status of the previously sent INITIATE_CLEAR request
  190. #define GET_CAPABILITES 0x07 // Returns attributes and capabilites of the USBTMC interface
  191. #define INDICATOR_PULSE 0x40 // A mechanism to turn on an activity indicator for identification purposes. The device indicate whether or not it support this requesrt in the GET_CAPABILITES response packet
  192. #define READ_STATUS_BYTE 0x80 // Returns the IEEE 488 status byte
  193. #define REN_CONTROL 0xA0 // Mechanism to enable or disable local controls on a device
  194. #define GO_TO_LOCAL 0xA1 // Mechanism to enable local controls on a device
  195. #define LOCAL_LOCKOUT 0xA2 // Mechanism to disable local controls on a device
  196. // =========================================== USBTMC Control-EP-Protocol Status codes ============================================================================================================
  197. // see "USBTMC spec., rev. 1.0, 2003": "page 19":"Table 16"
  198. #define STATUS_SUCCESS 0x01
  199. #define STATUS_PENDING 0x02 // This status is valid if a device has recieved a USBTMC split transaction CHECK_STATUS request and th request is still being processed
  200. #define STATUS_FAILED 0x80 // Failure, unspecified reason, and a more specified USBTMC_status is not defined
  201. #define STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 // this status is valid if a device has recieved an INITIATE_ABORT_BULK_OUT or INITIATE_ABORT_BULK_IN request and the specified transfer to abort is not in progress
  202. #define STATUS_SPLIT_NOT_IN_PROGRESS 0x82 // this status is valid if the device recieved a CHECK_STATUS request ans the device is not processing an INITIATE request
  203. #define STATUS_SPLIT_IN_PROGRESS 0x83 // this status is valid if the device recieved a new class-specific request and the device is still processing and INITIATE
  204. #define STATUS_INTERRUPT_IN_BUSY 0x20 // this status is valid if the device recieved READ_STATUS_BYTE request, the USB488 interface has as INterrupt_IN endpoint, and the device is unable to queue the response packe on INTerrupt_IN endpoint because the FIFO is full.
  205. // ================================================================================================================================================================================================
  206. // see "USBTMC spec. rev 1.0, 2003": "page 7":"Table 3", "page 9":"Table 4", "page 9":"Table 5", "page 10":"Table 6"
  207. // ñòðóêòóðà _USBTMC_COMMAND_MESSAGE
  208. //
  209. // +---------------------[4]---------------------------+------------[1]-------+---------------------[3]-----------------------+
  210. // | TransferSize [4] | bmTransferAttributes | Reserved |
  211. // +---------------------------------------------------+----------------------+-----------------------------------------------+
  212. //
  213. // +---------------------[4]---------------------------+------------[1]-------+---------[1]---+-------------[2]---------------+
  214. // | TransferSize [4] | bmTransferAttributes | TermChar | Reserved |
  215. // +---------------------------------------------------+----------------------+---------------+-------------------------------+
  216. //
  217. // +---------------------[4]---------------------------+--------------------------------[4]-----------------------------------+
  218. // | TransferSize [4] | Reserved |
  219. // +---------------------------------------------------+----------------------------------------------------------------------+
  220. struct _USBTMC_RESPOND_MESSAGE
  221. {
  222. DWORD TransferSize; // -- Total number of USBTMC message data bytes to be sent in this USB transfer.
  223. // This does not include the number of bytes in this Bulk-Out header or aligment
  224. // bytes. Sent least significant bytes first, most significant bytes last. TransferSize must be >0
  225. //-----------
  226. union{
  227. BYTE Reserved2[4]; // -- Reserved in VENDOR_SPECIFIC_IN request. Must be 0
  228. //-------------
  229. struct{
  230. BYTE bmTransferAttributes; // -- Bitmap:
  231. // ---# DEV_DEP_MSG_IN ------------------------------------------------------------------------------------------------------------------
  232. // D0 -- EOM bit: ( see "USBTMC spec. rev 1.0, 2003": "page 7" )
  233. // # EOM bit = 1 -- The last USBTMC message data byte in this transfer is the last byte of the USBTMC message.
  234. // # EOM bit = 0 -- The last USBTMC message data byte in this transfer is NOT the last byte of the USBTMC message.
  235. // D1 -- Multiple bit:
  236. // # bit == 1 -- All of the following are true:
  237. // 1. The USBTMC interface supports TermChar.
  238. // 2. The bmTransferAttributes.TermCharEnabled bit was set in the REQUEST_DEV_DEP_MSG_IN.
  239. // 3. The last USBTMC message data byte in this transfer matches the TermChar in REQUEST_DEV_DEP_MSG_IN
  240. // # bit == 0 -- Overwise
  241. // D2-D7 -- Reserved. Must be 0.
  242. BYTE Reserved0[3]; // -- Reserved in DEV_DEP_MSG_IN request. Must be 0
  243. //------------
  244. };
  245. //-----------
  246. };
  247. };
  248. struct _USBTMC_COMMAND_MESSAGE
  249. {
  250. DWORD TransferSize; // -- Total number of USBTMC message data bytes to be sent in this USB transfer.
  251. // This does not include the number of bytes in this Bulk-Out header or aligment
  252. // bytes. Sent least significant bytes first, most significant bytes last. TransferSize must be >0
  253. //-----------
  254. union{
  255. BYTE Reserved2[4]; // -- Reserved in VENDOR_SPECIFIC_OUT request. Must be 0
  256. //-------------
  257. struct{
  258. BYTE bmTransferAttributes; // -- Bitmap:
  259. // ---# DEV_DEP_MSG_OUT ------------------------------------------------------------------------------------------------------------------
  260. // D0 -- EOM bit: ( see "USBTMC spec. rev 1.0, 2003": "page 7" )
  261. // # EOM bit = 1 -- The last USBTMC message data byte in this transfer is the last byte of the USBTMC message.
  262. // # EOM bit = 0 -- The last USBTMC message data byte in this transfer is NOT the last byte of the USBTMC message.
  263. // D1-D7 -- Reserved. Must be 0.
  264. // ---# REQUEST_DEV_DEP_MSG_OUT ----------------------------------------------------------------------------------------------------------
  265. // D0 -- Must be 0
  266. // D1 -- TermCharEnabled: ( see "USBTMC spec. rev 1.0, 2003": "page 9" )
  267. // # TermCharEnabled bit = 1 -- The Bulk-IN trnasfer must terminate on the specified TermChar.
  268. // The host may only set this bit if the USBTMC interface indicates it supports TermChar in the GET_CAPABILITES response packet
  269. // # TermCharEnabled bit = 0 -- The device must ignore TermChar
  270. //-----------
  271. union {
  272. BYTE Reserved0[3]; // -- Reserved in DEV_DEP_MSG_OUT request. Must be 0
  273. //--------------
  274. struct{
  275. BYTE TermChar; // -- If bmbmTransferAttributes.D1 == 1, TermChar is an 8-bin value representing a termination character. If supported, the device must terminate the Bulk-In transfer after this character is sent.
  276. BYTE Reserved1[2]; // -- Reserved in REQUEST_DEV_DEP_MSG_OUT ???????. Must be 0
  277. };
  278. //--------------
  279. };
  280. //------------
  281. };
  282. //-----------
  283. };
  284. //--------
  285. };
  286. typedef struct _USBTMC_COMMAND_MESSAGE USBTMC_COMMAND_MESSAGE;
  287. typedef struct _USBTMC_RESPOND_MESSAGE USBTMC_RESPOND_MESSAGE;
  288. #pragma pack( push, 1 )
  289. __pkd__ struct _BULKOUT_HEADER
  290. {
  291. BYTE MsgID; // -- Specifies the USBTMC message and the type fo the USBTMC message.
  292. BYTE bTag; // -- A transfer identifier. The HOST must set bTag different than the bTag used in the previous Bulk-Out header
  293. // The host should increment the bTag by 1each time it sends a new Bulk-Out Header.
  294. // The Host must set bTag such that: 1<=bTag<=255
  295. BYTE bTagInverse; // -- The inverse (one`s complement) of the bTag.
  296. BYTE Reserved; // -- Reserved. Must be 0x00
  297. // ------------- USBTMC command message specific ---------------------------------------
  298. USBTMC_COMMAND_MESSAGE stCommandMessage; // -- USBTMC command message specific
  299. // ----------------------------------------------------------------------------------------
  300. }__pk__;
  301. typedef struct _BULKOUT_HEADER BULKOUT_HEADER;
  302. #pragma pack( pop )
  303. #pragma pack( push, 1 )
  304. __pkd__ struct _BULKIN_HEADER
  305. {
  306. BYTE MsgID; // -- Must match MsgID in the USBTMC command message transfer causing this response
  307. BYTE bTag; // -- Must match bTag in the USBTMC command message transfer causing this response
  308. BYTE bTagInverse; // -- Must match bTagInverse in the USBTMC command message transfer causing this response
  309. BYTE Reserved; // -- Reserved. Must be 0x00
  310. // ------------- USBTMC command message specific ---------------------------------------
  311. USBTMC_RESPOND_MESSAGE stRespondMessage; // -- USBTMC respond message specific
  312. // ----------------------------------------------------------------------------------------
  313. }__pk__;
  314. typedef struct _BULKIN_HEADER BULKIN_HEADER;
  315. #pragma pack( pop )
  316. struct _USBTMC_INFO_HEADER
  317. {
  318. int IDNStringLength;
  319. char IDNString[MAX_USBTMC_IDNSTRING_SIZE];
  320. };
  321. typedef struct _USBTMC_INFO_HEADER USBTMC_INFO_HEADER;
  322. typedef enum
  323. {
  324. USB_INTERFACE_SCPI = 0,
  325. USB_INTERFACE_CONT = 1,
  326. USB_INTERFACE_INV = 0xffffffff
  327. } USB_INTERFACE;
  328. #define USB_MAX_BULKIN_BUFFERSIZE RAM_BULKINBUFFER_SIZE
  329. #define USB_MAX_BULKOUT_BUFFERSIZE RAM_BULKOUTBUFFER_SIZE
  330. #define USB_MAX_FUNCCONTEXT RAM_GPIBTRANSFERCONTEXT_SIZE
  331. // --------------------------------------------------------------------------------
  332. #define USB_MAX_BULK_PAYLOAD (USB_MAX_PACKET2-sizeof(BULKOUT_HEADER))
  333. // USB_MAX_BULK_PAYLOAD - ìàêñ êîëè÷åñòâî áàéò, ïåðåäàâàåìûõ â îäíîé OUT òðàíçàêöèè
  334. // âìåñòå ñ BULKOUT_HEADER. Åñëè äëèííà Payload áîëüùå ýòîãî ÷èñëà, èìååò ìåñòî
  335. // ðàçäåëåíèå ïîñûëêè äàííûõ íà íåñêîëüêî òðàíçàêöèé.
  336. // --------------------------------------------------------------------------------
  337. #ifndef _USBTMC_C_
  338. extern const __root USBTMC_INFO_HEADER USBTMCInfo;
  339. extern BYTE gEP2BufIn[];
  340. extern BYTE gEP2BufOut[];
  341. #endif
  342. #endif
  343. // =============================================================================
  344. // =============================================================================
  345. // === -= APPENDIX 1. Describing of the BULKOUT_HEADER =- ===
  346. // =============================================================================
  347. // =============================================================================
  348. // See "USBTMC spec., rev 1.0, 2003": "page 7":"Figure 2", "page 8":"Figure 3",
  349. // "page 9":"last paragraph".
  350. //
  351. // Õîñò ìîæåò ïåðåäàâàòü êîììàíäó ñ äàííûìè ðàçäåëüíî êàê â ðàçíûõ òðàíçàêöèÿõ,
  352. // òàê è â ðàçíûõ ïåðåäà÷àõ. Ïîýòîìó, çàãîëîâîê Bulk-Out header èìååò ïîëå
  353. // TransferSize, êîòîðîå è îïðåäåëÿåò ðåàëüíóþ äëèííó ñîîáùåíèÿ ñ äàííûìè.
  354. // Õîñò íå äîëæåí (÷èòàé ÎÁßÇÀÍ ÍÅ) ïîñûëàòü íîâûé çàãîëîâîê Bulk-Out header,
  355. // åñëè åùå íå ïåðåäàë îñòàâøóþñÿ ÷àñòü ñîîáùåíèÿ. Èñêëþ÷åíèå: õîñò ïåðåäàë
  356. // íà EP0 çàïðîñ INITIATE_ABORT_BULK_OUT. Îí, êîíå÷íî, ìîæåò, òîëüêî device
  357. // âîñïðèìåò ýòî íå êàê Bulk-Out header, à êàê äàííûå, ñîáüåòñÿ ñèíõðîíèçàöèÿ
  358. // Host-Out-Device-In Messages è âñå ïîëåòèò.