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.
 
 

39 lines
732 B

#include <error.h>
#include <fcntl.h>
#include <malloc.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include "uart.hpp"
using namespace iflytop;
class Uart g_uart;
int main(int argc, char *argv[]) {
int rec_len;
char buffer[128];
if (argc != 3) {
cout << "input error,please input ttyS and baudrate" << endl;
return 0;
}
g_uart.open(argv[1], argv[2]);
while (1) {
rec_len = g_uart.receive(buffer, sizeof(buffer));
if (rec_len > 0) {
g_uart.send(buffer, rec_len);
memset(buffer, 0, sizeof(buffer));
}
usleep(1000);
}
return 0;
}