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

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. #include "serial.h"
  5. #include "steering_gear.h"
  6. PORT serial_port;
  7. int serial_com_id;
  8. int main(int argc, char *argv[]) {
  9. int i = 0;
  10. /* 参数判断 */
  11. if (argc != 2) {
  12. printf("please input com id\n");
  13. return -1;
  14. }
  15. printf("Serial port number is:%s\n", argv[1]);
  16. /* 字符串转int类型 */
  17. serial_com_id = atoi(argv[1]);
  18. if (serial_com_id == 0) { /* */
  19. /* 转换错误 */
  20. printf("The serial port id is incorrect\n");
  21. return -2;
  22. }
  23. serial_port = serial_init(serial_com_id, 115200, 8, 1, 0);
  24. while (1) {
  25. steering_gear_set_position(serial_port, (i % 5));
  26. i = i + 1;
  27. printf("i:%d\n", i);
  28. Sleep(1000);
  29. }
  30. return 0;
  31. }