FreeCalypso > hg > fc-sim-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
52:0fec41a10131 | 53:fbedb67d234f |
---|---|
27 } | 27 } |
28 ioctl(target_fd, TIOCEXCL); | 28 ioctl(target_fd, TIOCEXCL); |
29 return 0; | 29 return 0; |
30 } | 30 } |
31 | 31 |
32 set_serial_params(br) | 32 set_serial_params(bps, parity) |
33 { | 33 { |
34 struct termios2 target_termios; | 34 struct termios2 target_termios; |
35 | 35 |
36 target_termios.c_iflag = IGNBRK; | 36 target_termios.c_iflag = IGNBRK|IGNPAR; |
37 target_termios.c_oflag = 0; | 37 target_termios.c_oflag = 0; |
38 target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8|CSTOPB|PARENB; | 38 target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8|CSTOPB|PARENB; |
39 if (parity == 1) | |
40 target_termios.c_cflag |= PARODD; | |
39 target_termios.c_lflag = 0; | 41 target_termios.c_lflag = 0; |
40 target_termios.c_cc[VMIN] = 1; | 42 target_termios.c_cc[VMIN] = 1; |
41 target_termios.c_cc[VTIME] = 0; | 43 target_termios.c_cc[VTIME] = 0; |
42 target_termios.c_ispeed = br; | 44 target_termios.c_ispeed = bps; |
43 target_termios.c_ospeed = br; | 45 target_termios.c_ospeed = bps; |
44 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { | 46 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { |
45 perror("TCSETSF2"); | 47 perror("TCSETSF2"); |
46 exit(1); | 48 exit(1); |
47 } | 49 } |
48 return 0; | 50 return 0; |