I'm a bit puzzled, wondering if anyone can offer advice on how best to visualize a solution to this.
Just for fun, I've been writing a program that will communicate with an embedded controller via a serial port. The controller contains callibration data which I would like to read, and perhaps even write - which the controller has it's own 'commandset' (quite similar to AT commands really).
I've written a program in vb.net which can communicate with the controller, no problems there, what I'm struggling with is how to interpret the data i'm receiving.
I'm handling all received data as a byte array, so in the serialport datareceived event, a byte array is incremented with the bytes received - when a command is sent to the controller, this array is cleared, so the array only contains the response to a specific command.
I wasn't sure how to convert a byte array to a string - so i googled it. It became clear I would have to encode the sequence, but after using the getstring method with all the encoding options (UT7/8/32/ASCII/Unicode) all I am getting if I try to display the string in a messagebox or textbox is an empty line.
Yet, if I search for a value in that string, the search is able to read the data within it -
Does anyone know where I'm going wrong? I appreciate this is probably quite a n00b question...
cheers
Kris
Just for fun, I've been writing a program that will communicate with an embedded controller via a serial port. The controller contains callibration data which I would like to read, and perhaps even write - which the controller has it's own 'commandset' (quite similar to AT commands really).
I've written a program in vb.net which can communicate with the controller, no problems there, what I'm struggling with is how to interpret the data i'm receiving.
I'm handling all received data as a byte array, so in the serialport datareceived event, a byte array is incremented with the bytes received - when a command is sent to the controller, this array is cleared, so the array only contains the response to a specific command.
I wasn't sure how to convert a byte array to a string - so i googled it. It became clear I would have to encode the sequence, but after using the getstring method with all the encoding options (UT7/8/32/ASCII/Unicode) all I am getting if I try to display the string in a messagebox or textbox is an empty line.
Yet, if I search for a value in that string, the search is able to read the data within it -
VB.NET:
'RX_Buffer is byte array for received data
RX_BufferString = System.Text.Encoding.ASCII/Utf8/UTF7/Unicode.GetString(RX_Buffer) 'tried all encoding options
textbox1.text = RX_BufferString 'should display string in textbox however textbox remains empty
if RX_Bufferstring.contains("Hello") = true then msgbox("Hello was found in the string") 'messagebox DOES display
Does anyone know where I'm going wrong? I appreciate this is probably quite a n00b question...
cheers
Kris