aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vymetálek <pavel@vym.cz>2020-04-03 17:06:54 +0200
committerPavel Vymetálek <pavel@vym.cz>2020-04-03 17:06:54 +0200
commitda3ab5ca185ebdf80a84893b2033c62a0aed8fd2 (patch)
tree3ea9ce14ffabf8e37af10690b2b5f4ef6a1dba51
parent45c8724e89c7c0d84fa42d2877f5b71c0f70749e (diff)
downloadsercp-pc-da3ab5ca185ebdf80a84893b2033c62a0aed8fd2.tar.gz
Change open serial port for __APPLE__: CCTS_OFLOW | CRTS_IFLOWv0.3.2
-rw-r--r--sercp.c24
1 files 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 <fcntl.h>
#include <windows.h>
#include <getopt.h>
+ #include <strings.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
@@ -39,14 +40,15 @@
#include <utime.h>
#else
#include <stdio.h>
- #include <unistd.h>
#include <stdlib.h>
#include <string.h>
+ #include <strings.h>
#include <errno.h>
#include <stdint.h>
#include <libgen.h>
#include <getopt.h>
#include <termios.h>
+ #include <unistd.h>
#include <err.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -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;