Sub Process_Globals
Private myserial As Serial
Private astream As AsyncStreams
Private MyPort As String
Private BaudRate As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
myserial.Initialize("")
End sub
Sub btn_Connect_MouseClicked (EventData As MouseEvent)
Log("Com Port: " & MyPort)
Log("Baud: " & BaudRate)
If btn_Connect.Text="Connect" Then
btn_Connect.Text="Disconnect"
myserial.Open(MyPort)
myserial.SetParams(BaudRate,8,1,0) 'Baud normally 9600
astream.Initialize(myserial.GetInputStream,myserial.GetOutputStream,"astream")
Else
btn_Connect.Text="Connect"
astream.Close
myserial.Close
End If
End Sub
'Then I use the following to send data,MyText is a string containing anything.
astream.Write(MyText.GetBytes("UTF8"))