diff options
author | Pavel Vymetálek <pavel@vym.cz> | 2023-01-10 23:28:58 +0100 |
---|---|---|
committer | Pavel Vymetálek <pavel@vym.cz> | 2023-01-10 23:28:58 +0100 |
commit | 087ff0d8a5e036c6cff66c97cfa1a322f55fadfa (patch) | |
tree | ba00d8fb359cc000f577a3dac287f28593c08800 /sercp.c | |
parent | 139969ef7b0ac660853899ac601bab330c111f71 (diff) | |
download | sercp-pc-0.3.7.tar.gz |
Add switch -n for flow control nonev0.3.7
-n, --none Set the flow control to NONE. Default is CTS/RTS.
This is useful for eLeMeNt ZX and machines or serial port without CTS/RTS wires.
Diffstat (limited to 'sercp.c')
-rw-r--r-- | sercp.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -68,7 +68,7 @@ #define FALSE 0 #define true 1 #define TRUE 1 -const char* _version = "v0.3.6"; +const char* _version = "v0.3.7"; // SERIAL FILE *tapout_fd = NULL; int is_outfile = 0; @@ -88,6 +88,7 @@ long pos = 0; int scp = 0; int is_scp_read = 0; int is_continue = 1; +int is_flow_control_none = 0; // 1 - set flow control to NONE // prototypes @@ -131,7 +132,7 @@ typedef struct { FILEINFO fileinfo; void usage(void) { - printf ("sercp %s (c)2018-2020 Pavel Vymetalek <pavel@vym.cz>\n", _version); + printf ("sercp %s (c)2018-2023 Pavel Vymetalek <pavel@vym.cz>\n", _version); printf ("serial copy for transfering file to/from ZX Spectrum 128 AY's RS232\n"); printf ("Uses 1109bytes of fileinfo - blocks sums, filename, etc.\n"); printf ("More info at https://vym.cz/sercp/\n"); @@ -144,6 +145,7 @@ void usage(void) { printf ("\t-d, --device\tSerial communication device\n"); #endif printf ("\t-b, --baud\tSet the communication speed. Default 38400Bd\n"); + printf ("\t-n, --none\tSet the flow control to NONE. Default is CTS/RTS\n\t\t\tThis is useful for eLeMeNt ZX and machines or serial port without CTS/RTS wires\n"); printf ("\t-w, --wait\tWaiting in milliseconds between transmitted blocks.\n\t\t\tDefault is -w 800 ms\n"); printf ("\t-r, --read\tRead file from serial port\n"); } @@ -159,12 +161,13 @@ void TestArgs (int argc, char *argv[]) {"device", required_argument, NULL, 'd'}, {"baud", required_argument, NULL, 'b'}, {"wait", required_argument, NULL, 'w'}, + {"none", no_argument, NULL, 'n'}, {"read", no_argument, NULL, 'r'}, {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; - c = getopt_long (argc, argv, "d:b:w:rvh", long_options, &option_index); + c = getopt_long (argc, argv, "d:b:w:nrvh", long_options, &option_index); if (c == -1) { // end of arguments break; @@ -186,6 +189,9 @@ void TestArgs (int argc, char *argv[]) case 'r': is_scp_read = 1; break; + case 'n': + is_flow_control_none = 1; + break; case 'v': printf ("%s\n", _version); exit(1); @@ -770,14 +776,25 @@ int OpenUart() { cfsetospeed(&newtio, baud_rate); cfsetispeed(&newtio, baud_rate); // set ispeed same as ospeed (see POSIX) #if defined (__APPLE__) || defined (BSD) - newtio.c_cflag |= CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW | HUPCL; + if (is_flow_control_none) { + printf("Sorry, flow control is not tested on this platform\n"); + newtio.c_cflag |= CS8 | CLOCAL | CREAD | HUPCL; + } else { + newtio.c_cflag |= CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW | HUPCL; + } #else - newtio.c_cflag |= CS8 | CLOCAL | CREAD | CRTSCTS; + if (is_flow_control_none) { + // usefull for eLeMeNt ZX and machines or serial port without CTS/RTS wires + newtio.c_cflag |= CS8 | CLOCAL | CREAD; + } else { + // standard CTS/RTS flow control + newtio.c_cflag |= CS8 | CLOCAL | CREAD | CRTSCTS; + } #endif newtio.c_iflag &= ~(IXON | IXOFF | IXANY); newtio.c_oflag &= ~(OPOST); newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // raw input - printf ("Serial device: %s, communication speed is: %d Bd\n", SERIALDEVICE, baud_rate); + printf ("Serial device: %s, communication speed is: %d Bd, flow control: %s\n", SERIALDEVICE, baud_rate, (is_flow_control_none)?"None":"CTS/RTS"); // http://unixwiz.net/techtips/termios-vmin-vtime.html newtio.c_cc[VMIN] = 1; // minimum number to read |