Infypwr_PsuCommObj.h 6.5 KB

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