2019-10-01 11:32:49 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
2022-02-09 21:05:39 +00:00
|
|
|
#include <unistd.h>
|
2019-10-01 11:32:49 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int dir;
|
|
|
|
int angle;
|
|
|
|
int speed;
|
|
|
|
} motorDrvManualConfig_t;
|
|
|
|
|
|
|
|
#define ASUS_MOTOR_NAME_SIZE 32
|
|
|
|
#define ASUS_MOTOR_DATA_SIZE 4
|
|
|
|
|
|
|
|
#define ASUS_MOTOR_DRV_DEV_PATH ("/dev/asusMotoDrv")
|
|
|
|
#define ASUS_MOTOR_DRV_IOC_MAGIC ('M')
|
|
|
|
#define ASUS_MOTOR_DRV_AUTO_MODE _IOW(ASUS_MOTOR_DRV_IOC_MAGIC, 1, int)
|
|
|
|
#define ASUS_MOTOR_DRV_MANUAL_MODE _IOW(ASUS_MOTOR_DRV_IOC_MAGIC, 2, motorDrvManualConfig_t)
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
if(argc != 2) return 1;
|
|
|
|
int fd = open("/dev/asusMotoDrv", O_RDWR);
|
|
|
|
motorDrvManualConfig_t cfg;
|
|
|
|
cfg.dir = atoi(argv[1]);
|
|
|
|
cfg.angle = 180;
|
|
|
|
cfg.speed = 4;
|
|
|
|
|
|
|
|
ioctl(fd, ASUS_MOTOR_DRV_MANUAL_MODE, &cfg);
|
2022-02-09 21:05:39 +00:00
|
|
|
close(fd);
|
2019-10-01 11:32:49 +00:00
|
|
|
}
|