BBB UART baud rate.


I have a BeagleBone Black (rev. C) that runs Debian distro (3.8.13-bone70 Linux Kernel version), and I want to communicate via UART with some device that’s using 1.5Mbaud (1500000 baud).

Since the serial communication Linux API (termios.h) don’t provide such higher values, I’m using the stty utility.
This tool allows me to set some higher baud values like: 1000000, 1500000, 2000000, 2500000, etc.

The problem is that when I set the baud rate on some UART-associated port at 1500000 baud (via stty), it will actually get ~1754385 baud (568 nanoseconds per bit, measured using an scope).
Q1: Why is this happening?
Q2: How can I set the exact 1500000 baud? (± ~5% variation would be fine).

I have not tested this code my self, but Marlon said it worked fine for him, and the code is so very simple I do not see why It would not work . . . code is at the gist link below.

Additionally Marius,

There are other serial tools similar to stty there are at least fgetty, and getty, that can set buad rate too. Possibly more cmdline tools as well. That I’ve forgotten about . . .