diff options
Diffstat (limited to 'sercp.c')
-rw-r--r-- | sercp.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -70,7 +70,6 @@ const char* _version = "v0.3.4"; FILE *tapout_fd = NULL; int is_outfile = 0; int baud_rate = 0; -int wait_us = 200; int wait_ms = 800; char *path; char sercp_file[FILENAME_MAX]; @@ -176,7 +175,6 @@ void TestArgs (int argc, char *argv[]) baud_rate = atoi(optarg); break; case 'w': - wait_us = atoi(optarg); wait_ms = atoi(optarg); break; case 'r': @@ -479,11 +477,10 @@ void sercpRecv(void) { #ifdef _WIN32 ReadFile(serial_fd, p_buff, expected_len, &ulNumBytes, NULL); len = (uint16_t)ulNumBytes; - sleep_ms(10); #else len = read (serial_fd, p_buff, expected_len); - sleep_ms(10); #endif + sleep_ms(10); p_buff += len; expected_len -= len; length += len; @@ -697,6 +694,7 @@ int OpenUart() { if (SetCommTimeouts(serial_fd, &sCommTimeouts) == 0) { return (-1); } + FlushSerialPort(); return (0); #else struct termios oldtio, newtio; @@ -741,15 +739,16 @@ int OpenUart() { cfmakeraw(&newtio); cfsetspeed(&newtio, baud_rate); #if defined (__APPLE__) || defined (BSD) - // pro jabkace | CNEW_RTSCTS - newtio.c_cflag |= CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW; // CSTOPB - two stop bits NOT +// newtio.c_cflag |= CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW; + newtio.c_cflag |= CS8 | CLOCAL | CREAD; #else newtio.c_cflag |= CS8 | CLOCAL | CREAD | CRTSCTS; #endif newtio.c_iflag &= ~(IXON | IXOFF | IXANY); newtio.c_oflag &= ~(OPOST); printf ("Serial device: %s, communication speed is: %d Bd\n", SERIALDEVICE, baud_rate); - newtio.c_cc[VMIN] = 1; + // http://unixwiz.net/techtips/termios-vmin-vtime.html + newtio.c_cc[VMIN] = 0; newtio.c_cc[VTIME] = 0; tcsetattr(serial_fd, TCSANOW, &newtio); tcflush(serial_fd, TCIOFLUSH); |