Module_PhBackend.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Module_PhBackend.h
  3. *
  4. * Created on: 2020/6/11
  5. * Author: foluswen
  6. */
  7. #ifndef MODULE_PHBACKEND_H_
  8. #define MODULE_PHBACKEND_H_
  9. #include <sys/time.h>
  10. #include <sys/timeb.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/shm.h>
  19. #include <sys/mman.h>
  20. #include <linux/wireless.h>
  21. #include <arpa/inet.h>
  22. #include <netinet/in.h>
  23. #include <unistd.h>
  24. #include <stdarg.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <termios.h>
  30. #include <errno.h>
  31. #include <errno.h>
  32. #include <string.h>
  33. #include <time.h>
  34. #include <ctype.h>
  35. #include <ifaddrs.h>
  36. #include <sys/types.h>
  37. #include <sys/socket.h>
  38. #include <netinet/in.h>
  39. #include <netdb.h>
  40. #include <error.h>
  41. #include "define.h"
  42. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  43. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  44. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  45. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  46. #define PASS 1
  47. #define FAIL -1
  48. #define ON 1
  49. #define OFF 0
  50. #define true 1
  51. #define false 0
  52. #define PROTOCOL_VER 0x00
  53. struct Message
  54. {
  55. int size;
  56. uint8_t buffer[2048];
  57. };
  58. struct PH_Backend_Info
  59. {
  60. uint32_t st_hearbeat;
  61. uint32_t st_status[3];
  62. uint32_t interval_heartbeat;
  63. uint32_t interval_status;
  64. uint8_t retry_heartbeat;
  65. uint16_t sn_heartbeat;
  66. uint8_t counter_heartbeat_retry;
  67. uint8_t isSignin:1;
  68. }backend_info;
  69. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  70. struct StatusCodeData *ShmStatusCodeData;
  71. uint16_t message_header = 0xffff;
  72. uint8_t server_addr[512];
  73. uint16_t server_port;
  74. uint16_t server_cmd_sn = 0x0000;;
  75. uint16_t server_user_id = 0xffff;
  76. extern void handle_cmd_1001(struct Message *in, struct Message *out);
  77. extern void handle_cmd_1003(struct Message *in, struct Message *out);
  78. extern void handle_cmd_1005(struct Message *in, struct Message *out);
  79. extern void handle_cmd_1101(struct Message *in);
  80. extern void handle_cmd_1103(struct Message *in);
  81. extern void handle_cmd_1105(struct Message *in);
  82. extern void handle_cmd_2303(struct Message *in, struct Message *out);
  83. extern void handle_cmd_2305(struct Message *in, struct Message *out);
  84. extern void create_Cmd_1002(struct Message *out, uint8_t cmd_type, uint32_t address, uint32_t count);
  85. extern void create_Cmd_1004(struct Message *out, uint8_t cmd_type, uint32_t address, uint8_t *data, uint8_t data_len);
  86. extern void create_Cmd_1006(struct Message *out, uint8_t gun_index, uint32_t address, uint8_t count, uint8_t isExecuted);
  87. extern void create_Cmd_1102(struct Message *out);
  88. extern void create_Cmd_1104(struct Message *out, uint8_t gun_index);
  89. extern void create_Cmd_1106(struct Message *out);
  90. extern void create_Cmd_2304(struct Message *out);
  91. extern void create_Cmd_2306(struct Message *out);
  92. #endif /* MODULE_PHBACKEND_H_ */