/* * Phihong_PsuCommObj.h * * Created on: 2019¦~7¤ë2¤é * Author: 7564 */ #ifndef PHIHONG_PSUCOMMOBJ_H_ #define PHIHONG_PSUCOMMOBJ_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef unsigned char byte; extern struct Current_cmd_Proc { int none; // 0 int _address_assignment; // 0x02000200 int _get_status; // 0x01000300 int _get_fw_ver; // 0x01000400 int _get_fan_speed; // 0x01000500 int _get_temperature; // 0x01000600 int _get_present_input_vol; // 0x01000700 int _get_present_output; // 0x01000800 int _get_available_cap; // 0x01000900 int _switch_output_pow; // 0x02000A00 int _set_present_output; // 0x02000B00 int _set_fan_speed; // 0x01000C00 int _upgrade_req; // 0x02000F00 int _start_block_trans; // 0x02001000 int _img_trans; // 0x02001100 int _upgrade_finish; // 0x02001200 int _get_serial_number; // 0x01001300 int _set_cooling_water_temp; // 0x02001400 int _get_presnet_input_cur; // 0x01001500 int _get_hw_verstion; // 0x01001600 int _switch_pfc_output; // 0x02001700 int _get_log_size; // 0x01001800 int _get_log_block_checksum; // 0x01001900 int _get_log_block_data; // 0x01001A00 int _switch_custom_info; // 0x02001B00 int _custom_info_transfer; // 0x0E001C00 }Psu_cmd; enum Receieve_PSU_msg { ADDRESS_REQ = 0x08000100, ACK_ADDRESS_ASSINGMENT = 0x0B000200, ACK_STATUS = 0x0B000300, ACK_FIRMWARE_VERSION = 0x0B000400, ACK_FAN_SPEED = 0x0B000500, ACK_TEMPERATURE = 0x0B000600, ACK_PRESENT_INPUT_VOLTAGE = 0x0B000700, ACK_GET_PRESENT_OUTPUT = 0x0B000800, ACK_AVAILABLE_CAP = 0x0B000900, ACK_OUTPUT_POWER_SWITCH = 0x0B000A00, ACK_SET_PRESENT_OUTPUT = 0x0B000B00, ACK_SET_FAN_SPEED = 0x0B000C00, ACK_UPGRADE_REQ = 0x0B000F00, ACK_START_BLOCK_TRANS = 0x0B001000, ACK_UPGRADE_FINISH = 0x0B001200, ACK_GET_SERIAL_NUMBER = 0x0B001300, ACK_COOLING_WATER_TEMP = 0x0B001400, ACK_PRESENT_INPUT_CURRENT = 0x0B001500, ACK_HARDWARE_VERSION = 0x0B001600, ACK_PFC_OUTPUT_SWITCH = 0x0B001700, ACK_LOG_SIZE = 0x0B001800, ACK_LOG_BLOCK_CHECKSUM = 0x0B001900, ACK_LOG_BLOCK_DATA = 0x0B001A00, ACK_CUSTOM_INFO_TRANSFER_SWITCH = 0x0B001B00, CUSTOM_LOG_INFO = 0x0E001C00, ALARM_NOTIFICATION = 0x0C000D00, FAULT_NOTIFICATION = 0X0D001D00, STATUS_NOTIFICATION = 0x0E000E00, }; #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0])) int CanFd; pid_t recFork; /* API Function */ bool InitialCommunication(); void PsuAddressAssignment(byte phy_addr, char *serial_number, byte real_addr, byte group); void GetStatus(byte group, byte address); void GetFwVersion(byte group, byte address, byte type); void GetSerialNumber(byte group, byte address); void GetFanSpeed(byte group, byte address); void GetTemperature(byte group, byte address); void GetPresentInputVol(byte group, byte address); void GetPresentOutput(byte group, byte address); void GetPresentInputCurrent(byte group, byte address); void GetAvailableCap(byte group, byte address, short _outputVol); void SetPresentOutput(byte group, byte address, short vol, short cur, unsigned short AvailableCur, byte derating); void EnableOutputPower(byte group, byte address, byte value); /* API Function end */ /* Callback Function */ void GetPsuAddressReq(void *func); void (*get_psu_addr_req)(byte phy_id, char *serial_number); void RefreshStatus(void *func); void (*return_status)(byte group, byte address, int alarm, int fault); void RefreshFanSpeed(void *func); void (*return_fan_speed)(byte group, byte address, unsigned short fan1, unsigned short fan2, unsigned short fan3, unsigned short fan4); void RefreshTemp(void *func); 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); void RefreshInputVol(void *func); void (*return_input_vol)(byte group, byte address, byte vol_type, unsigned short vol1, unsigned short vol2, unsigned short vol3); void RefreshGetOutput(void *func); void (*return_get_output)(byte group, byte address, unsigned short out_vol, unsigned short out_cur); void RefreshInputCur(void *func); void (*return_input_cur)(byte group, byte address, unsigned short in_cur1, unsigned short in_cur2, unsigned short in_cur3); void RefreshAvailableCap(void *func); void (*return_available_cap)(byte group, byte address, unsigned short able_power, unsigned short able_cur); void RefreshAlarmNotify(void *func); void (*return_alarm_code)(byte group, byte address, unsigned char *alarm); void RefreshFaultNotify(void *func); void (*return_fault_code)(byte group, byte address, int fault); void RefreshStatusNotify(void *func); void (*return_status_code)(byte group, byte address, byte st_machine, unsigned short out_vol, unsigned short out_cur); void RefreshSerialNumber(void *func); void (*return_get_serial_number)(byte group, byte address, unsigned char packageIndex, unsigned char *data); void RefreshOutputPowerSwitch(void *func); void (*return_output_pow_switch)(byte group, byte address, int result); void RefreshFWVersion(void *func); void (*return_fw_version)(byte group, byte address, unsigned char packageIndex, unsigned char type, unsigned char *data); /* Callback Function end */ #endif /* PHIHONG_PSUCOMMOBJ_H_ */