SerialPort UART input buffer omits zeroes
-
Hi, I need to tranfer hex values through UART. But the problem is the default ASCII encoding of the SerialPort omits zeroes and such values (mostly below 0x14). What do I change this setting to in order to receive all values from 0-255 through the port? Please Help. For ex: 0x55, 0x55, 0x00, 0x00, 0x55, 0x55 comes through to the PC C# app as UUUU Regards, Karthik
-
Hi, I need to tranfer hex values through UART. But the problem is the default ASCII encoding of the SerialPort omits zeroes and such values (mostly below 0x14). What do I change this setting to in order to receive all values from 0-255 through the port? Please Help. For ex: 0x55, 0x55, 0x00, 0x00, 0x55, 0x55 comes through to the PC C# app as UUUU Regards, Karthik
If you want to send or receive all possible byte values, then your data isn't text, and you should stay away from all text-oriented methods and classes. So the words "ASCII" and "encoding" do not apply, just use the Read() and Write() methods which deal with byte arrays; they'll handle everything (unless you have set DiscardNull to true). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
If you want to send or receive all possible byte values, then your data isn't text, and you should stay away from all text-oriented methods and classes. So the words "ASCII" and "encoding" do not apply, just use the Read() and Write() methods which deal with byte arrays; they'll handle everything (unless you have set DiscardNull to true). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
@gszakacs : That did it! I set SerialPort.DiscardNull = False and I was able to see all the hex values. I was using code from a previous project where I used 50-50 encoding to transmit data. Thank you!