#include <stdio.h>
#include <stdlib.h>
#include "_tty.h"
Include dependency graph for os_intf/ttytest.cc:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
|
Definition at line 10 of file os_intf/ttytest.cc. 00011 { 00012 #ifdef UNIX_LIKE_PLAT 00013 char *ttyDevName = "/dev/ttyb"; 00014 #else 00015 char *ttyDevName = "COM2:"; 00016 #endif 00017 if (argc > 1) 00018 { 00019 ttyDevName = argv[1]; 00020 } 00021 RCS_SERIAL_PORT_HANDLE handle = 00022 open_serial_communications_port (ttyDevName); 00023 00024 print_serial_port_configuration (handle); 00025 set_serial_port_configuration (handle, NULL); 00026 char buf[80]; 00027 memset (buf, 0, 80); 00028 int newline_received = 0; 00029 printf ("Receiving line:\n"); 00030 while (1) 00031 { 00032 int bytes_read = read_serial_communications_port (handle, buf, 80); 00033 if (bytes_read != 0) 00034 { 00035 //printf("nytes_read = %d\n",bytes_read); 00036 for (int i = 0; i < bytes_read; i++) 00037 { 00038 if (buf[i] == '\n' || buf[i] == '\r') 00039 { 00040 newline_received = 1; 00041 } 00042 //printf("%x ",buf[i]); 00043 } 00044 //printf("\n"); 00045 fputs (buf, stdout); 00046 //printf("\n"); 00047 } 00048 if (newline_received) 00049 { 00050 printf ("Enter line to send:\n"); 00051 fgets (buf, 80, stdin); 00052 write_serial_communications_port (handle, buf, strlen (buf)); 00053 newline_received = 0; 00054 memset (buf, 0, 80); 00055 printf ("Receiving line:\n"); 00056 } 00057 } 00058 } |