microcom
microcom copied to clipboard
Support custom rates
Using 'struct termios2' with the 'TCGETS2' ioctl, custom baud rates could be supported. I need 1384200 for one board. My quick fix was to switch to picocom but custom rates would be nice for microcom as well. I'd be available for testing.
I looked into that for a while now and this is very ugly. The problem is: I want to #include <linux/termios.h>
to get the (architecture dependant!) definition of struct termios2
. However this header cannot be used in the same translation unit as <termios.h>
or <sys/ioctl.h>
:
uwe@taurus:~$ printf '#include <termios.h>\n#include <linux/termios.h>' | gcc -xc -
In file included from /usr/include/x86_64-linux-gnu/asm/termbits.h:1,
from /usr/include/asm-generic/termios.h:12,
from /usr/include/x86_64-linux-gnu/asm/termios.h:1,
from /usr/include/linux/termios.h:6,
from <stdin>:2:
/usr/include/asm-generic/termbits.h:12:8: error: redefinition of ‘struct termios’
12 | struct termios {
| ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/termios.h:27,
from /usr/include/termios.h:39,
from <stdin>:1:
/usr/include/x86_64-linux-gnu/bits/termios-struct.h:24:8: note: originally defined here
24 | struct termios
| ^~~~~~~
uwe@taurus:~$ printf '#include <sys/ioctl.h>\n#include <linux/termios.h>' | gcc -xc -
In file included from /usr/include/x86_64-linux-gnu/asm/termios.h:1,
from /usr/include/linux/termios.h:6,
from <stdin>:2:
/usr/include/asm-generic/termios.h:15:8: error: redefinition of ‘struct winsize’
15 | struct winsize {
| ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/ioctl.h:29,
from <stdin>:1:
/usr/include/x86_64-linux-gnu/bits/ioctl-types.h:27:8: note: originally defined here
27 | struct winsize
| ^~~~~~~
/usr/include/asm-generic/termios.h:23:8: error: redefinition of ‘struct termio’
23 | struct termio {
| ^~~~~~
/usr/include/x86_64-linux-gnu/bits/ioctl-types.h:36:8: note: originally defined here
36 | struct termio
| ^~~~~~
I see no at least half-pretty way to manage that.
picocom duplicates the definition of struct termios2
, see https://github.com/npat-efault/picocom/blob/master/termbits2.h