Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private SerialNative2 As Stream
Private astream As AsyncStreams
Dim Timer1 As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
RunNative("SerialNative2", Null)
astream.Initialize(SerialNative2, "astream_NewData", "astream_Error")
Timer1.Initialize("Timer1_Tick", 1000)
Timer1.Enabled = True
Log("AppStart")
End Sub
Sub astream_Error
Log("Serialport 2 error.")
End Sub
Sub astream_NewData (s() As Byte)
Log(s)
End Sub
Private Sub Timer1_Tick
SendOutString("12345")
End Sub
Public Sub SendOutString(text As String)
Dim Buffer(6) As Byte
For i = 0 To text.Length-1
Buffer(i)=text.GetBytes(i)
Next
''Log(Buffer)
Log("buffer send")
astream.Write(Buffer)
End Sub
#if C
HardwareSerial Serial2(2); // Second Hardware Port
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(115200);
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#End If