Android Question Bluetooth Using InitializePrefix mode

walterf25

Expert
Licensed User
Longtime User
Hello all, i have a Linvor bluetooth Module that i have been using for a while, it has been working great with a program written in B4A, today i started doing some data acquisition and noticed that i was not receiving the full message data on my phone, i was receiving broken messages, so I decided to try to use InitializePrefix, now the problem is that when i start the program now it won't work, i get this message i the filtered logs.
java.lang.OutOfMemoryError
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:172)
at java.lang.Thread.run(Thread.java:841)
** Activity (chatactivity) Pause, UserClosed = true **

Can anyone, maybe Erel can help me figure out what this means, the only thing i changed was
B4X:
AStream.Initialize(Main.Serial1.InputStream, Main.Serial1.OutputStream, "AStreams")
to this
B4X:
AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "Astreams")

I don't understand what the difference is, any help guys will be greatly appreciated.

Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
It is explained in the tutorial: AsyncStreams Tutorial
Hi Erel thanks for the reply, i think i understand how the prefix mode works, what i don't understand is why the application crashes at this line
B4X:
AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "Astreams")
it crashes even before jumping to the new data event.

am i missing something?

another issue is if i use only Initialize mode, it works fine, but i don't get the full data stream, i should be getting "Volt2.59" but sometimes i only get the V followed by a carriage return and then on the next line i get "olt2.59", why is that? this is driving me nuts, any suggestions Erel?

Thanks,
Walter
 
Upvote 0
Top