Not able to open a serialport

I’m obviously forgetting something, because I know I’ve done this before, but here is the entirety of my robot program:

public class Robot extends TimedRobot {

public SerialPort mySerialPort;
@Override
public void robotInit() {
mySerialPort=new SerialPort(9600,SerialPort.Port.kUSB1);
}

The result is:

ERROR  1  Unhandled exception: edu.wpi.first.hal.util.UncleanStatusException: Code: -1123. HAL: The specified serial port device was not found

I’ve tried lots of variations on baud rate. I’ve tried it with or without something plugged into the USB ports. I’ve tried two roborios.

Following up on some threads that mentioned problems, I went to the web interface of the Roborio because a thread said it should mention serial ports and mappings. It doesn’t. No reference to serial ports at all.

Does there have to be a device plugged in? Does it have to be able to support a baud rate? Have I left out a required argument or function that has to be called before I can use kUsb1? (I’ve tried it with and without things plugged into the port, with the same result.)

I know I’ve done this before, even with the same device I’m using now (a Jevois camera), but this year, nothing ……except the exceptions.

For USB, there does have to be a device plugged in. If it is not plugged in you will get that error.

It also needs to be properly detected by the Rio. The webdash should should this, but the new 2019 and newer one might not. I can look into that.

I hate computers.

I had a few things to try, so I came in to test. Step 1, recreate the problem and…it worked. Same camera. Same program. Same cable. Same…………obviously something isn’t the same, but I can’t figure out what it is. If I had tried this only once, I would have just blamed a bad connection, but I tried this Saturday, Sunday, Monday…

I still am not reading any characters, but I’m opening the port without an exception.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.