Hi,
I'm in the middle of porting my apps from rfo-basic to b4a.
So far it has gone well and the b4a code is running.
The problem I'm having is reading a Bluetooth packet of BYTES (0-255 decimal, 0x00-0xFF hex) and saving them to an array as decimal integer numbers.
The rfo-basic code looks like this
IF rr
BT.READ.BYTES rmsg$
dtr$=dtr$+rmsg$
endif
until rr=0
for k=1 to len(dtr$)
numbytes=numbytes+1
bval$=MID$(dtr$, k, 1)
ascval=ascii(bval$)
BTdata[numbytes]=ascval
next k
dtr$=""
My b4a code has got to this point-
Sub Timer1_Tick
Dim len_pkt As Int
Dim dtr_In As String
Dim btdata As Int
Dim i As Int
'Dim sf As StringFunctions
' sf.Initialize
If connected Then
If TextReader1.Ready Then 'check if there is any data waiting to be read
txtLog.Text = TextReader1.ReadLine
len_pkt=txtLog.text.Length
Log("Len_pkt")
Log(len_pkt)
i=1
Do While i<=len_pkt
dtr_In=txtLog.text.SubString2(i,i+1)
i=i+1
btdata=dtr_In
Log(btdata)
Loop
End If
End If
End Sub
earlier in the code I declare - TextReader1.Initialize2((Serial1.InputStream),"Windows-1252")
I am now in despair...can anyone help?
I'm in the middle of porting my apps from rfo-basic to b4a.
So far it has gone well and the b4a code is running.
The problem I'm having is reading a Bluetooth packet of BYTES (0-255 decimal, 0x00-0xFF hex) and saving them to an array as decimal integer numbers.
The rfo-basic code looks like this
IF rr
BT.READ.BYTES rmsg$
dtr$=dtr$+rmsg$
endif
until rr=0
for k=1 to len(dtr$)
numbytes=numbytes+1
bval$=MID$(dtr$, k, 1)
ascval=ascii(bval$)
BTdata[numbytes]=ascval
next k
dtr$=""
My b4a code has got to this point-
Sub Timer1_Tick
Dim len_pkt As Int
Dim dtr_In As String
Dim btdata As Int
Dim i As Int
'Dim sf As StringFunctions
' sf.Initialize
If connected Then
If TextReader1.Ready Then 'check if there is any data waiting to be read
txtLog.Text = TextReader1.ReadLine
len_pkt=txtLog.text.Length
Log("Len_pkt")
Log(len_pkt)
i=1
Do While i<=len_pkt
dtr_In=txtLog.text.SubString2(i,i+1)
i=i+1
btdata=dtr_In
Log(btdata)
Loop
End If
End If
End Sub
earlier in the code I declare - TextReader1.Initialize2((Serial1.InputStream),"Windows-1252")
I am now in despair...can anyone help?