DoComm.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. //------------------------------------------------------------------------------
  69. //--- dispenser result ---
  70. //------------------------------------------------------------------------------
  71. #define COMMAND_RESULT_OK 0x01
  72. #define COMMAND_RESULT_NG 0x02 //wait state
  73. //------------------------------------------------------------------------------
  74. //--- power cabinet misc status code ---
  75. //------------------------------------------------------------------------------
  76. #define MISC_ST_MISC_CMD "B40001"
  77. #define MISC_ST_VERSION "B40999"
  78. //------------------------------------------------------------------------------
  79. //--- power cabinet misc command ---
  80. //------------------------------------------------------------------------------
  81. #define MISC_CMD_CONNECOTOR_TIMEOUT (0X0001)
  82. #define MISC_CMD_OPERATIVE_STATE (0X0002)
  83. #define MISC_CMD_DEFAULT_PRICES (0x0003)
  84. #define MISC_CMD_DEFAULT_CURRENCY (0x0004)
  85. #define MISC_CMD_ACCOUNT_BALANCE (0x0005)
  86. #define MISC_CMD_BACKEND_STATUS (0x0006)
  87. #define MISC_CMD_ETHERNET_STATUS (0x0007)
  88. #define MISC_CMD_WIFI_STATUS (0x0008)
  89. #define MISC_CMD_4G_STATUS (0x0009)
  90. #define MISC_CMD_BILLING_INFO (0x000A)
  91. #define MISC_CMD_WEB_STOP_CHARGING (0x000B)
  92. #define MISC_CMD_AUTH_DISABLE (0x000C)
  93. #define MISC_CMD_EVCCID_ENABLE (0x000D)
  94. #define MISC_CMD_HARDWARE_REBOOT (0x0101)
  95. #define MISC_CMD_SOFTWARE_RESTART (0x0102)
  96. #define MISC_CMD_REMOTE_START_CHARGING (0x0103)
  97. #define MISC_CMD_REMOTE_STOP_CHARGING (0x0104)
  98. #define MISC_CMD_REMOTE_UNLOCK (0x0105)
  99. #define ST_UPDATE_FIRMWARE (0x01)
  100. #define ST_NO_UPDATE_FIRMWARE (0x02)
  101. //------------------------------------------------------------------------------
  102. #pragma pack(push)
  103. #pragma pack(1)
  104. typedef struct StConnectorState {
  105. uint8_t State;
  106. uint8_t WarningCode[6];
  107. uint8_t ConnectorTemp;
  108. uint8_t ChillerTemp;
  109. uint8_t Reserved[3];
  110. } ConnectorState;
  111. typedef struct StConnectorIDTable {
  112. uint8_t DcConnID1;
  113. uint8_t DcConnID2;
  114. uint8_t AcConnID;
  115. uint8_t Reserved;
  116. } ConnectorIDTable;
  117. typedef struct StDoCommGlobalVar {
  118. uint8_t SeqNum;
  119. uint8_t DisConnCount;
  120. uint8_t ConnectorID[3]; //keep from power cabinet
  121. uint8_t MiscCmd;
  122. uint8_t Reserved[2];
  123. } DoCommGblData;
  124. typedef struct StCommnadHead {
  125. uint8_t SeqNum; //sequence number 0 ~ 255
  126. uint8_t ID; //0: Reserved, 0x01 ~ 0xFE: connector ID, 0xFF: exists in register 1 and register 2
  127. uint8_t OP; //0x01: read, 0x02: write, 0x03: response from power cabinet
  128. uint8_t DataLen; //raw data Length
  129. } CmdHead;
  130. typedef struct StCommandData {
  131. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  132. 0x02: The ID to connector equipped at dispenser
  133. 0x03: Power cabinet status
  134. 0x04: Dispenser status
  135. 0x05: The charging capacity of each connector
  136. 0x06: The required voltage and current during charging
  137. 0x07: The indicator of software update to dispenser
  138. 0x08: Indicate whether the connector is plug-in or not
  139. 0x09: Indicate the connector state
  140. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  141. 0x0B: Charging permission from power cabinet to dispenser
  142. */
  143. uint8_t Data[250];
  144. } CmdData;
  145. typedef struct StResultData {
  146. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  147. 0x02: The ID to connector equipped at dispenser
  148. 0x03: Power cabinet status
  149. 0x04: Dispenser status
  150. 0x05: The charging capacity of each connector
  151. 0x06: The required voltage and current during charging
  152. 0x07: The indicator of software update to dispenser
  153. 0x08: Indicate whether the connector is plug-in or not
  154. 0x09: Indicate the connector state
  155. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  156. 0x0B: Charging permission from power cabinet to dispenser
  157. */
  158. uint8_t Result;
  159. uint8_t Data[249];
  160. } ResultData;
  161. typedef struct StCsuCmdPkt {
  162. CmdHead Head;
  163. CmdData Data;
  164. } CsuCmdPkt;
  165. typedef struct StCsuResultPkt {
  166. CmdHead Head;
  167. ResultData Data;
  168. } CsuResultPkt;
  169. typedef struct StMiscCommand {
  170. uint16_t CMD;
  171. uint8_t Value[4];
  172. } MiscCommand;
  173. typedef struct StPresentChargingInfo {
  174. uint16_t PresentChargingVoltage; //0~6553.5 volt
  175. uint16_t PresentChargingCurrent; //0~6553.5 amp
  176. int RemainChargingDuration; // second
  177. uint8_t EvBatterySoc; // 0~100%
  178. } PreChargingInfo;
  179. typedef struct StGroundFaultDetection { //Ground Fault Detection
  180. uint8_t Status;
  181. } GroundFaultDetection;
  182. typedef struct StSoftwareUpdInfo {
  183. uint8_t UpdateState; //1:update , 2: not update
  184. uint8_t ImgName[248];
  185. } SoftwareUpdInfo;
  186. typedef struct StCapabilityInfo {
  187. uint16_t OutputVoltage;
  188. uint16_t OutputCurrent;
  189. uint16_t OutputPower;
  190. uint8_t Reserved[2];
  191. } CapabilityInfo;
  192. typedef struct StAccountInfo {
  193. uint8_t Currency;
  194. int UserPrices;
  195. int TotalCost;
  196. int Balance;
  197. uint8_t Reserved[3];
  198. } AccountInfo;
  199. #pragma pack(pop)
  200. #endif /* _DO_COMM_H_ */