I am looking for some way to read and write to an Edison UART via a non typical baud rate.
Its a particular hardware I have - quite slow at about 1600 baud and I wish to create an Arduino sketch on the Edison to communicate with it.
I have tried -
On Edison its failing (works ok on Arduino Unos) - Serial1 only supports certain fixed baud rates: 50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 + some higher ones
I've looked at the code - big switch statement to select a fixed constant (one per supported baud rate) and passes this to tcsetattr() which I have not yet found the code for.
2) I have tried calling linux stty via system ( and also direct on the terminal command line)
system("stty -F /dev/ttyMFD1 1600");
Error given is: stty: invalid argument '1600' when anything other than the values above are displayed
3) I have tried the Linux trick of calling ioct (to use ASYNC_SPD_CUST aliasing (link)). But no matter what i specify, even standard baud rates - TIOCSSERIAL command just does not seem to be implemented.
ioctl(m_Socket_fd, TIOCGSERIAL, &serinfo); //this is ok - reads all values.
ioctl(m_Socket_fd, TIOCSSERIAL, &serinfo); //even writing this data back without changing anything returns an error
4) I have looked into SoftwareSerial - but its not supported on non AVR platforms.
5) Also tried of course just using closest supported baud - but it just reads garbage.
I think my best bet is (3) above if I anyone knows how to get the TIOCSSERIAL to work - but any other ideas considered.
// Set non-standard baudrate (all my error checking removed)
int baudrate = 1600;
struct serial_struct serinfo;
int r=ioctl(m_Socket_fd, TIOCGSERIAL, &serinfo);
serinfo.flags &= ~ASYNC_SPD_MASK;
serinfo.flags |= ASYNC_SPD_CUST;
serinfo.custom_divisor = serinfo.baud_base / baudrate;
r = ioctl(m_Socket_fd, TIOCSSERIAL, &serinfo);
Out of ideas now - would anyone know any way to set the UART to a nonstandard baud rate please?
Thanks very much,