Tipro API
Communicate with Tipro devices
TiproHid.h
1 // TiproHid.h: interface for the CTiproHid class.
2 //
4 
5 //20190710
6 //#define EErrCode unsigned int
7 //#define UCHAR unsigned char
8 //#define UINT16 unsigned int
9 //#define DWORD unsigned int
10 //typedef uint16_t UINT16
11 //typedef int EErrCode
12 //typedef unsigned char UCHAR
13 
14 
15 #if !defined(AFX_TIPROHID_H__D7FE7D00_4776_473B_B5C3_499AB033B3A3__INCLUDED_)
16 #define AFX_TIPROHID_H__D7FE7D00_4776_473B_B5C3_499AB033B3A3__INCLUDED_
17 
18 #if _MSC_VER > 1000
19 #pragma once
20 #endif // _MSC_VER > 1000
21 
22 //20190709 #include "Hid.h"
23 
24 #include "StdAfx.h" //20190711
25 
26 //20190827 linux
27 typedef unsigned short UINT16;
28 typedef unsigned int DWORD;
29 typedef unsigned int EErrCode;
30 
31 
32 
33 class CTiproHid /*20190710todo : public CHid */
34 {
35 public:
36  CTiproHid(/*20200224int nDeviceNum=0*/); //20200409commented /*20190826todo:CHid(nDeviceNum)*/{m_FWLevel=0;};
37  virtual ~CTiproHid(); //20200409removed virtual
38 
39  //int lala();
40 
41  enum ETErrCode
42  {
43  // compatible with EErrCode from CHid -> converted in ConvertErr() function
44  terrNone, // 0x00
45  terrWrongParameter, // 0x01
46  terrInvalidHandleValue, // 0x02
47  terrDeviceNotOpened, // 0x03
48  terrGetFeature, // 0x04
49  terrSetFeature, // 0x05
50  terrUnknown, // 0x06
51  // CTiproHid specific errors
52  terrCmdNotSupportedAtFWLevel, // 0x07
53  terrFWLevelNotAvailable, // 0x08
54  terrFWLevelChangeFailed, // 0x09
55  terrWTCDelayExpired, // 0x0A
56  terrWrongSignatureBytes, // 0x0B
57  terrResponseTimoutExpired, // 0x0C
58  // Firmware exchange errors
59  terrExchStatusVoid, // 0x0D
60  terrExchStatusReqTO, // 0x0E
61  terrExchStatusReqReject, // 0x0F
62  terrExchStatusReqFail, // 0x10
63  terrExchStatusReqSucc, // 0x11
64  terrExchStatusAnsPend, // 0x12
65  terrExchStatusAnsTO, // 0x13
66  terrExchStatusAnsReject, // 0x14
67  terrExchStatusAnsFail, // 0x15
68  terrExchStatusAnsOK, // 0x16
69  terrExchStatusFWBug // 0x17
70  };
71 
72  ETErrCode ConvertErr (EErrCode errCode);
73 
74 //20190827 ETErrCode GetFeatureReport(UCHAR *pData, int *nLen) {return ConvertErr(CHid::GetFeatureReport(0,pData,nLen));}
75 //20190827 ETErrCode SetFeatureReport(const UCHAR *pData,const int nLen) {return ConvertErr(CHid::SetFeatureReport(0,pData,nLen));}
76 
77  bool IsTipro(); // not finished yet
78  bool IsConnected(); // not finished yet
79 
80 
81  // unsigned int ReturnSignature(void) {return s_SignatureCounter++;} // to solve Bug#9
82  UINT16 ReturnSignature(void) {return s_SignatureCounter++;} // to solve Bug#9
83 
84  // specific Tipro commands (enabling FW Level, additional interfaces, sending commands...)
85 
86  // Firmware Level commands
87 //20200224 UCHAR GetFWLevel();
88 //20200224 ETErrCode SetFWLevel(TiproHidDevice *device, const UCHAR nFWLevel); // not finished yet
89 
90  // Additional interfaces commands
91  ETErrCode GetEnabledInterfaces(); // not finished yet
92  ETErrCode EnableInterface(); // not finished yet
93 
94  // controller info functions
95 //20200224 ETErrCode GetControllerVersion(int *pVerMaj, int *pVerMin, int *pVerBuild, int *pVerCustom); // not finished yet
96 
97  // Sending commands over HID interface
98 //20200224 ETErrCode SendCommand(TiproHidDevice *device, const UCHAR nCommand, const UCHAR *pParameters, const int nLen); // not finished yet
99 
100  //ETErrCode SendCommandEx(); // not finished yet
101  // verson 1.0 - for test // not finished yet
102 //20200224 ETErrCode SendCommandEx(TiproHidDevice *device, const UCHAR nCommand, const UCHAR nDest, const UCHAR *pParameters, const int nLen, UCHAR *pResponse, int *nResponseLen);
103 
104  // Misc commands
105  ETErrCode WaitToConnect(const DWORD nDelay); // not finished yet
106 
107 #if 0 // FW_LEVEL_3
108  // FW-Level 3 commands
109  ETErrCode CTiproHid::SendRawData(const UCHAR *pRawData, const int nLen);
110 #endif
111 
112 
113  // constants definition - must me initialized ouside of the class (end of this file)
114  /*static const UCHAR DEFAULT_REPORT_ID;
115  static const UCHAR FRCMD_SWITCH_LEVEL;
116  static const UCHAR FRCMD_ENABLE_INTERFACE;
117  static const UCHAR FRCMD_PADDING_CHAR;*/
118 //*20190709
119 
120  static const UCHAR FRCMD_RESET = 0x00;
121  static const UCHAR FRCMD_TMC_IF_DISABLE = 0x01;
122  static const UCHAR FRCMD_TMC_IF_ENABLE = 0x02;
123  static const UCHAR FRCMD_TMC_IF_V2_ENABLE = 0x03;
124  static const UCHAR FRCMD_LEVEL1_CMD = 0x04;
125  static const UCHAR FRCMD_CLR_SERIAL_NO = 0x05;
126  static const UCHAR FRCMD_OPT_IF = 0x06;
127  static const UCHAR FRCMD_FW_LEVEL = 0x07;
128  static const UCHAR FRCMD_MID_EXCH = 0x08;
129 
130 private:
131  UCHAR m_FWLevel;
132 
133  // signature counter -> MUST BE 16 bits only
134  // static unsigned int s_SignatureCounter; // to solve Bug#9
135  static UINT16 s_SignatureCounter;
136 
137  // Feature report header indexes (same for firmware level1+)
138  static const UCHAR FRH_VER_MAJOR_IX = 0x00;
139  static const UCHAR FRH_VER_MIN_IX = 0x01;
140  static const UCHAR FRH_VER_BUILD_IX = 0x02;
141  static const UCHAR FRH_VER_CUSTOM_IX = 0x03;
142  static const UCHAR FRH_INTERFACES_IX = 0x04;
143  static const UCHAR FRH_FW_LEVEL_IX = 0x05;
144  static const UCHAR FRH_RESERVED_1_IX = 0x06;
145  static const UCHAR FRH_RESERVED_2_IX = 0x07;
146 
147 };
148 
149  // constants initializaion
150 /*
151  const UCHAR CTiproHid::DEFAULT_REPORT_ID = 0x00;
152  const UCHAR CTiproHid::FRCMD_SWITCH_LEVEL = 0x07;
153  const UCHAR CTiproHid::FRCMD_ENABLE_INTERFACE = 0x06;
154  const UCHAR CTiproHid::FRCMD_PADDING_CHAR = 0xFF;
155 */
156 //*20190709
157 
158 /*20190903
159  const UCHAR CTiproHid::FRCMD_RESET = 0x00;
160  const UCHAR CTiproHid::FRCMD_TMC_IF_DISABLE = 0x01;
161  const UCHAR CTiproHid::FRCMD_TMC_IF_ENABLE = 0x02;
162  const UCHAR CTiproHid::FRCMD_TMC_IF_V2_ENABLE = 0x03;
163  const UCHAR CTiproHid::FRCMD_LEVEL1_CMD = 0x04;
164  const UCHAR CTiproHid::FRCMD_CLR_SERIAL_NO = 0x05;
165  const UCHAR CTiproHid::FRCMD_OPT_IF = 0x06;
166  const UCHAR CTiproHid::FRCMD_FW_LEVEL = 0x07;
167  const UCHAR CTiproHid::FRCMD_MID_EXCH = 0x08;
168 
169  const UCHAR CTiproHid::FRH_VER_MAJOR_IX = 0x00;
170  const UCHAR CTiproHid::FRH_VER_MIN_IX = 0x01;
171  const UCHAR CTiproHid::FRH_VER_BUILD_IX = 0x02;
172  const UCHAR CTiproHid::FRH_VER_CUSTOM_IX = 0x03;
173  const UCHAR CTiproHid::FRH_INTERFACES_IX = 0x04;
174  const UCHAR CTiproHid::FRH_FW_LEVEL_IX = 0x05;
175  const UCHAR CTiproHid::FRH_RESERVED_1_IX = 0x06;
176  const UCHAR CTiproHid::FRH_RESERVED_2_IX = 0x07;
177 */
178  // interface messaging format:
179  // [00,07,01,...]
180  //
181  // [DEFAULT_REPORT_ID, FRCMD__XXX, FRCMD_PARAM_01, FRCMD_PARAM_02,....FRCMD_PADDING_CHAR, ... ]
182  //
183 
184 
185 #endif // !defined(AFX_TIPROHID_H__D7FE7D00_4776_473B_B5C3_499AB033B3A3__INCLUDED_)
Definition: TiproHid.h:33