I am trying to send a hex packet via serially, program looks like this
dim SerDataOut As String
SerDataOut = SendTextField1.Text
SerialConnection1.Write(DecodeHex(SerDataOut))
SendTextField1 is an text box that will be used to input the hex message.
I think using EncodeHex is just taking the hex number and converting it to a hex string.
As an example this hex message (54 03 01 00 00 00 00 00 A8) will turn on a LED on my demo board.
I know that the hex string is correct as I can use cool terminal and send hex and the light turns on.
dim SerDataOut As String
SerDataOut = SendTextField1.Text
dim data as string = DecodeHex(SerDataOut))
SerialConnection1.Write(data) // set a breakpoint here in the debugger
In the debugger, inspect the value of ‘data’ - the Xojo debugger lets you view strings as strings or as raw byte data, which will let you confirm the data format is correct.
Edit to add:
You might also neeed SerialConnection1.Flush()
to make sure the data is actually sent?