Receiving Decimal -vs- String through Uart
trytryagain
Posts: 26
Peter,
Thanks for the help this morning.
Here's the next issue.
I'm sending a "J" out the uart send port
to my socket and I echo back the same character
except I get back a 74 (the decimal equivelant!)
Do you know why this would occur?
Any quick ideas on a routine to convert decimal
to a string (numbers and letters)?
Thanks Pete,
Jeff(trytryagain)
·
Thanks for the help this morning.
Here's the next issue.
I'm sending a "J" out the uart send port
to my socket and I echo back the same character
except I get back a 74 (the decimal equivelant!)
Do you know why this would occur?
Any quick ideas on a routine to convert decimal
to a string (numbers and letters)?
Thanks Pete,
Jeff(trytryagain)
·
Comments
myUart.sendByte('J'); //send character J
int c = myUart.receiveByte(); //receive echoed J
System.out.print(c); //prints 74 to message window
Change last line to
System.out.print((char)c); //print character J to message window
Creating hexstring
char buffer[noparse]/noparse = new char[noparse][[/noparse]7];
Format.sprintf(buffer,"%04x",value); //print hexstring·with leading zeroes to buffer
Format.printf("%04x",value); //directly to message window
regards peter
Thank you so much, I did not know about (char) !
Jeff