B4J Question JSerial Open multiple COM Ports

Yado

Member
Licensed User
Longtime User
Hi ,
I need to open Multiple com ports (COM1 to COM 30) in the same time and get and send data concurrently , i try but i for now i can make work one not more.

Can anyone please have any idea how it works ?

Thanks
 

Yado

Member
Licensed User
Longtime User
OK , i've make the class ,and all works when i need to get the streams , since it come from any opened COM ,
but when i send data works only the last opened COM , any idea why ?

Thanks
 
Upvote 0

Yado

Member
Licensed User
Longtime User
Ah found that if i make a Class for every Com that i open , it's works nice.
Probably i dont understant something on what a class works.

I call a class : example my class is named jcom , i call it and pass the parameters like :

Dim cser As jcom

cser.Initialize("event1")
cser.opencom("COM1",2400,7,2,2,"astream1") ' open com1'

and i call again for com2

cser.Initialize("event1")
cser.opencom("COM2",2400,7,2,2,"astream1")

is this the correct way ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
is this the correct way ?
Sounds like no.
If you want o have different connections then you need to have different Objects.

B4X:
Dim cser1 As jcom
cser1.Initialize("event1")
cser1.opencom("COM1",2400,7,2,2,"astream1") ' open com1'

B4X:
Dim cser2 As jcom
cser2.Initialize("event2")
cser2.opencom("COM2",2400,7,2,2,"astream2") ' open com2'

You now have two opened conenctions. cser1 and cser2
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…