On-board serial port initializing causing an "UnclearStatusException"

Hi all,
we are trying to use a Lidar sensor (TF-Luna though I doubt it matters) on the RS-232 port but the constructor in serial port throws an unknown exception


It does work when using the MXP port but for some reason, the native method throws this random exception when using the OnBoard option with no real explanation.

This is what we provide to the ctor:
new SerialPort(115200, SerialPort.Port.kOnboard, 8 ,SerialPort.Parity.kNone, SerialPort.StopBits.kOne);

All params as per sensor specs.

We use an empty code so I don’t see any reason for this to happen.
Thanks in advance!

Edit: we are using version 2021.3.1

Do you happen to have enable console out configured in the roborio imaging tool? If you click on the Edit Startup Settings radio button, there is an Enable Console Out checkbox. If that is enabled, you won’t be able to access the onboard serial port from the roborio. You can disable it by unchecking it then clicking apply.

Didn’t know about it, I will certainly check that out when I can but I guess if that is the case a proper exception should be displayed

I didn’t realize that was the error it gave. I’m actually working on a fix right now to give the right error, because I was able to reproduce it locally.

1 Like

Is this console out intended for debugging through a serial connection to a computer?

Yes. If its enabled, you can hook it up to an RS232 port on a computer and login from there.

1 Like

The on-board serial port is RS-232 levels (+/- 15v). You’ll need to use an RS-232 level shifter to use it with the TF-Luna. The MXP serial port is at CMOS levels (3.3v).

1 Like

So you are saying the MXP should be plug and play with the TF-Luna? Cause we didn’t get it to work, when we tried to read the values we got an empty array…

That’s how I interpret the TF-Luna data sheet. I’ve never used one.

1 Like

We will be doing more testing, if we won’t be able to make it work we will post a new thread about it >_<

One of the other things to review about Joe’s post is the RS-232 voltage range, which as he wrote is much higher than the 3.3V that I understand this device uses.

It’s possible that exposing the device to the RS-232 voltages has damaged it; if the device “RX” pin received a RS-232 signal from RoboRIO that was at +15V (logic 0) or -15V (logic 1), the device circuitry is possibly damaged, as these voltages are much higher than what the device supports.

Based on that, I’d recommend verifying proper device operation using another controller, for example an Arduino.