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.

35 lines
684 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. /* 参数判断 */
  10. if (argc != 2) {
  11. printf("please input com id\n");
  12. return -1;
  13. }
  14. printf("Serial port number is:%s\n", argv[1]);
  15. /* 字符串转int类型 */
  16. serial_com_id = atoi(argv[1]);
  17. if (serial_com_id == 0) { /* */
  18. /* 转换错误 */
  19. printf("The serial port id is incorrect\n");
  20. return -2;
  21. }
  22. serial_port = serial_init(serial_com_id, 115200, 8, 1, 0);
  23. while (1) {
  24. Serial_SendData(serial_port, "hello finny", 12);
  25. Sleep(1000);
  26. }
  27. return 0;
  28. }