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.
46 lines
894 B
46 lines
894 B
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <windows.h>
|
|
|
|
#include "serial.h"
|
|
|
|
int serial_com_id;
|
|
|
|
int serial_test() {
|
|
PORT COM1;
|
|
char buff[1024] = {0};
|
|
int rcv_len = 0;
|
|
|
|
printf("Start open com%d\n", serial_com_id);
|
|
COM1 = serial_init(serial_com_id, 115200, 8, 1, 0);
|
|
|
|
while (1) {
|
|
Serial_SendData(COM1, "hello finny", 12);
|
|
memset(buff, 0, 1024);
|
|
rcv_len = Serial_ReciveData(COM1, buff, 1024);
|
|
printf("rcv:%s\n", buff);
|
|
Sleep(1);
|
|
}
|
|
}
|
|
int main(int argc, char *argv[]) {
|
|
/* 参数判断 */
|
|
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_test();
|
|
while (1) {
|
|
}
|
|
|
|
return 0;
|
|
}
|