You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
738 B
38 lines
738 B
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <windows.h>
|
|
|
|
#include "serial.h"
|
|
#include "steering_gear.h"
|
|
|
|
PORT serial_port;
|
|
int serial_com_id;
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int i = 0;
|
|
/* 参数判断 */
|
|
if (argc != 2) {
|
|
printf("please input com id\n");
|
|
return -1;
|
|
}
|
|
printf("Serial port number is:%s\n", argv[1]);
|
|
|
|
/* 字符串转int类型 */
|
|
serial_com_id = atoi(argv[1]);
|
|
if (serial_com_id == 0) { /* */
|
|
/* 转换错误 */
|
|
printf("The serial port id is incorrect\n");
|
|
return -2;
|
|
}
|
|
|
|
serial_port = serial_init(serial_com_id, 115200, 8, 1, 0);
|
|
|
|
while (1) {
|
|
steering_gear_set_position(serial_port, (i % 5));
|
|
i = i + 1;
|
|
printf("i:%d\n", i);
|
|
Sleep(1000);
|
|
}
|
|
|
|
return 0;
|
|
}
|