Custom baud rates - #19
jorisvergeer wants to merge 1 commit into
Conversation
commit ca3966446039aa557ff5eda364fbc97de7a35898
Author: vagrant <vagrant@vagrant.vm>
Date: Tue Apr 11 16:10:17 2017 +0000
Fix build issues and a missed check
commit 9ee3d50cc581053b05e380b6eb6454ee19150e26
Author: Joris Vergeer <j.vergeer@agis.nl>
Date: Tue Apr 11 18:01:20 2017 +0200
Custom baud
|
Cool! Be patient while I get around to testing it with the serial devices I have. I'm hoping over the Easter break. |
|
I might need to add some cleanup code around the close event |
|
Also I was a bit lazy with returned errors |
|
I was also thinking, because the custom baudrate is OS specific, it might make sense to put it in its own file, and have the CMakeLists.txt compile the file depending on the OS it detects. |
|
What chipsets have you already tested with, and what OS are you using? |
|
There might only be a handful of drivers that support the custom_divisor stuff although I am not sure. |
|
I only tested with FTDI. |
|
I have PL2303, an original 16550A in my laptop docking station and another USB (SCM2xxx) that I'll test with. |
|
Data point from using this in production, in case it's useful for deciding how to land custom baud rates. We hit the same wall (FTDI FT4232H on linux-arm64, needing 250000 / 1562500 / 3125000 / 6250000 — none of which have a POSIX 1. It's exact rather than rounded. 2. It needs no native rebuild. Termios settings on Linux belong to the TTY, not to a file descriptor, so opening a second fd to the same device and issuing Sketch (ioctl values are the same on x86_64 and aarch64, both asm-generic): #define TCGETS2 0x802C542A
#define TCSETS2 0x402C542B
#define CBAUD 0x0000100F
#define BOTHER 0x00001000
struct termios2 t;
ioctl(fd, TCGETS2, &t);
t.c_cflag = (t.c_cflag & ~CBAUD) | BOTHER;
t.c_ispeed = t.c_ospeed = baud;
ioctl(fd, TCSETS2, &t);One thing worth doing either way: read the settings back after setting them and compare against what was requested. The kernel (or the driver) can quietly program something else, and without the check that looks indistinguishable from a working switch — we chased a bug for a while that turned out to be exactly this class of silent mismatch. Also, separate from custom rates but adjacent to the Thanks for the library — it's been solid for us otherwise. |
Hi,
I saw some todos regarding custom baud rates in your code.
I needed baud rate 345600 which is not a supported baud rate.
Here is a pull request with code for custom baud rates. I using information from:
http://www.home.unix-ag.org/simon/files/serial-linux.c
and
https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ftdi_sio.c
It runs now for 5 minutes on my machine using a FTDI chip.