B4J Question B4J jSerial initialization question

Beja

Expert
Licensed User
Hi,
Please someone point me to the correct syntax of initializing the jSerial port without "Prefix"
in the b4j/b4a chat example I received the following error:

B4X:
astream.InitializePrefix(sp.GetInputStream, True, sp.GetOutputStream, "astream")
Program started.
java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:205)
at java.lang.Thread.run(Thread.java:745)
Error: (RuntimeException) java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
Connection is broken.

P.S.
I am not using the B4A app on the other side of the chat, but sending string or plain text through the serial port.
 

besoft

Active Member
Licensed User
B4X:
    BaudRate =9600
    sp.Open("COM5")
    sp.SetParams(BaudRate,8,1,0)
    astream.Initialize(sp.GetInputStream,sp.GetOutputStream, "astream")

Try this.
 
Upvote 0

Beja

Expert
Licensed User
B4X:
    BaudRate =9600
    sp.Open("COM5")
    sp.SetParams(BaudRate,8,1,0)
    astream.Initialize(sp.GetInputStream,sp.GetOutputStream, "astream")

Try this.

Hi besoft,
In the above example, the data is read only when the NewData event is fired.. but in my project I want to initiate the reading process..
means I want to read the port by a command like : X = MSComm1.input.. I am using a modem and data comes in intervals and stored in the modem buffer, so I want to read it from the buffer. I utterly failed to find a command to read the port.. calling the NewData event didn't work.
Any hint or direction?
 
Upvote 0
Top