#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private btn_Quit As Button
Private Timer1 As Timer
Private astream As AsyncStreams
Private myserial As Serial
Private uart_list As List
Private rcvStr As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Timer1.Initialize("Timer1",5000)
If astream.IsInitialized Then
astream.Close
End If
myserial.Initialize("")
uart_list = myserial.ListPorts
Log(uart_list)
Log(" ")
myserial.Open(uart_list.Get(1))
myserial.SetParams(9600,8,1,0)
astream.Initialize(myserial.GetInputStream,myserial.GetOutputStream,"astream")
Log("Com Port Initialized: " & uart_list.Get(0))
'Timer1.Enabled=True
End Sub
Sub Timer1_Tick
Dim s1, s2, s3 As String
s1=Rnd(0,360)
s2=Rnd(0,500)/100
s3="<STX>Q," & s1 & "," & s2 & ", M, 00, <ETX> 16"
Log("Sending: " & s3)
astream.Write(s3.GetBytes("UTF8"))
End Sub
' Called when stream gets new data
Sub astream_NewData (Buffer() As Byte)
rcvStr = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log("Newdata received: " & rcvStr)
End Sub
Sub btn_Quit_MouseClicked (EventData As MouseEvent)
astream.Close
myserial.Close
ExitApplication
End Sub