I have an FTDI USB/serial device at /dev/ttyUSB0. I set up my channel with
% set channel [open /dev/ttyUSB0 r+] file3 % chan configure $channel -mode "76800,n,8,1" -buffering none -blocking 0 -translation auto
which works just fine for Tcl on Windows. On Linux, baud rate queries show
% puts [chan configure $channel -mode] 57600,n,8,1
and I get all the garbage you’d expect from trying to communicate at the wrong baud rate. I saw this previous post: fconfigure refuses to set baud rate to 921600 …reference a fixed set of baud rates in the Tcl source. Is there a way for me to add my non-standard baud rate to get communication to work under both Windows and Linux?
Advertisement
Answer
Tcl refuses to set the speed to those values because the underlying C functions don’t support those baud rates on Linux. In fact, it’s not Tcl or even your libc that’s the problem here, but Linux: it supports a fixed set of baud rates, and 76800 is not one of them.
On my system (Debian sid), the baud rates beyond the ones specified by POSIX are visible in /usr/include/x86_64-linux-gnu/bits/termios-baud.h
. This location may differ based on the OS and version.
If you want to use this serial device, you’ll need to configure it for a different rate. The closest ones are 57600 and 115200. The maximum supported POSIX-specified version is 38400.