Serial error management #282
Unanswered
relaxmax01
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, is there a way to detect and prevent the error "serial PI_BAD_HANDLE; unknown handle " when building a serial port with a non valid port name? for example below, if .device(myPort) is set with myport not being a valid RPI port name? (myport is read for a config file that may not be initialized. I'm trying to have a method to test the port and report status to my application before proceeding).
Serial serial = pi4j.create(Serial.newConfigBuilder(pi4j)
.use_9600_N81()
.dataBits_8()
.parity(Parity.NONE)
.stopBits(StopBits._1)
.flowControl(FlowControl.NONE)
.id(myPort) // ??
.device(myPort) // /dev/serial0 or serial1 ; use ls -l /dev/ser* to see which one is mapped to ttyS0 if using RPI UART on connector; https://forums.raspberrypi.com/viewtopic.php?t=299548#p1804496
.provider("pigpio-serial")
.build());
also what is the purpose of the .id field or how is it used?
Beta Was this translation helpful? Give feedback.
All reactions