In an experiment, data is send from Node-RED running on a Raspberry Pi via the serial line to an Arduino.
The data send by Node-RED is a comma separated string, e.g. 12,string1,true.
What is the best way to get the string items converted to the right types, e.g. Int, String, Boolean.
The data send by Node-RED is a comma separated string, e.g. 12,string1,true.
What is the best way to get the string items converted to the right types, e.g. Int, String, Boolean.
B4X:
Private astream As AsyncStreams
astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
B4X:
Sub Astream_NewData (Buffer() As Byte)
If Buffer.Length < 3 Then Return
Dim bc As ByteConverter
Dim idx As UInt = 0
For Each s() As Byte In bc.Split(Buffer, ",")
Log(idx,"=", s)
Select idx ' Integer
Case 0
' How to convert s to Int
Dim number1 as Int = ???
' String
Case 1
' How to convert s to String
Dim string1 as String = ???
' Boolean
Case 2
' How to convert s to a boolean
Dim bool1 as Boolean = ???
End Select
idx = idx + 1
Next
End Sub