Java Question Serial Lib 1.2 binary access

thetallone

Member
Licensed User
Longtime User
I try to send binary data to a RFCOM Bluetooth Module
from PC in VB6 I can write and read over SPP (COMx) and also the App Blueterm can send an receive binary data.
Binary data is mentioned as stream character bytes (values 0-255) including EOL (0x00) or CRLF (x13), which will be sent and can be received anytime in between the stream but the stream has never an CRLF at the end (the stream is not 'line' based)

The base of the tests is the serial example and the bluetooth example from this website.

Sub btnSend_Click
If connected Then
txtSend.Text = Chr(0x1b) & Chr(3)& Chr(0) & Chr(15) & Chr(16) & Chr(11) & Chr(45)
TextWriter1.Write(txtSend.Text)
TextWriter1.Flush
End If
End Sub

Sub Timer1_Tick
Dim c As String
If connected Then
If TextReader1.Ready Then 'check if there is any data waiting to be read
c = TextReader1.Readall 'read the buffer
End If
End If
End Sub

Serial Example:
When connected the application hangs up with the toastmessageshow connected information and no other information
Bluetooth Example:
Orignal code, after connecting -> Process was stoped unexpected.
 
Last edited:

thetallone

Member
Licensed User
Longtime User
AsyncStream binary access

I have changed to AsyncStream

Sub AStreams_NewData (Buffer() As Byte)

version a)
If Buffer(0) = 0 Then
Label1.Text = Chr(Buffer(0))
End If

version b)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
ToastMessageShow(msg, False)
Log(msg)

End Sub

a) and b) ...after the first byte is received, android closes the application with unexpected error.

How will the buffer be cleared or released for next receive, eg by END SUB?
Can Buffer.Length report correct when no EOF (0x00) can be found?
 

Jonas

Member
Licensed User
Longtime User
Did you change
B4X:
AStream.InitializePrefix
to
B4X:
AStreams.Initialize
?

/J
 
Top