Serial communication with multiple usb devices #189
Unanswered
JToddCorley
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
-
I guess the root of my question is: Can I establish multiple serial connections with pi4j?
I started out using the 40pin header of my Pi4 and in my project decided to move the pin/connection monitoring out to multiple Arduino nano boards. I was already set up for using pi4j and following the serial example I was able to connect to one nano and open a serial com chanel, but when I tried to create a second serial object to talk to another nano I get
IO instance [com.pi4j.plugin.pigpio.provider.serial.PiGpioSerial] already exists in the Pi4J runtime context; unable to create a new instance using this reserved id.
My setup looks like this
var serial = pi4j.create(Serial.newConfigBuilder(pi4j).baud(Baud._115200).dataBits(DataBits._8)
.parity(Parity.NONE).stopBits(StopBits._1).flowControl(FlowControl.NONE).id("my-serial")
.device("/dev/ttyUSB2").provider("pigpio-serial").build());
serial.open();
I was hoping to change the id and device to create the second serial channel.
I also tried multiple context objects and that got really weird with VM crashes.
I am out of documentation to read at this point and hoping for advice.
Even if it "you can't get there from here", thanks in advance for any input.
Beta Was this translation helpful? Give feedback.
All reactions