DoComm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. #ifndef _DO_COMM_H_
  2. #define _DO_COMM_H_
  3. //------------------------------------------------------------------------------
  4. #include <stdint.h>
  5. //------------------------------------------------------------------------------
  6. //--- common define ---
  7. //------------------------------------------------------------------------------
  8. #define CMP_ETH_IP_HEAD "192.168.100"
  9. #define DoIPAddress "192.168.100.1"
  10. #define DoTcpPort 36000
  11. #define IMAGE_FILE_PATH "../mnt"
  12. #define TFTP_PULL_CMD "tftp"
  13. #define SIGTERM_MSG "SegmentFault.~~~~\n"
  14. #define MAX_REGISTER_NUM 30
  15. #define CHECK_NETWORK_FAIL_COUNT 10//10
  16. #define CONNECT_SERVER_FAIL_COUNT 3//5
  17. #define WARNING_CODE_SIZE 6
  18. #define MAX_VOLTAGE 10000
  19. #define MAX_CURRENCY 5000
  20. #define MAX_POWER 3600
  21. #define DISPENSER_INIT_SUCC 0x01
  22. #define DISPENER_INIT_FAIL 0x02
  23. #define DISPENSER_SOCKET_RECONN 0x03
  24. #define VERSION_BUF_SIZE 32
  25. #define PRICES_UNIT 0.01
  26. #define LOOP_RETRY_TIME 1000 //1 second
  27. //------------------------------------------------------------------------------
  28. //--- dispenser ID ---
  29. //------------------------------------------------------------------------------
  30. #define ID_RESERVER 0x00
  31. #define ID_OF_DISPENSER 0x01
  32. #define ID_REGISTER 0xFF
  33. //------------------------------------------------------------------------------
  34. //--- dispenser operation ---
  35. //------------------------------------------------------------------------------
  36. #define OP_READ_DATA 0x01
  37. #define OP_WRITE_DATA 0x02
  38. #define OP_WAIT_RESPONSE 0x03
  39. //------------------------------------------------------------------------------
  40. //--- connector status ---
  41. //------------------------------------------------------------------------------
  42. #define CONN_ST_IDLE 0x00
  43. #define CONN_ST_PREPARING 0x01
  44. #define CONN_ST_CHARGING 0x02
  45. #define CONN_ST_TERMINATING 0x03
  46. #define CONN_ST_ALARM 0x04
  47. //------------------------------------------------------------------------------
  48. //--- dispenser register ---
  49. //------------------------------------------------------------------------------
  50. #define REG_MODEL_NAME 0x01
  51. #define REG_CONNECTOR_ID 0x02
  52. #define REG_POWER_CABINET_STATUS 0x03
  53. #define REG_DISPENSER_STATUS 0x04
  54. #define REG_CHARGING_CAP 0x05
  55. #define REG_CHARGING_TARGET 0x06
  56. #define REG_SOFTWARE_UPDATE 0x07
  57. #define REG_PLUG_IN_STATE 0x08
  58. #define REG_CONNECTOR_STATE 0x09
  59. #define REG_USER_ID 0x0A
  60. #define REG_CHARGING_PERMISSION 0x0B
  61. #define REG_MISC_CONTROL 0X0C
  62. #define REG_REPORT_CSU_VERSION 0X0D
  63. #define REG_REPORT_OTHER_VERSION 0X0E
  64. #define REG_PRESENT_CHARGING_INFO 0X0F
  65. #define REG_QRCODE_URL_INFO 0X10
  66. #define REG_WAIT_PLUG_IT_STATE 0x11
  67. #define REG_Ground_Fault_Detection 0x12
  68. #define REG_CABINET_DCM_VERSION 0x13
  69. #define REG_CABINET_OTHER_VERSION 0x14
  70. #define REG_TOTAL_PSU_QUANTITY 0x15
  71. #define REG_PSU_VERSION 0x16
  72. #define REG_RESERVATION_IDTAG 0x17
  73. #define REG_DISPENSER_REQUEST 0x18
  74. #define REG_REMOTE_START_NO_ID 0x19
  75. #define REG_REFUND_AMOUNT 0x1A
  76. #define REG_PREPAYMENT_INFO 0x1B
  77. #define REG_PAYMENT_FAIL_REASON 0x1C
  78. #define REG_CONNECTOR_QR_CODE 0x1D
  79. #define REG_STATION_INFO 0x1E
  80. //------------------------------------------------------------------------------
  81. //--- dispenser result ---
  82. //------------------------------------------------------------------------------
  83. #define COMMAND_RESULT_OK 0x01
  84. #define COMMAND_RESULT_NG 0x02 //wait state
  85. //------------------------------------------------------------------------------
  86. //--- power cabinet misc status code ---
  87. //------------------------------------------------------------------------------
  88. #define MISC_ST_MISC_CMD "B40001"
  89. #define MISC_ST_VERSION "B40999"
  90. //------------------------------------------------------------------------------
  91. //--- power cabinet misc command ---
  92. //------------------------------------------------------------------------------
  93. #define MISC_CMD_CONNECOTOR_TIMEOUT (0X0001)
  94. #define MISC_CMD_OPERATIVE_STATE (0X0002)
  95. #define MISC_CMD_DEFAULT_PRICES (0x0003)
  96. #define MISC_CMD_DEFAULT_CURRENCY (0x0004)
  97. #define MISC_CMD_ACCOUNT_BALANCE (0x0005)
  98. #define MISC_CMD_BACKEND_STATUS (0x0006)
  99. #define MISC_CMD_ETHERNET_STATUS (0x0007)
  100. #define MISC_CMD_WIFI_STATUS (0x0008)
  101. #define MISC_CMD_4G_STATUS (0x0009)
  102. #define MISC_CMD_BILLING_INFO (0x000A)
  103. #define MISC_CMD_WEB_STOP_CHARGING (0x000B)
  104. #define MISC_CMD_AUTH_DISABLE (0x000C)
  105. #define MISC_CMD_EVCCID_ENABLE (0x000D)
  106. #define MISC_CMD_HARDWARE_REBOOT (0x0101)
  107. #define MISC_CMD_SOFTWARE_RESTART (0x0102)
  108. #define MISC_CMD_REMOTE_START_CHARGING (0x0103)
  109. #define MISC_CMD_REMOTE_STOP_CHARGING (0x0104)
  110. #define MISC_CMD_REMOTE_UNLOCK (0x0105)
  111. #define MISC_CMD_RESERVATION (0x0106)
  112. #define MISC_CMD_CHANGE_LCM_PAGE (0x0107)
  113. #define MISC_CMD_QR_CODE_REQ (0x0108)
  114. #define MISC_CMD_STATION_INFO_REQ (0x0109)
  115. #define ST_UPDATE_FIRMWARE (0x01)
  116. #define ST_NO_UPDATE_FIRMWARE (0x02)
  117. //------------------------------------------------------------------------------
  118. #pragma pack(push)
  119. #pragma pack(1)
  120. typedef union
  121. {
  122. unsigned int Value;
  123. struct
  124. {
  125. unsigned int StationInfoReq:1; // 0: no effect, 1: need to request StationInfo
  126. unsigned int res:31;
  127. }bits;
  128. } MoreInfoReq;
  129. typedef struct StStationVar {
  130. char StationName[64];
  131. char StationID[16];
  132. int WeatherID;
  133. float Temperature;
  134. } StationVar;
  135. typedef struct StConnectorState {
  136. uint8_t State;
  137. uint8_t WarningCode[6];
  138. uint8_t ConnectorTemp;
  139. uint8_t ChillerTemp;
  140. uint8_t PlugIn;
  141. uint8_t Reserved[2];
  142. } ConnectorState;
  143. typedef struct StConnectorIDTable {
  144. uint8_t DcConnID1;
  145. uint8_t DcConnID2;
  146. uint8_t AcConnID;
  147. uint8_t Reserved;
  148. } ConnectorIDTable;
  149. typedef struct StDoCommGlobalVar {
  150. uint8_t SeqNum;
  151. uint8_t DisConnCount;
  152. uint8_t ConnectorID[3]; //keep from power cabinet
  153. uint8_t MiscCmd;
  154. uint8_t Reserved[2];
  155. } DoCommGblData;
  156. typedef struct StCommnadHead {
  157. uint8_t SeqNum; //sequence number 0 ~ 255
  158. uint8_t ID; //0: Reserved, 0x01 ~ 0xFE: connector ID, 0xFF: exists in register 1 and register 2
  159. uint8_t OP; //0x01: read, 0x02: write, 0x03: response from power cabinet
  160. uint8_t DataLen; //raw data Length
  161. } CmdHead;
  162. typedef struct StCommandData {
  163. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  164. 0x02: The ID to connector equipped at dispenser
  165. 0x03: Power cabinet status
  166. 0x04: Dispenser status
  167. 0x05: The charging capacity of each connector
  168. 0x06: The required voltage and current during charging
  169. 0x07: The indicator of software update to dispenser
  170. 0x08: Indicate whether the connector is plug-in or not
  171. 0x09: Indicate the connector state
  172. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  173. 0x0B: Charging permission from power cabinet to dispenser
  174. */
  175. uint8_t Data[250];
  176. } CmdData;
  177. typedef struct StResultData {
  178. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  179. 0x02: The ID to connector equipped at dispenser
  180. 0x03: Power cabinet status
  181. 0x04: Dispenser status
  182. 0x05: The charging capacity of each connector
  183. 0x06: The required voltage and current during charging
  184. 0x07: The indicator of software update to dispenser
  185. 0x08: Indicate whether the connector is plug-in or not
  186. 0x09: Indicate the connector state
  187. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  188. 0x0B: Charging permission from power cabinet to dispenser
  189. */
  190. uint8_t Result;
  191. uint8_t Data[249];
  192. } ResultData;
  193. typedef struct StCsuCmdPkt {
  194. CmdHead Head;
  195. CmdData Data;
  196. } CsuCmdPkt;
  197. typedef struct StCsuResultPkt {
  198. CmdHead Head;
  199. ResultData Data;
  200. } CsuResultPkt;
  201. typedef struct StMiscCommand {
  202. uint16_t CMD;
  203. uint8_t Value[4];
  204. } MiscCommand;
  205. typedef struct StPresentChargingInfo {
  206. uint16_t PresentChargingVoltage; //0~6553.5 volt
  207. uint16_t PresentChargingCurrent; //0~6553.5 amp
  208. int RemainChargingDuration; // second
  209. uint8_t EvBatterySoc; // 0~100%
  210. } PreChargingInfo;
  211. typedef struct StGroundFaultDetection { //Ground Fault Detection
  212. uint8_t Status;
  213. } GroundFaultDetection;
  214. typedef struct StSoftwareUpdInfo {
  215. uint8_t UpdateState; //1:update , 2: not update
  216. uint8_t ImgName[248];
  217. } SoftwareUpdInfo;
  218. typedef struct StCapabilityInfo {
  219. uint16_t OutputVoltage;
  220. uint16_t OutputCurrent;
  221. uint16_t OutputPower;
  222. uint8_t Reserved[2];
  223. } CapabilityInfo;
  224. typedef struct StAccountInfo {
  225. uint8_t Currency;
  226. int UserPrices;
  227. int TotalCost;
  228. int Balance;
  229. uint8_t Reserved[3];
  230. } AccountInfo;
  231. #pragma pack(pop)
  232. #endif /* _DO_COMM_H_ */