# Serial - DeviceOpen - Baudrate Error

When trying:

ser = DeviceOpen["Serial", {"COM1", "BaudRate" -> 230400}]


I get:

SerialLinkSerialPortOpen::baudrate: Value of option BaudRate -> 230400 is not
110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600,
115200, 128000, 256000.


So obviously the Std BR of 230400 is not supported, although the Help for DeviceOpen in the Serial-context explicitly says:

Typical baud rate values include: 4800, 9600, 19200, 38400, 57600, 115200, 230400.

Unfortunately I need 230400 to connect to the external device. Is there any way of setting a baudrate other than through DeviceOpen?

• 1. The Mathematica source of SerialLink is readable and found in SystemFiles/Links/SerialLink. Looking at it it is clear that the allowed baud rates are hard coded, and do not match what the documentation says (i.e. 230400 is not included). This suggests a bug. Please contact Wolfram and report it (i.e. that the docs mention 230400 but it's not supported). 2. Try modifying SerialLinkPrivate\$ValidBaudRates. You must run the DeviceOpen call first to trigger loading all the required bits. Once done, modify that variable, add 230400 to it, and see if it works. It might not, but try. – Szabolcs Feb 14 '16 at 12:00
• Thank you Szabolcs. I will report it as bug. I also tried - similar to what you suggested - modifying the actual SerialLink.m File and added 230400 to the list of valid baudrates. Then DeviceOpen gave no error, but the actually transmitted bytes are garbled in this case. I guess the underlying DLL can't get close enough to this baudrate...Too bad. – swoo Feb 14 '16 at 12:45
• What happens when you use 256000 as baud rate? – Sascha Feb 14 '16 at 16:09
• This discussion on reddit might be relevant – Sascha Feb 15 '16 at 10:51

If you are under Windows, it is possible to access the RS232 port via netLink.

<< NETLink
InstallNET[]

ser = NETNew["System.IO.Ports.SerialPort", "COM1"]
ser @ Open[]
ser @ BaudRate = 230400


I don't have any device at 230400 Bauds. To try the port, I have made a shortcut between pin 2 and 3 of my connector (ie Transmitter linked to Receiver) and it works :

ser @ WriteLine["Hello"]



"Hello"

To see how to use the object ser type :

NETTypeInfo[ser]


The main properties/methods are :

ser @ Open[]
ser @ Close[]
ser @ BaudRate
ser @ Parity
ser @ StopBits
`