Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: Send Integer to PC with usbMsgPtr

$
0
0
Hi.

Your AVR has an "other understanding" of integer, than your host.

One thing is the endianness (http://en.wikipedia.org/wiki/Endianness).
Your AVR is BIG endian - your PC little endian.
Also your AVR uses just 16bit (??) for int, while your PC uses 4 bytes.

As a convention data always is transmitted in little endian trough networks.
(Usually your PC has much more CPU power to transform it in its own format,
than little microcontrollers have.)

To simplify platform independent code see http://www.gnu.org/software/libc/manual ... Order.html .
(Use hton on the AVR side and ntoh on the PC side)

To avoid type misinterpretation on both sides use "#include <stdint.h>" and then the std-type uint32_t or int32_t.
(http://www.gnu.org/software/gnulib/manu ... 002eh.html AND
http://www.nongnu.org/avr-libc/user-man ... tdint.html)

Best regards

Viewing all articles
Browse latest Browse all 4524

Trending Articles