Phihong_PsuCommObj.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Phihong_PsuCommObj.h
  3. *
  4. * Created on: 2019¦~7¤ë2¤é
  5. * Author: 7564
  6. */
  7. #ifndef PHIHONG_PSUCOMMOBJ_H_
  8. #define PHIHONG_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. extern struct Current_cmd_Proc
  26. {
  27. int none; // 0
  28. int _address_assignment; // 0x02000200
  29. int _get_status; // 0x01000300
  30. int _get_fw_ver; // 0x01000400
  31. int _get_fan_speed; // 0x01000500
  32. int _get_temperature; // 0x01000600
  33. int _get_present_input_vol; // 0x01000700
  34. int _get_present_output; // 0x01000800
  35. int _get_available_cap; // 0x01000900
  36. int _switch_output_pow; // 0x02000A00
  37. int _set_present_output; // 0x02000B00
  38. int _set_fan_speed; // 0x01000C00
  39. int _upgrade_req; // 0x02000F00
  40. int _start_block_trans; // 0x02001000
  41. int _img_trans; // 0x02001100
  42. int _upgrade_finish; // 0x02001200
  43. int _get_serial_number; // 0x01001300
  44. int _set_cooling_water_temp; // 0x02001400
  45. int _get_presnet_input_cur; // 0x01001500
  46. int _get_hw_verstion; // 0x01001600
  47. int _switch_pfc_output; // 0x02001700
  48. int _get_log_size; // 0x01001800
  49. int _get_log_block_checksum; // 0x01001900
  50. int _get_log_block_data; // 0x01001A00
  51. int _switch_custom_info; // 0x02001B00
  52. int _custom_info_transfer; // 0x0E001C00
  53. }Psu_cmd;
  54. enum Receieve_PSU_msg
  55. {
  56. ADDRESS_REQ = 0x08000100,
  57. ACK_ADDRESS_ASSINGMENT = 0x0B000200,
  58. ACK_STATUS = 0x0B000300,
  59. ACK_FIRMWARE_VERSION = 0x0B000400,
  60. ACK_FAN_SPEED = 0x0B000500,
  61. ACK_TEMPERATURE = 0x0B000600,
  62. ACK_PRESENT_INPUT_VOLTAGE = 0x0B000700,
  63. ACK_GET_PRESENT_OUTPUT = 0x0B000800,
  64. ACK_AVAILABLE_CAP = 0x0B000900,
  65. ACK_OUTPUT_POWER_SWITCH = 0x0B000A00,
  66. ACK_SET_PRESENT_OUTPUT = 0x0B000B00,
  67. ACK_SET_FAN_SPEED = 0x0B000C00,
  68. ACK_UPGRADE_REQ = 0x0B000F00,
  69. ACK_START_BLOCK_TRANS = 0x0B001000,
  70. ACK_UPGRADE_FINISH = 0x0B001200,
  71. ACK_GET_SERIAL_NUMBER = 0x0B001300,
  72. ACK_COOLING_WATER_TEMP = 0x0B001400,
  73. ACK_PRESENT_INPUT_CURRENT = 0x0B001500,
  74. ACK_HARDWARE_VERSION = 0x0B001600,
  75. ACK_PFC_OUTPUT_SWITCH = 0x0B001700,
  76. ACK_LOG_SIZE = 0x0B001800,
  77. ACK_LOG_BLOCK_CHECKSUM = 0x0B001900,
  78. ACK_LOG_BLOCK_DATA = 0x0B001A00,
  79. ACK_CUSTOM_INFO_TRANSFER_SWITCH = 0x0B001B00,
  80. CUSTOM_LOG_INFO = 0x0E001C00,
  81. ALARM_NOTIFICATION = 0x0C000D00,
  82. FAULT_NOTIFICATION = 0X0D001D00,
  83. STATUS_NOTIFICATION = 0x0E000E00,
  84. };
  85. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  86. int CanFd;
  87. pid_t recFork;
  88. /* API Function */
  89. bool InitialCommunication();
  90. void PsuAddressAssignment(byte phy_addr, char *serial_number, byte real_addr, byte group);
  91. void GetStatus(byte group, byte address);
  92. void GetFwVersion(byte group, byte address, byte type);
  93. void GetSerialNumber(byte group, byte address);
  94. void GetFanSpeed(byte group, byte address);
  95. void GetTemperature(byte group, byte address);
  96. void GetPresentInputVol(byte group, byte address);
  97. void GetPresentOutput(byte group, byte address);
  98. void GetPresentInputCurrent(byte group, byte address);
  99. void GetAvailableCap(byte group, byte address, short _outputVol);
  100. void SetPresentOutput(byte group, byte address, short vol, short cur, unsigned short AvailableCur, byte derating);
  101. void EnableOutputPower(byte group, byte address, byte value);
  102. /* API Function end */
  103. /* Callback Function */
  104. void GetPsuAddressReq(void *func);
  105. void (*get_psu_addr_req)(byte phy_id, char *serial_number);
  106. void RefreshStatus(void *func);
  107. void (*return_status)(byte group, byte address, int alarm, int fault);
  108. void RefreshFanSpeed(void *func);
  109. void (*return_fan_speed)(byte group, byte address, unsigned short fan1, unsigned short fan2, unsigned short fan3, unsigned short fan4);
  110. void RefreshTemp(void *func);
  111. void (*return_temp)(byte group, byte address, char cri_temp1, char cri_temp2, char cri_temp3, char ex_temp, char in_temp1, char in_temp2, char out_temp);
  112. void RefreshInputVol(void *func);
  113. void (*return_input_vol)(byte group, byte address, byte vol_type, unsigned short vol1, unsigned short vol2, unsigned short vol3);
  114. void RefreshGetOutput(void *func);
  115. void (*return_get_output)(byte group, byte address, unsigned short out_vol, unsigned short out_cur);
  116. void RefreshInputCur(void *func);
  117. void (*return_input_cur)(byte group, byte address, unsigned short in_cur1, unsigned short in_cur2, unsigned short in_cur3);
  118. void RefreshAvailableCap(void *func);
  119. void (*return_available_cap)(byte group, byte address, unsigned short able_power, unsigned short able_cur);
  120. void RefreshAlarmNotify(void *func);
  121. void (*return_alarm_code)(byte group, byte address, unsigned char *alarm);
  122. void RefreshFaultNotify(void *func);
  123. void (*return_fault_code)(byte group, byte address, int fault);
  124. void RefreshStatusNotify(void *func);
  125. void (*return_status_code)(byte group, byte address, byte st_machine, unsigned short out_vol, unsigned short out_cur);
  126. void RefreshSerialNumber(void *func);
  127. void (*return_get_serial_number)(byte group, byte address, unsigned char packageIndex, unsigned char *data);
  128. void RefreshOutputPowerSwitch(void *func);
  129. void (*return_output_pow_switch)(byte group, byte address, int result);
  130. void RefreshFWVersion(void *func);
  131. void (*return_fw_version)(byte group, byte address, unsigned char packageIndex, unsigned char type, unsigned char *data);
  132. /* Callback Function end */
  133. #endif /* PHIHONG_PSUCOMMOBJ_H_ */