|
ASCII-HEX & Binary on RSR232Next Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Rutu Patil Posted 24-Aug-2004 09:25 Toolset None |  ASCII-HEX & Binary on RSR232 Rutu Patil Hi,
Normally when we use printf to output on RSR232, in which format it outputs.
ascii-hex or binary.How to set the output format.
rutu | | Read-Only Author Jon Ward Posted 24-Aug-2004 10:26 Toolset None |  RE: ASCII-HEX & Binary on RSR232 Jon Ward The output is in ASCII characters.
I've never heard of ASCII-HEX. What is it?
Jon | | Read-Only Author Andrew Neil Posted 24-Aug-2004 10:50 Toolset None |  RE: ASCII-HEX & Binary on RSR232 Andrew Neil "The output is in ASCII characters."
To be precise (as the original post seems very vague), the output is a string of bytes where the numerical value of each byte is the ASCII code for a character.
Here are some examples of numerical byte values (shown in binary, octal, decimal, and hex) and the corresponding characters from the ASCII code:
Binary Octal Decimal Hex ASCII
-------- ----- ------- --- -----
00110000 060 48 30 '0'
00110001 061 49 31 '1'
01000001 101 65 41 'A'
01100001 141 97 61 'a'
| | Read-Only Author Drew Davis Posted 24-Aug-2004 19:56 Toolset None |  RE: ASCII-HEX & Binary on RSR232 Drew Davis U8 val = 65;
printf ("%02bx", val);
will produce two characters of output -- "40" -- which is what I think you mean by "ASCII HEX".
printf ("%c", val);
will produce the output "A", or 65 decimal, which is what I think you mean by "binary". | | Read-Only Author Drew Davis Posted 24-Aug-2004 19:57 Toolset None |  RE: ASCII-HEX & Binary on RSR232 Drew Davis That's "41" hex, of course. I'm really out of it today. So just trust these guys instead:
http://www.asciitable.com/ | | Read-Only Author Rutu Patil Posted 25-Aug-2004 02:53 Toolset None |  RE: ASCII-HEX & Binary on RSR232 Rutu Patil Hi,
Thankx andrew fro explanation also drew i caught me wright.
Actually if i use uchar val=0x0A; printf ("%02bx", val); it should output "0A" and not a linefeed. since with printf ("%c", val); i get a linefeed.
I got the point thankx. rutu | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|