I/O exception error when using serialport.open()

This comes from the serial port driver; it is unhappy about one of the settings. With baudrate being a good candidate, drivers tend to allow only up to 115200. Albeit that this should not be a restriction when this is a dedicated CAN bus product.

The best way to tackle this is by using Sysinternals’ Portmon utility; you can see what is being sent to the driver. Observe it for Terminate first; that’s your known-to-work baseline. Then tinker with SerialPort properties until the initialization commands, as you see them in PortMon, sent by your program matches Termite’s. Just the values, not the order. If that doesn’t pan out either then take it to the parking lot and back over it with your car several times and buy another brand.


Update: it certainly looks like a baudrate problem. That’s an issue in .NET; it is not going to ignore the driver’s error return code like your terminal emulator programs do. The actual value should not matter since you are talking to an emulated serial port. There is however a possible issue with the CAN bus speed; rates are variable and it isn’t clear to me how they are negotiated. This tended to be done with DIP switches in the olden days, and it may well be that the driver wants you to specify the speed through the baudrate setting. There ought to be something about it on the box or in the manual. Typical speeds are 40, 250 or 500 kbit/s. The manufacturer certainly would know; give them a call.

Leave a Comment