You should probably start by learning the C language. This may help:
http://en.wikibooks.org/wiki/C_Programming

But a quick answer goes something like this:

A 'C' string like "gv" is an array of chars (or bytes to most machines)
so it may be declared and initialized thusly:

    char string[] = "gv";

You can get to each byte by indexing the array:

    char byte1 = string[0];
    char byte2 = string[1];

So byte1 one will be 'g' and byte2 will be 'v', where the hex values
of those ASCII chars are 0x67 and 0x76 respectively (assuming I
interpreted the number conversions correctly from this):
http://www.asciitable.com/

The assignment works both ways of course so you can build up
a string like this (note that real C strings are defined to
be terminated with a null (0) character):

    char newstring[3];

    newstring[0] = 'g';
    newstring[1] = 0x76;
    newstring[2] = 0x00;

MS

Sikar Chan wrote:
Hello

I connected a CmuCAM3 to Tmote Sky via the UART0. I want to ask how to convert a string like "gv" to bytes in order to send it to CmuCAM via UART0.

Thanks a lot

Regards
Sikar Chan


------------------------------------------------------------------------

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to