Hello,
I try to connect to a serial device using Serial lib and AsyncStreams.
B4X:
Sub btnOpen_Action
sp.Open(cmbPort.Value)
sp.SetParams(38400, 8,0,1)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
btnOpen.Enabled = False
End Sub
Sub MainForm_Closed
sp.Close
End Sub
Sub AStream_NewData (Buffer() As Byte)
Dim i As Int
Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "UTF-8")
Log(s)
For i = 0 To Buffer.Length -1
Log(Buffer(i) & "- "&Chr(Buffer(i)))
Next
End Sub
The device send the following ASCII string through serial :
thi sis what I get using putty opening COM11 38400,n,8,1
{"msg":"No_Card"}