diff serial/serport.c @ 53:fbedb67d234f

serial: fix parity for inverse coding convention Important note: it is my (Mother Mychaela's) understanding that SIM cards with inverse coding convention are extremely rare, and I have never seen such a card. Therefore, our support for the inverse coding convention will likely remain forever untested.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Mar 2021 20:46:09 +0000
parents 61a8ac93764f
children
line wrap: on
line diff
--- a/serial/serport.c	Sun Mar 21 19:38:27 2021 +0000
+++ b/serial/serport.c	Sun Mar 21 20:46:09 2021 +0000
@@ -29,18 +29,20 @@
 	return 0;
 }
 
-set_serial_params(br)
+set_serial_params(bps, parity)
 {
 	struct termios2 target_termios;
 
-	target_termios.c_iflag = IGNBRK;
+	target_termios.c_iflag = IGNBRK|IGNPAR;
 	target_termios.c_oflag = 0;
 	target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8|CSTOPB|PARENB;
+	if (parity == 1)
+		target_termios.c_cflag |= PARODD;
 	target_termios.c_lflag = 0;
 	target_termios.c_cc[VMIN] = 1;
 	target_termios.c_cc[VTIME] = 0;
-	target_termios.c_ispeed = br;
-	target_termios.c_ospeed = br;
+	target_termios.c_ispeed = bps;
+	target_termios.c_ospeed = bps;
 	if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) {
 		perror("TCSETSF2");
 		exit(1);