Sub bacRead(bacDevice As Int, bacType As Int, bacInstance As Int, bacProperty As Int) As String
Dim shl As Shell
' Casting all the input paramters into String as that is how .Initialize requires them
Dim deviceString As String = bacDevice
Dim deviceType As String = bacType
Dim deviceInstance As String = bacInstance
Dim deviceProperty As String = bacProperty
shl.Initialize("connect", "./bvlc.sh", Array As String("192.168.1.25"))
shl.WorkingDirectory = "/home/pi/bacnet-stack-0.8.5/bin"
shl.Run(10000)
StartMessageLoop
' Initializing the name as read, command as bacrp and passing the parameters. Parameters can be dynamic.
shl.Initialize("read", "./bin/bacrp", Array As String(deviceString, deviceType, deviceInstance, deviceProperty))
' Setting the working directory. On Linux it must be the bacnet-stack-0.8.x containing bin/bacrp.
shl.WorkingDirectory = "/home/pi/bacnet-stack-0.8.5"
' 10 second timeout
shl.Run(10000)
StartMessageLoop
' Goes to read_ProcessCompleted on this line before going onwards.
Dim presentState As String = shl.GetTempOut
Return(presentState)
End Sub
' This is automatically called when the process above finishes.
' The bit before the _ (in this case "read") MUST MATCH the first parameter given to the .Initialize function.
Sub read_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
' Stops the thread from tampering with message queue and returns to bacRead()
If Not(Success And ExitCode = 0) Then
Log("Error: " & StdErr)
End If
StopMessageLoop
Return
End Sub
Sub connect_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Not(Success And ExitCode = 0) Then
Log("Error: " & StdErr)
End If
Log("Out: " & StdOut)
StopMessageLoop
Return
End Sub