B4J Question Several COM-ports at the same time - possible ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Anyone tried to use several COM-ports at the same time in B4J ?

I'm trying, and more over - trying to make the baudrate autodetect. And it's successful - one port is opened with 9600 baud, another - 115200, and first data packet from each port is decoded under the chosen baudrate, and it's congratulation that connected correctly, but ... after these 2 connections - only one port is going on streaming data.
The second connected port gives silence, but sometimes they both work together, as expected.
Unstable work.
Maybe any suggestion how better to control COM-ports ?
 

peacemaker

Expert
Licensed User
Longtime User
multiple instances of Serial
Yes. Each is created in the class dynamically.
Root usb_devices class detects COM-ports list, and creates instances of the use_serial_device class where this port is opened, baudrate is changed, waiting for data from AsyncStreams, and switching the baudrate if no data for several seconds.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I expect it to work
Yes, solved ! Unstable work was due to at COM-port losing or adding - i was reconnecting all the ports.
If to manage ports only one by one - no any trouble: each COM-port is able to work at any detected baudrate and together with others already working ports.
Resume: do not break already working OK piece.

p.s. but now i understand why USB was invented :)
 
Upvote 0
Top