Shop OBEX P1 Docs P2 Docs Learn Events
Receiving Decimal -vs- String through Uart — Parallax Forums

Receiving Decimal -vs- String through Uart

trytryagaintrytryagain Posts: 26
edited 2009-09-30 23:30 in General Discussion
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)
·

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-09-30 23:01
    Not sure what you mean but I guess you mean

    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
  • trytryagaintrytryagain Posts: 26
    edited 2009-09-30 23:30
    roll.gif·Peter,

    Thank you so much, I did not know about (char) !

    Jeff
Sign In or Register to comment.