Send Hex With fdserial.h
Keith Young
Posts: 569
I am trying to send the following using fdserial.h:
0xBE
0xEF
0
3
1
4
then a checksum which I think is 2
The problem is when receiving with the Parallax Serial Terminal, when I try to send 0xBE I get a symbol which is small, but I think it's the symbol "3/4"
How can I send something that will show up in Parallax Serial Terminal as BE, and hopefully be accepted as a Hex value rather than a string?
Thanks for the help.
0xBE
0xEF
0
3
1
4
then a checksum which I think is 2
The problem is when receiving with the Parallax Serial Terminal, when I try to send 0xBE I get a symbol which is small, but I think it's the symbol "3/4"
How can I send something that will show up in Parallax Serial Terminal as BE, and hopefully be accepted as a Hex value rather than a string?
Thanks for the help.

Comments
Example:
I'd gotten it to kind of work. The problem (I think) was it sending lower case Hex (definitely lower case), then the handshake fails. I wonder if the handshake is case sensitive.
The functions printf / dprint / etc are doing a number to "ascii hex" conversion, which takes 4-bit chunks of the number and sends them as the ascii characters '0' to '9' and 'A' to 'F', to represent the 16 values possible for those 4 bits.
You can do it yourself easily, like this:
void SendHex( int value ) { int shift = 32-4; // Start with the upper four bits // Scan the value until we find some non-zero bits (removes leading zeros) while( ((value >> shift) & 0xF) == 0 && shift > 0 ) shift -= 4; do { int nybble = (value >> shift) & 0xF; // Grab the four bits starting at index "shift" char sendThis; if( nybble < 10 ) sendThis = '0' + nybble; // values from 0 to 9 are the ascii characters '0' to '9' else sendThis = 'A' + (nybble-10); // values from 10 to 15 are the characters 'A' to 'F' fdserial_txChar( serial, sendThis ); shift -= 4; } while( shift > 0 ); }Note that I haven't actually compiled / run this code, but hopefully it conveys the idea.