Infypwr_PsuCommObj.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Infypwr_PsuCommObj.h
  3. *
  4. * Created on: 2019年11月26日
  5. * Author: 7564
  6. */
  7. #ifndef INFYPWR_PSUCOMMOBJ_H_
  8. #define INFYPWR_PSUCOMMOBJ_H_
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stdbool.h>
  12. #include <signal.h>
  13. #include <string.h>
  14. #include <fcntl.h>
  15. #include <unistd.h>
  16. #include <sys/socket.h>
  17. #include <sys/ioctl.h>
  18. #include <linux/wireless.h>
  19. #include <linux/can.h>
  20. #include <sys/ipc.h>
  21. #include <sys/shm.h>
  22. #include <sys/time.h>
  23. #include <stdbool.h>
  24. #include <unistd.h>
  25. #include <stdarg.h>
  26. #include <stdio.h> /*標準輸入輸出定義*/
  27. #include <stdlib.h> /*標準函數庫定義*/
  28. #include <unistd.h> /*Unix 標準函數定義*/
  29. #include <fcntl.h> /*檔控制定義*/
  30. #include <termios.h> /*PPSIX 終端控制定義*/
  31. #include <errno.h> /*錯誤號定義*/
  32. #include <errno.h>
  33. #include <string.h>
  34. #include <time.h>
  35. #include <ctype.h>
  36. #include <ifaddrs.h>
  37. #include <math.h>
  38. typedef unsigned char byte;
  39. typedef unsigned short word;
  40. typedef unsigned int unit;
  41. #define INFYPWR_MODULE_CMD 0x02800000 //
  42. #define INFYPWR_GROUP_CMD 0x02C00000 //
  43. #define INFYPWR_MASTER_TXID 0xF0 //
  44. #define INFYPWR_BROADCAST_ID 0x3F //
  45. #define UNFEEDBACK_ID 0
  46. #define FEEDBACK_ID 1
  47. #define SET_MODULE_CMD 0
  48. #define SET_GROUP_CMD 1
  49. extern struct Current_cmd_Proc
  50. {
  51. int none; // 0
  52. int _address_assignment; // 0x02000200
  53. int _get_status; // 0x01000300
  54. int _get_fw_ver; // 0x01000400
  55. int _get_fan_speed; // 0x01000500
  56. int _get_temperature; // 0x01000600
  57. int _get_present_input_vol; // 0x01000700
  58. int _get_present_output; // 0x01000800
  59. int _get_available_cap; // 0x01000900
  60. int _switch_output_pow; // 0x02000A00
  61. int _set_present_output; // 0x02000B00
  62. int _set_fan_speed; // 0x01000C00
  63. int _upgrade_req; // 0x02000F00
  64. int _start_block_trans; // 0x02001000
  65. int _img_trans; // 0x02001100
  66. int _upgrade_finish; // 0x02001200
  67. int _get_serial_number; // 0x01001300
  68. int _set_cooling_water_temp; // 0x02001400
  69. int _get_presnet_input_cur; // 0x01001500
  70. int _get_hw_verstion; // 0x01001600
  71. int _switch_pfc_output; // 0x02001700
  72. int _get_log_size; // 0x01001800
  73. int _get_log_block_checksum; // 0x01001900
  74. int _get_log_block_data; // 0x01001A00
  75. int _switch_custom_info; // 0x02001B00
  76. int _custom_info_transfer; // 0x0E001C00
  77. }Psu_cmd;
  78. enum Receieve_PSU_msg
  79. {
  80. ADDRESS_REQ = 0x08000100,
  81. ACK_ADDRESS_ASSINGMENT = 0x0B000200,
  82. ACK_STATUS = 0x0B000300,
  83. ACK_FIRMWARE_VERSION = 0x0B000400,
  84. ACK_FAN_SPEED = 0x0B000500,
  85. ACK_TEMPERATURE = 0x0B000600,
  86. ACK_PRESENT_INPUT_VOLTAGE = 0x0B000700,
  87. ACK_GET_PRESENT_OUTPUT = 0x0B000800,
  88. ACK_AVAILABLE_CAP = 0x0B000900,
  89. ACK_OUTPUT_POWER_SWITCH = 0x0B000A00,
  90. ACK_SET_PRESENT_OUTPUT = 0x0B000B00,
  91. ACK_SET_FAN_SPEED = 0x0B000C00,
  92. ACK_UPGRADE_REQ = 0x0B000F00,
  93. ACK_START_BLOCK_TRANS = 0x0B001000,
  94. ACK_UPGRADE_FINISH = 0x0B001200,
  95. ACK_GET_SERIAL_NUMBER = 0x0B001300,
  96. ACK_COOLING_WATER_TEMP = 0x0B001400,
  97. ACK_PRESENT_INPUT_CURRENT = 0x0B001500,
  98. ACK_HARDWARE_VERSION = 0x0B001600,
  99. ACK_PFC_OUTPUT_SWITCH = 0x0B001700,
  100. ACK_LOG_SIZE = 0x0B001800,
  101. ACK_LOG_BLOCK_CHECKSUM = 0x0B001900,
  102. ACK_LOG_BLOCK_DATA = 0x0B001A00,
  103. ACK_CUSTOM_INFO_TRANSFER_SWITCH = 0x0B001B00,
  104. CUSTOM_LOG_INFO = 0x0E001C00,
  105. ALARM_NOTIFICATION = 0x0C000D00,
  106. FAULT_NOTIFICATION = 0X0D001D00,
  107. STATUS_NOTIFICATION = 0x0E000E00,
  108. };
  109. enum Receieve_INFYPWR_msg
  110. {
  111. INFYPWR_GET_TOTAL_MOULE_MSG = 0x00020000,
  112. INFYPWR_GET_STATUS_MSG = 0x00040000,
  113. INFYPWR_GET_PRESENT_INPUT_VOLTAGE_MSG = 0x00060000,
  114. INFYPWR_GET_PRESENT_OUTPUT_MSG = 0x00090000,
  115. INFYPWR_GET_AVAILABLE_CAP_MSG = 0x000A0000,
  116. INFYPWR_GET_BARCODE_MSG = 0x000B0000,
  117. INFYPWR_GET_VEXT_IAVAIL_MSG = 0x000C0000,
  118. INFYPWR_GET_MISC_INFO_MSG = 0x000E0000,
  119. INFYPWR_SET_MISC_INFO_MSG = 0x000F0000,
  120. INFYPWR_SET_WALKIN_MODE_MSG = 0x00130000,
  121. INFYPWR_SET_GREEN_KED_FLASH_MSG = 0x00140000,
  122. INFYPWR_SET_GROUP_ASSINGMENT_MSG = 0x00160000,
  123. INFYPWR_SET_SLEEP_MODE_MSG = 0x00190000,
  124. INFYPWR_SET_POWER_SWITCH_MSG = 0x001A0000,
  125. INFYPWR_SET_GROUP_PERSENT_OUTPUT_MSG = 0x001B0000,
  126. INFYPWR_SET_MODULE_PERSENT_OUTPUT_MSG = 0x001C0000,
  127. INFYPWR_SET_ADDRESS_MODE_MSG = 0x001F0000,
  128. };
  129. #define MISC_REQCMD_DC_BOARD_TMP 0x1107
  130. #define MISC_REQCMD_PFC_BOARD_TMP 0x1108
  131. #define MISC_REQCMD_FAN_SPEED 0x1201
  132. #define MISC_SETCMD_FAN_DENOISE_MODE 0x1113
  133. #define MISC_SETCMD_FAN_SPEED 0x1201
  134. #define MISC_SETCMD_AC_INPUT_LIMIT 0x1205
  135. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  136. int CanFd;
  137. pid_t recFork;
  138. /* API Function */
  139. bool InitialCommunication();
  140. //void PsuAddressAssignment(byte phy_addr, char *serial_number, byte real_addr, byte group);
  141. void PsuAddressAssignment(byte phy_addr, byte group);
  142. void GetStatus(byte group, byte address);
  143. void GetFwVersion(byte group, byte address, byte type);
  144. void GetSerialNumber(byte group, byte address); //barcode
  145. void GetVextAndIavail(byte group, byte address);
  146. //void GetFanSpeed(byte group, byte address);
  147. void GetMiscInfo(byte group, byte address, unsigned short CmdType);
  148. //void GetTemperature(byte group, byte address);
  149. void GetPresentInputVol(byte group, byte address);
  150. void GetPresentOutput(byte group, byte address);
  151. void GetPresentInputCurrent(byte group, byte address);
  152. void GetAvailableCap(byte group, byte address, short _outputVol);
  153. void SetPresentOutput(byte group, byte address, float vol, float cur, float AvailableCur);
  154. void SetMiscInfo(byte group, byte address, unsigned short CmdType, unsigned int value);
  155. void EnableGreenLedFlash(byte group, byte address, byte value);
  156. void EnableSleepMode(byte group, byte address, byte value);
  157. void EnableDipAddrMode(void);
  158. void EnableWalkInMode(byte group, byte address, byte value);
  159. void RequestModuleTotalMumbert(void);
  160. /* API Function end */
  161. /* Callback Function */
  162. void GetPsuAddressReq(void *func);
  163. //void GetPsuRequestCallback(byte phy_id, char *serial_number)
  164. void (*get_psu_addr_req)(byte phy_id, char *serial_number);
  165. //ver 1.8 & 1.9
  166. void RefreshSerialNumber(void *func);
  167. //void GetBarCodeCallback(byte address, char *serial_number , unsigned short module_ver)
  168. void (*return_serial_number)(byte address, char *serial_number , unsigned short module_ver);
  169. //ver 1.9
  170. void RefreshVextAndIavail(void *func);
  171. //void SavePresentModeleVextIavailCallback(byte address, unsigned short Vext, unsigned short Iavail)
  172. void (*return_vext_and_iavail)(byte address, unsigned short Vext, unsigned short Iavail);
  173. void RefreshMiscInfo(void *func);
  174. //void GetMiscInfoCallback(byte address, unsigned short CmdType , unsigned int value)
  175. void (*return_misc_info)(byte address, unsigned short CmdType , unsigned int value);
  176. void RefreshStatus(void *func);
  177. //void SaveStatusCallback(byte group, byte address, char cri_temp1, int alarm)
  178. void (*return_status)(byte group, byte address, int alarm, int fault);
  179. void RefreshInputVol(void *func);
  180. //void SavePresentInputVoltageCallback(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3)
  181. void (*return_input_vol)(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3);
  182. void RefreshGetOutput(void *func);
  183. //void SavePresentOutputCallback(byte address, unsigned short out_vol, unsigned short out_cur)
  184. void (*return_get_output)(byte address, unsigned short out_vol, unsigned short out_cur);
  185. void RefreshAvailableCap(void *func);
  186. //void SaveAvailableCapCallback(byte address, unsigned short maxv,unsigned short minv, unsigned short able_cur, unsigned short able_power)
  187. void (*return_available_cap)(byte address, unsigned short maxv,unsigned short minv , unsigned short able_cur,unsigned short able_power);
  188. void RefreshOutputPowerSwitch(void *func);
  189. //void GetOutputPowerSwitchStatusCallback(byte address, unsigned char value)
  190. void (*return_output_pow_switch)(byte address, int result);
  191. /* Callback Function end */
  192. void DisableDipAddrMode(void);
  193. void EnableOutputPower(byte group, byte address, byte value);
  194. #endif /* INFYPWR_PSUCOMMOBJ_H_ */