#if !defined(__CAN_CLIENT_H__) #define __CAN_CLIENT_H__ #include #include #include #include #include #include #include #include #include #include #define MOTOR_COUNT 2 // motor gear: 0x7C=reverse, 0x7D=neutral, 0x7E=forward #define MOTOR_GEAR_REVERSE 0x7C #define MOTOR_GEAR_NEUTRAL 0x7D #define MOTOR_GEAR_FORWARD 0x7E #define MOTOR_PWR_MIN_PCT 15 #define MOTOR_PWR_MAX_PCT 100 #define MOTOR_PWR_STEP 12 struct MOTOR_CONTROL_DATA { int iMotorGear; int iMotorPower; int iMotorPowerPct; unsigned char nSwitchState; int iActualMotorPowerW; }; extern struct MOTOR_CONTROL_DATA motctrl[MOTOR_COUNT]; struct CAN_INTERFACE_DATA { int socket; char iface_name[20]; struct ifreq ifr; struct sockaddr_can addr; }; int Can_OpenInterface(int iMotorIndex, const char * ifacename); void Can_CloseInterface(int iMotorIndex); void Can_SetMotorGear(int iMotorIndex, int iGear); void Can_SetMotorPower(int iMotorIndex, int iPower); void Can_TransmitMotorGear(int iMotorIndex); void Can_TransmitMotorPower(int iMotorIndex); void Can_ReadData(int iMotorIndex); void Can_Read_Manu_PGN(int iMotorIndex, struct can_frame *frame); void Can_Read_Manu_PGN2(int iMotorIndex, struct can_frame *frame); #endif