#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
' sout = File.OpenOutput("","/dev/ttyS0",True) ' open serial output
' sinp = File.OpenInput("","/dev/ttyS0") ' open serial input
'
Dim inpkt(128) As Byte ' serial comm input packet buffer
Dim sout As OutputStream ' serial out stream
Dim sinp As InputStream ' serial in stream
Dim c, rxlen As Int
Dim s As String
End Sub
Sub Service_Create
sout = File.OpenOutput("","/dev/ttyS0",True) ' open serial output
sinp = File.OpenInput("","/dev/ttyS0") ' open serial input
End Sub
Sub Service_Start (StartingIntent As Intent)
rxlen = sinp.BytesAvailable ' check if bytes available on serial input
If rxlen > 0 Then
sinp.ReadBytes(inpkt,0,rxlen) ' read pending characters
s = "" ' clear string
For c = 0 To rxlen-1 ' build string from characters
s = s & Chr(inpkt(c))
Next
'Log(s)
ToastMessageShow (s,True)
End If
End Sub
Sub Service_Destroy
End Sub