Getting a answer from a driver in HEX
Getting a answer from a driver in HEX
i´m working in a communication between a software that i developed and a weighing module. I´m facing the following problem problem:
I´m receiving the data from a serial port in CHAR, but it goes untill 127, after this i start to receive a "?" and it converts to a "63".
There is a way of receiving the message back in HEX or do you have another solution maybe? Because i need the rest of the numbers from 127 to 255.
SerialPort1.Write(message1)
message = SerialPort1.ReadLine()
peso1 = message.Chars(2)
value1 = Convert.ToInt32(peso1)
If pes2 = "?" Then
value2 = 0
If peso1 = "?" Then
value1 = 0
End If
End If
pes2 = message.Chars(1)
value2 = Convert.ToInt32(pes2)
pes3 = message.Chars(0)
value3 = Convert.ToInt32(pes3)
valuef = value1 + value2*255
TextBox1.Text = valuef
'
tv1.Text = value1
tv2.Text = value2
tv3.Text = value3
SerialPort.Read Method
– TheGeneral
Jul 2 at 12:15
What as the parameters to use serial.port.read() in bytes?
– Rafael Ferronato
Jul 2 at 13:27
1 Answer
1
If the device is sending ASCII characters then the encoding of the serial port will have to be something that has 256 values defined. I believe this is one.
System.Text.Encoding.GetEncoding(28591)
Without knowing the protocol of the device it is hard to give a better answer.
It worked, thank you so much
– Rafael Ferronato
Jul 2 at 16:22
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
surely you want to read bytes?
– BugFinder
Jul 2 at 12:13