Infypwr_PsuCommObj.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 SET_MODULE_CMD 0
  46. #define SET_GROUP_CMD 1
  47. extern struct Current_cmd_Proc
  48. {
  49. int none; // 0
  50. int _address_assignment; // 0x02000200
  51. int _get_status; // 0x01000300
  52. int _get_fw_ver; // 0x01000400
  53. int _get_fan_speed; // 0x01000500
  54. int _get_temperature; // 0x01000600
  55. int _get_present_input_vol; // 0x01000700
  56. int _get_present_output; // 0x01000800
  57. int _get_available_cap; // 0x01000900
  58. int _switch_output_pow; // 0x02000A00
  59. int _set_present_output; // 0x02000B00
  60. int _set_fan_speed; // 0x01000C00
  61. int _upgrade_req; // 0x02000F00
  62. int _start_block_trans; // 0x02001000
  63. int _img_trans; // 0x02001100
  64. int _upgrade_finish; // 0x02001200
  65. int _get_serial_number; // 0x01001300
  66. int _set_cooling_water_temp; // 0x02001400
  67. int _get_presnet_input_cur; // 0x01001500
  68. int _get_hw_verstion; // 0x01001600
  69. int _switch_pfc_output; // 0x02001700
  70. int _get_log_size; // 0x01001800
  71. int _get_log_block_checksum; // 0x01001900
  72. int _get_log_block_data; // 0x01001A00
  73. int _switch_custom_info; // 0x02001B00
  74. int _custom_info_transfer; // 0x0E001C00
  75. }Psu_cmd;
  76. enum Receieve_PSU_msg
  77. {
  78. ADDRESS_REQ = 0x08000100,
  79. ACK_ADDRESS_ASSINGMENT = 0x0B000200,
  80. ACK_STATUS = 0x0B000300,
  81. ACK_FIRMWARE_VERSION = 0x0B000400,
  82. ACK_FAN_SPEED = 0x0B000500,
  83. ACK_TEMPERATURE = 0x0B000600,
  84. ACK_PRESENT_INPUT_VOLTAGE = 0x0B000700,
  85. ACK_GET_PRESENT_OUTPUT = 0x0B000800,
  86. ACK_AVAILABLE_CAP = 0x0B000900,
  87. ACK_OUTPUT_POWER_SWITCH = 0x0B000A00,
  88. ACK_SET_PRESENT_OUTPUT = 0x0B000B00,
  89. ACK_SET_FAN_SPEED = 0x0B000C00,
  90. ACK_UPGRADE_REQ = 0x0B000F00,
  91. ACK_START_BLOCK_TRANS = 0x0B001000,
  92. ACK_UPGRADE_FINISH = 0x0B001200,
  93. ACK_GET_SERIAL_NUMBER = 0x0B001300,
  94. ACK_COOLING_WATER_TEMP = 0x0B001400,
  95. ACK_PRESENT_INPUT_CURRENT = 0x0B001500,
  96. ACK_HARDWARE_VERSION = 0x0B001600,
  97. ACK_PFC_OUTPUT_SWITCH = 0x0B001700,
  98. ACK_LOG_SIZE = 0x0B001800,
  99. ACK_LOG_BLOCK_CHECKSUM = 0x0B001900,
  100. ACK_LOG_BLOCK_DATA = 0x0B001A00,
  101. ACK_CUSTOM_INFO_TRANSFER_SWITCH = 0x0B001B00,
  102. CUSTOM_LOG_INFO = 0x0E001C00,
  103. ALARM_NOTIFICATION = 0x0C000D00,
  104. FAULT_NOTIFICATION = 0X0D001D00,
  105. STATUS_NOTIFICATION = 0x0E000E00,
  106. };
  107. enum Receieve_INFYPWR_msg
  108. {
  109. INFYPWR_GET_TOTAL_MOULE_MSG = 0x00020000,
  110. INFYPWR_GET_STATUS_MSG = 0x00040000,
  111. INFYPWR_GET_PRESENT_INPUT_VOLTAGE_MSG = 0x00060000,
  112. INFYPWR_GET_PRESENT_OUTPUT_MSG = 0x00090000,
  113. INFYPWR_GET_AVAILABLE_CAP_MSG = 0x000A0000,
  114. INFYPWR_SET_WALKIN_MODE_MSG = 0x00130000,
  115. INFYPWR_SET_GREEN_KED_FLASH_MSG = 0x00140000,
  116. INFYPWR_SET_GROUP_ASSINGMENT_MSG = 0x00160000,
  117. INFYPWR_SET_SLEEP_MODE_MSG = 0x00190000,
  118. INFYPWR_SET_POWER_SWITCH_MSG = 0x001A0000,
  119. INFYPWR_SET_GROUP_PERSENT_OUTPUT_MSG = 0x001B0000,
  120. INFYPWR_SET_MODULE_PERSENT_OUTPUT_MSG = 0x001C0000,
  121. INFYPWR_SET_ADDRESS_MODE_MSG = 0x001F0000,
  122. };
  123. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  124. int CanFd;
  125. pid_t recFork;
  126. /* API Function */
  127. bool InitialCommunication();
  128. //void PsuAddressAssignment(byte phy_addr, char *serial_number, byte real_addr, byte group);
  129. void PsuAddressAssignment(byte phy_addr, byte group);
  130. void GetStatus(byte group, byte address);
  131. void GetFwVersion(byte group, byte address, byte type);
  132. void GetSerialNumber(byte group, byte address);
  133. void GetFanSpeed(byte group, byte address);
  134. void GetTemperature(byte group, byte address);
  135. void GetPresentInputVol(byte group, byte address);
  136. void GetPresentOutput(byte group, byte address);
  137. void GetPresentInputCurrent(byte group, byte address);
  138. void GetAvailableCap(byte group, byte address, short _outputVol);
  139. void SetPresentOutput(byte group, byte address, float vol, float cur, float AvailableCur);
  140. void EnableOutputPower(byte group, byte address, byte value);
  141. void EnableGreenLedFlash(byte group, byte address, byte value);
  142. void EnableSleepMode(byte group, byte address, byte value);
  143. void EnableDipAddrMode(byte group, byte address, byte value);
  144. void EnableWalkInMode(byte group, byte address, byte value);
  145. void RequestModuleTotalMumbert(void);
  146. /* API Function end */
  147. /* Callback Function */
  148. void GetPsuAddressReq(void *func);
  149. void (*get_psu_addr_req)(byte phy_id, char *serial_number);
  150. void RefreshStatus(void *func);
  151. void (*return_status)(byte group, byte address, int alarm, int fault);
  152. void RefreshInputVol(void *func);
  153. void (*return_input_vol)(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3);
  154. void RefreshGetOutput(void *func);
  155. void (*return_get_output)(byte address, unsigned short out_vol, unsigned short out_cur);
  156. void RefreshAvailableCap(void *func);
  157. void (*return_available_cap)(byte address, unsigned short maxv,unsigned short minv , unsigned short able_cur,unsigned short able_power);
  158. void RefreshOutputPowerSwitch(void *func);
  159. void (*return_output_pow_switch)(byte address, int result);
  160. /* Callback Function end */
  161. #endif /* INFYPWR_PSUCOMMOBJ_H_ */