We’re attempting to use an arduino as a controller for neopixels on our robot. We figured we’d use the USB/Serial option to send our commands. So long story short, when we create a SerialPort using kUSB, we can call writeString() exactly once, and then the robot code crashes. We’ve verified that the command gets to the arduino properly too. The test project was a clean project created with the New Project -> Iterative Robot template. It contains no code at all except the declaration of the SerialPort, the object creation in robotInit, and a single call to writeString() wrapped in an if statement checking for the A button of an Xbox Controller.
The code runs happily until you tap the A button, at which point the Arduino gets that one command, does the right thing, then the robot code hangs for a few seconds, finally crashes, and restarts. The RoboRIO is just fine, as an SSH connection stayed up, just the java robot code died.
We don’t have internet access at the school and I dont have the driver station at home with me so I cant copy-pate the exception (Maybe I’ll try using my phone as a hotspot tomorrow?), but it eventually boils down to a VISA exception.
We attempted to switch to the onboard RS232, and while the arduino never received the command (Most likely because we had to cobble together a cable, and we werent sure if it needed to be a straight through, or cross-over) The robot code never crashed.
Has anyone seen anything like this? We could probably switch to the RS232 if we have no success, but we’re going to need power from the USB anyway, so we might as well not be wasteful. Besides, Not getting a serial connection to work? I’m taking that personally!
Edit::
Error Cap
ERROR Unhandled exception: java.lang.RuntimeException: Code: -1073807339. Unknown error status at [edu.wpi.first.wpilibj.hal.SerialPortJNI.serialWrite(Native Method), edu.wpi.first.wpilibj.SerialPort.write(SerialPort.java:356), edu.wpi.first.wpilibj.SerialPort.writeString(SerialPort.java:366), org.usfirst.frc.team871.robot.Robot.teleopPeriodic(Robot.java:55), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:143), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]
Edit 2:
After several hours of experimentation (with a second roborio, loaded with a fresh image and JDK downloaded from the internets) we still have the same result. You get one successful writeString() (successful, meaning the arduino gets the command) followed by a few second halt, followed by a robot code crash and restart. I really hope someone else can reproduce this issue to get some more brains on the problem.