'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private astream As AsyncStreams
Private sp As Serial
Private s1 As String=""
Private n3 As Int=0
End Sub
Sub AppStart (Args() As String)
sp.Open("/dev/ttymxc2")
sp.Initialize("")
sp.SetParams(19200,8,1,0)
'sp.SetPort(port,baudrate,2)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "AStream")
'astream.Write2(Array As Byte(1,2,3,4,5),0,5)
StartMessageLoop
End Sub
Sub astream_NewData (Buffer() As Byte)
Dim n1 As Int=Buffer.Length
If n1 >0 Then
Dim n2 As Int
For n2=0 To n1-1
s1= s1 & " " & b4jlib.Byte2Hex(Buffer(n2))
n3=n3+1
If n3>=16 Then
Log(s1)'BytesToString(Buffer, 0, Buffer.Length, "utf8").Trim)
s1=""
n3=0
End If
Next
End If
End Sub