AppTaskUart1.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * @Author : ChenJie
  3. * @Date : 2022-02-10 11:44:08
  4. * @Version : V3.0
  5. * @LastEditors : ChenJie
  6. * @LastEditTime : 2022-05-17 16:22:56
  7. * @Description : file content
  8. * @FilePath : \S32K146_4G\src\AppTaskUart1.h
  9. */
  10. /*
  11. * AppTaskUart2.h
  12. *4G的串口函数
  13. * Created on: 2022年2月10日
  14. * Author: QiXiang_CHENJIE
  15. */
  16. #ifndef APPTASKUART1_H_
  17. #define APPTASKUART1_H_
  18. #include "hal_adapter.h"
  19. #include "AppFunclib.h"
  20. #include "AppGlobalVar.h"
  21. #include "AppTaskGps.h"
  22. #define CRLF "\r\n"
  23. #define BATT_SN_LEN 17
  24. #define TCP_START_SYM1 0x23
  25. #define TCP_START_SYM2 0x23
  26. #define TCP_CMD_SYM 0x02 // 实时信息上报是0x02
  27. #define TCP_HEART_SYM 0x07 // 心跳包标志
  28. #define TCP_ANS_SYM 0xFE
  29. #define TCP_ENCPT_ENABLE 0x00
  30. #define TCP_ENCPT_DISABLE 0x01
  31. #define BattMsg (0x80)
  32. #define GpsMsg (0x82)
  33. #define VerMsg (0x86)
  34. #define DebugMsg (0x8C)
  35. #define TruckBattMsg (0x91)
  36. #define TruckVehiMsg (0x90)
  37. #define TruckAcclMsg (0x92)
  38. #define TCP_QUERY_SYM 0x80
  39. #define TCP_SETCMD_SYM 0x81
  40. #define TCP_CONCMD_SYM 0x82
  41. #define TCP_UDSCMD_SYM 0x83
  42. typedef struct _GPSInfoType
  43. {
  44. uint8 sendTimeUTC[6];
  45. uint8 msgMark;
  46. uint8 msgCollectionTimeUTC[6];
  47. GPSInfo GpsInfoData;
  48. uint8 Tac[2];
  49. uint8 CellID[4];
  50. uint8 xData[2];
  51. uint8 yData[2];
  52. uint8 zData[2];
  53. } GPSInfoType;
  54. typedef struct GPSMsgtoTcpType
  55. {
  56. uint8 startSymbol[2];
  57. uint8 cmdSymbol;
  58. uint8 ansSymbol;
  59. uint8 SN[BATT_SN_LEN];
  60. uint8 encryptMethod;
  61. uint8 dataLength[2];
  62. GPSInfoType gpsInfo;
  63. uint8 CRC;
  64. } GPSMsgtoTcpType;
  65. typedef struct _VerInfoType
  66. {
  67. uint8 sendTimeUTC[6];
  68. uint8 msgMark;
  69. uint8 msgCollectionTimeUTC[6];
  70. uint8 ICCID[20];
  71. uint8 IMEI[15];
  72. uint8 BMSHwVersion[2];
  73. uint8 BMSSwVersion[4];
  74. uint8 HwVersion[2];
  75. uint8 BLVersion[4];
  76. uint8 DRVVersion[4];
  77. uint8 APPVersion[4];
  78. uint8 BmsType;
  79. uint8 BmsInfo;
  80. uint8 DataModuleType;
  81. } VerInfoType;
  82. typedef struct VersionMsgtoTcpType
  83. {
  84. uint8 startSymbol[2];
  85. uint8 cmdSymbol;
  86. uint8 ansSymbol;
  87. uint8 SN[BATT_SN_LEN];
  88. uint8 encryptMethod;
  89. uint8 dataLength[2];
  90. VerInfoType VerInfo;
  91. uint8 CRC;
  92. } VersionMsgtoTcpType;
  93. typedef struct StorageInfoType
  94. {
  95. uint8 sendTimeUTC[6];
  96. uint8 msgMark;
  97. uint8 msgCollectionTimeUTC[6];
  98. uint8 RelayState;
  99. uint8 FanState;
  100. uint8 HeatState;
  101. uint8 ConvertState;
  102. } StorageInfo;
  103. typedef struct StorageInfoToTcpType
  104. {
  105. uint8 startSymbol[2];
  106. uint8 cmdSymbol;
  107. uint8 ansSymbol;
  108. uint8 SN[BATT_SN_LEN];
  109. uint8 encryptMethod;
  110. uint8 dataLength[2];
  111. StorageInfo StorageMsg;
  112. uint8 CRC;
  113. } StorageInfoToTcp;
  114. typedef struct StorageInfoType2
  115. {
  116. uint8 sendTimeUTC[6];
  117. uint8 msgMark;
  118. uint8 msgCollectionTimeUTC[6];
  119. uint8 meter1AllPwr[4];
  120. uint8 meter1PosPwr[4];
  121. uint8 meter1NegPwr[4];
  122. uint8 meter2AllPwr[4];
  123. uint8 meter2PosPwr[4];
  124. uint8 meter2NegPwr[4];
  125. } StorageInfo2;
  126. typedef struct StorageInfoToTcpType2
  127. {
  128. uint8 startSymbol[2];
  129. uint8 cmdSymbol;
  130. uint8 ansSymbol;
  131. uint8 SN[BATT_SN_LEN];
  132. uint8 encryptMethod;
  133. uint8 dataLength[2];
  134. StorageInfo2 StorageMsg2;
  135. uint8 CRC;
  136. } StorageInfoToTcp2;
  137. typedef struct AccInfoType
  138. {
  139. uint8 sendTimeUTC[6];
  140. uint8 msgMark;
  141. uint8 msgCollectionTimeUTC[6];
  142. uint8 accOnlineDays[2];
  143. uint8 accDrvMiles[2];
  144. uint8 sohNoCalibrTime[2];
  145. uint8 accChrgEng[4];
  146. uint8 accDischrgEng[4];
  147. uint8 accChrgCap[4];
  148. uint8 accDischrgCap[4];
  149. uint8 accOverChrgTimes;
  150. uint8 accOverDischrgTimes;
  151. uint8 accCycleTimes[2];
  152. } AccInfo;
  153. typedef struct AccInfoToTcpType
  154. {
  155. uint8 startSymbol[2];
  156. uint8 cmdSymbol;
  157. uint8 ansSymbol;
  158. uint8 SN[BATT_SN_LEN];
  159. uint8 encryptMethod;
  160. uint8 dataLength[2];
  161. AccInfo AccMsg;
  162. uint8 CRC;
  163. } AccInfoToTcp;
  164. typedef struct _DebugInfoType
  165. {
  166. UINT8 sendTimeUTC[6];
  167. UINT8 msgMark;
  168. UINT8 DebugLen[2];
  169. } DebugInfoType;
  170. typedef struct DebugMsgtoTcp_Type
  171. {
  172. UINT8 startSymbol[2];
  173. UINT8 cmdSymbol;
  174. UINT8 ansSymbol;
  175. UINT8 SN[BATT_SN_LEN];
  176. UINT8 encryptMethod;
  177. UINT8 dataLength[2];
  178. DebugInfoType DebugInfo;
  179. UINT8 _CRC;
  180. } DebugMsgtoTcpType;
  181. typedef struct UTC8Time_Type
  182. {
  183. uint8 year;
  184. uint8 month;
  185. uint8 day;
  186. uint8 hour;
  187. uint8 minute;
  188. uint8 second;
  189. } UTC8TimeType;
  190. typedef enum
  191. {
  192. AT_CMD_TEST = 0,
  193. AT_ATE0,
  194. AT_SIMREADY,
  195. AT_GETICCID,
  196. AT_CGREG,
  197. AT_CSQ,
  198. AT_NETOPEN,
  199. AT_CGIP,
  200. AT_CONNECT,
  201. AT_CONNECTCHK,
  202. AT_SEND,
  203. AT_DISCON,
  204. AT_NETCLOSE,
  205. AT_CGNSSPWR
  206. } ATCmd;
  207. typedef sint8 (*pFunc)(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
  208. sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
  209. typedef struct
  210. {
  211. ATCmd cmd; /*指令序号*/
  212. char *str; /*指令内容*/
  213. pFunc cb; /*对应的执行*/
  214. } ATCmdFunc;
  215. typedef enum
  216. {
  217. PROCESS_TCP_IDLE = 0,
  218. PROCESS_TCP_INIT,
  219. PROCESS_TCP_ATSYS,
  220. PROCESS_TCP_REGCHK,
  221. PROCESS_TCP_CONNECT,
  222. PROCESS_TCP_SEND,
  223. PROCESS_TCP_RECV,
  224. PROCESS_TCP_HEART,
  225. PROCESS_TCP_SLEEP,
  226. PROCESS_TCP_ERROR
  227. } process_Tcp;
  228. typedef struct
  229. {
  230. sint16 TimeCalibCnt[3];
  231. sint16 VersionFeqCnt[3];
  232. sint16 TrkBattFeqCnt[3];
  233. sint16 GpsFeqCnt[3];
  234. sint16 TrkVehichleFeqCnt[3];
  235. sint16 TrkAccMsgFeqCnt[3];
  236. sint16 DebugMsgFeqCnt[3];
  237. }TcpFeq_type;
  238. void Uart_4G_Task(void *pvParameters);
  239. sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDataLen);
  240. #endif /* APPTASKUART1_H_ */