123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #ifndef PHIHONG_PSUCOMMOBJ_H_
- #define PHIHONG_PSUCOMMOBJ_H_
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #include <signal.h>
- #include <string.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <sys/socket.h>
- #include <sys/ioctl.h>
- #include <linux/wireless.h>
- #include <linux/can.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/time.h>
- #include <stdbool.h>
- typedef unsigned char byte;
- extern struct Current_cmd_Proc
- {
- int none;
- int _address_assignment;
- int _get_status;
- int _get_fw_ver;
- int _get_fan_speed;
- int _get_temperature;
- int _get_present_input_vol;
- int _get_present_output;
- int _get_available_cap;
- int _switch_output_pow;
- int _set_present_output;
- int _set_fan_speed;
- int _upgrade_req;
- int _start_block_trans;
- int _img_trans;
- int _upgrade_finish;
- int _get_serial_number;
- int _set_cooling_water_temp;
- int _get_presnet_input_cur;
- int _get_hw_verstion;
- int _switch_pfc_output;
- int _get_log_size;
- int _get_log_block_checksum;
- int _get_log_block_data;
- int _switch_custom_info;
- int _custom_info_transfer;
- }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;
- 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);
- 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);
- #endif
|