123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- /*
- * Phihong_PsuCommObj.h
- PhGroup_PsuCommObj
- * Created on: 2022年02月22日
- * Author: 8274
- */
- #ifndef TESTONE_PSUCOMMOBJ_H_
- #define TESTONE_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 <linux/can/raw.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/time.h>
- #include <stdbool.h>
- #include <unistd.h>
- #include <stdarg.h>
- #include <stdio.h> /*標準輸入輸出定義*/
- #include <stdlib.h> /*標準函數庫定義*/
- #include <unistd.h> /*Unix 標準函數定義*/
- #include <fcntl.h> /*檔控制定義*/
- #include <termios.h> /*PPSIX 終端控制定義*/
- #include <errno.h> /*錯誤號定義*/
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #include <ifaddrs.h>
- #include <math.h>
- #define SYSTEM_CMD 0x3F
- #define DIR_CSU_to_Slave 0x5
- #define DIR_CSU_to_GrpMaster 0x6
- #define DIR_GrpMaster_to_CSU 0xE
- #define DIR_Slave_to_CSU 0xD
- #define SlaveAdd_Position 0
- #define GroupAdd_Position 6
- #define ALL_Group 0x3F
- #define ALL_Slave 0x3F
- #define PUS_UNLOCK_CMD 0xA5
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
- #define CMD_DELAY_TIME 25000
- typedef unsigned char byte;
- typedef unsigned short word;
- typedef unsigned int unit;
- int CanFd;
- pid_t recFork;
- typedef union
- {
- unsigned int PwrMessage;
- struct
- {
- unsigned int SlaveAddress:6; // slave address
- unsigned int SlaveGroup:6; // slave group
- unsigned int DIR:4; // message direction
- unsigned int MessageID:8; // message ID type
- unsigned int Status:4; // PSU status
- unsigned int RDY:1; // PSU stanby
- }PHBits;
- }PH_PwrFrame; //onetry
- typedef enum //onetry
- {
- PH_PSU_POWER_ON = 0xA1,
- PH_PSU_POWER_OFF = 0x00,
- }PH_Pwr_POWER_CMD;
- typedef enum
- {
- PH_PSU_RCmd_GetGroupModuleCount = 0x03,
- PH_PSU_RCmd_GetAlarmFault = 0x04,
- PH_PSU_RCmd_GetModuleVersion = 0x05,
- PH_PSU_RCmd_GetTemperature = 0x06,
- PH_PSU_RCmd_GetACInputVoltage = 0x07,
- PH_PSU_RCmd_GetACInputCurrent = 0x08,
- PH_PSU_RCmd_GetPresentOutput = 0x09,
- PH_PSU_RCmd_GetErrorRecord = 0x0A,
- PH_PSU_WCmd_ModulePowerOnOff = 0x41,
- PH_PSU_WCmd_SetOutputCommand = 0x42,
- PH_PSU_WCmd_UnlockPsuCommand = 0x43,
- PH_PSU_Ack_Msg = 0x80,
- }PHPwrCommand;
- typedef enum
- {
- PH_FW_DD_App = 0x01,
- PH_FW_PFC_App = 0x02,
- PH_FW_DD_Bootloader = 0x03,
- PH_FW_PFC_Bootloader = 0x04,
- }PHPwrFwVer;
- /*Initialization*/
- pid_t InitialCommunication(void);
- /*Set Cmd*/
- void SwitchPower(byte group, byte value);
- void SinglePsuPower(byte address, byte value);
- void SwitchPower_On(byte group);
- void SwitchPower_Off(byte group);
- void SinglePsuPower_On(byte address);
- void SinglePsuPower_Off(byte address);
- void SleepMode(byte group, byte value);
- void FlashLed(byte group, byte value);
- void SingleFlashLed(byte address, byte value);
- void FlashLed_Static(byte group);
- void FlashLed_Blinking(byte group);
- void SingleFlashLed_Static(byte address);
- void SingleFlashLed_Blinking(byte address);
- void PresentOutputVol(byte group, int voltage, int current);
- void SingleOutputVol(byte address, int voltage, int current);
- void FanNoiseInfo(byte group, byte value);
- void SetWalkInConfig(byte group, byte enable, byte sec);
- void SetDipSwitchMode();
- void UnlockPsuAlarm(byte full_address);
- /*Ver : 9.06 used*/
- void SetDirModulePresentOutput(byte group, int voltage, int current, byte _switch, byte _interRelay);
- /*Get Cmd*/
- void GetStatus(byte group);
- void GetFanSpeed(byte group);
- void GetDcTemperature(byte group);
- void GetPfcTemperature(byte group);
- void GetModuleCount(byte group);
- void GetSysModuleCount(void);
- void GetModuleVer(byte group, byte type);
- void GetAllModuleVer(byte group);
- void GetModuleCap(byte group);
- void GetModuleBarCode(byte group);
- void GetModuleInputVol(byte group);
- void GetModuleInputCur(byte group);
- void GetModuleIavailable(byte group, unsigned short voltage);
- void GetModuleOutput(byte group);
- void GetModuleOutputF(byte group);
- void GetErrorRecord(byte group);
- /*Upgrade*/
- void ChangePsuBaudrate(short baudrate);
- /* Callback Function */
- void RefreshPsuIndex(int (*func)(byte group, byte gIndex));
- int (*return_psuIndex)(byte group, byte gIndex);
- void RefreshGroup(void *func);
- void (*return_group)(byte group, byte psu_index, unsigned short full_address);
- void RefreshInfyPwrAlarmFlag(void *func);
- void (*return_infy_pwr_alarm_flag)(byte address, byte state_2, byte state_1, byte state_0);
- void RefreshPhPwrAlarmFlag(void *func);
- void (*return_ph_pwr_alarm_flag)(byte address, unsigned int status, unsigned int alarm_1, unsigned int alarm_0);
- void RefreshAlarmStatus(void *func);
- void (*return_alarm_status)(byte address, unsigned int status);
- void RefreshAmbient(void *func);
- void (*return_ambient)(byte address, char temp);
- void RefreshModuleCount(void *func);
- void (*return_module_count)(byte group, byte count, bool summation);
- void RefreshSysModuleCount(void *func);
- void (*return_sys_module_count)(byte group, byte count);
- void RefreshAvailableCap(void *func);
- void (*return_available_cap)(byte address, short maxVol, short minVol, short maxCur, short totalPow);
- void RefreshFwDcVersion(void *func);
- void (*return_fw_dc_version)(byte address, char *dcSwVer);
- void RefreshFwPfcVersion(void *func);
- void (*return_fw_pfc_version)(byte address, char *pfcSwVer);
- void RefreshInputVol(void *func);
- void (*return_input_vol)(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3);
- void RefreshInputCur(void *func);
- void (*return_input_cur)(byte address, unsigned short cur1, unsigned short cur2, unsigned short cur3);
- void RefreshGetOutput(void *func);
- void (*return_get_output)(byte address, unsigned short outVol, unsigned short outCur);
- void RefreshGetOutputF(void *func);
- void (*return_get_output_float)(byte group, float outVol, float outCur);
- void RefreshGetModuleOutput(void *func);
- void (*return_module_output)(byte address, float outVol, float outCur);
- void RefreshGetErrorRecord(void *func);
- void (*return_error_record)(byte address, byte count_down, byte *error_record);
- void RefreshFanSpeedInfo(void *func);
- void (*return_fan_speed)(byte address, unsigned int fanSpeed);
- void RefreshInletTemp(void *func);
- void (*return_inlet_temp)(byte address, char temp);
- void RefreshExletTemp(void *func);
- void (*return_exlet_temp)(byte address, char temp);
- void RefreshOutletTemp(void *func);
- void (*return_outlet_temp)(byte address, char temp);
- void RefreshOtherTemp(void *func);
- void (*return_other_temp)(byte address, char temp1, char temp2, char temp3, char temp4);
- void RefreshIavailable(void *func);
- void (*return_iavail_info)(byte address, unsigned short Iavail, unsigned short Vext);
- /*Test mode used*/
- void AutoMode_RefreshOutputAndTemp(void *func);
- void (*return_output_temp)(byte address, unsigned short outputVol,
- unsigned short outputCur, unsigned short outputPower, unsigned char Temperature);
- void AutoMode_RefreshModuleStatus(void *func);
- void (*return_module_status)(byte address, unsigned char isErr, unsigned char status,
- unsigned char err1, unsigned char err2, unsigned char err3, unsigned char err4);
- void AutoMode_RefreshModuleInput(void *func);
- void (*return_module_input)(byte address, unsigned short inputR,
- unsigned short inputS, unsigned short inputT);
- /* Callback Function end */
- #endif
|