Kommunikation hat funktioniert
This commit is contained in:
52
can/can_client.h
Executable file
52
can/can_client.h
Executable file
@@ -0,0 +1,52 @@
|
||||
#if !defined(__CAN_CLIENT_H__)
|
||||
#define __CAN_CLIENT_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <linux/can.h>
|
||||
#include <linux/can/raw.h>
|
||||
|
||||
#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 5
|
||||
#define MOTOR_PWR_MAX_PCT 100
|
||||
#define MOTOR_PWR_STEP 14
|
||||
|
||||
struct MOTOR_CONTROL_DATA
|
||||
{
|
||||
int iMotorGear;
|
||||
int iMotorPower;
|
||||
int iMotorPowerPct;
|
||||
};
|
||||
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);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user