From da3ab5ca185ebdf80a84893b2033c62a0aed8fd2 Mon Sep 17 00:00:00 2001 From: Pavel Vymetálek Date: Fri, 3 Apr 2020 17:06:54 +0200 Subject: Change open serial port for __APPLE__: CCTS_OFLOW | CRTS_IFLOW --- sercp.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sercp.c b/sercp.c index b99dc42..858c8ea 100644 --- a/sercp.c +++ b/sercp.c @@ -27,6 +27,7 @@ #include #include #include + #include #include #include #include @@ -39,14 +40,15 @@ #include #else #include - #include #include #include + #include #include #include #include #include #include + #include #include #include #include @@ -64,7 +66,7 @@ #define true 1 #define TRUE 1 -const char* _version = "v0.3.1"; +const char* _version = "v0.3.2"; // SERIAL FILE *tapout_fd = NULL; int is_outfile = 0; @@ -521,20 +523,20 @@ void sercpSend(void) { struct tm *timdat; no = stat(sercp_file, &st); - if (no != 0) { + if (no == -1) { printf ("can't stat input file\n"); exit (EXIT_FAILURE); } + if (st.st_size == 0) { + printf ("Zero length of file. End\n"); + exit (EXIT_FAILURE); + } tap_fd = fopen(sercp_file, "rb"); if (tap_fd == NULL) { printf ("can't open input file\n"); exit (EXIT_FAILURE); } - if (st.st_size == 0) { - printf ("Zero length of file. End\n"); - return; - } // FIXME do this more sophisticated and crossplatform, for example by __SIZE_WIDTH__ #if defined (__linux__) || defined(_WIN32) @@ -672,7 +674,7 @@ int OpenUart() { return(-1); } tcgetattr(serial_fd, &oldtio); /* save current port settings */ - explicit_bzero(&newtio, sizeof (newtio)); + bzero(&newtio, sizeof (newtio)); switch (baud_rate){ case 115200: newtio.c_cflag = B115200; @@ -705,7 +707,11 @@ int OpenUart() { } cfmakeraw(&newtio); cfsetspeed(&newtio, baud_rate); - newtio.c_cflag |= CS8 | CLOCAL | CREAD | CRTSCTS; // CSTOPB - two stop bits NOT +#ifdef __APPLE__ + newtio.c_cflag = CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW; // CSTOPB - two stop bits NOT +#else + newtio.c_cflag = CS8 | CLOCAL | CREAD | CRTSCTS; // CSTOPB - two stop bits NOT +#endif printf ("Serial device: %s, communication speed is: %d Bd\n", MODEMDEVICE, baud_rate); newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME] = 0; -- cgit