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
"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'
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".
That's "41" hex, of course. I'm really out of it today. So just trust these guys instead: http://www.asciitable.com/
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