Hi, guys, On Sat, Apr 9, 2011 at 4:04 AM, Chris Vine <chris@xxxxxxxxxxxxxxxxxxxxx> wrote: > On Sat, 9 Apr 2011 00:14:45 -0700 > Igor Korot <ikorot01@xxxxxxxxx> wrote: > [snip] >> Is there any way to find out if the device is little- or big-endian? > > Which device are you referring to? You appear to be writing some > code for a machine receiving data sent over a wire, and that machine's > endianness can be tested by seeing whether G_BYTE_ORDER is defined as > G_LITTLE_ENDIAN or G_BIG_ENDIAN, and then used for conditional > compilation purposes. glib also has some built in byte-swapping macros: > > http://developer.gnome.org/glib/stable/glib-Byte-Order-Macros.html > > However the thing that puzzles me is that there are other issues here, > apart from the byte order of data elements whose size is greater than 1. > As another poster has pointed out, the format of the data stream > requires specification somewhere. How do you know it is sent as structs > with the potentially compiler-dependent layout that you referred to? As > I mentioned (and others have mentioned) earlier, what is being sent is > serialised data. What you need to know is how the data packet layout > of the serialised data is specified and work from there. This is very simple. If I connect the device to the x86-based machine and run minicom I can see a string of numbers which is received from the device. By looking at the documentation I can find out that the first byte (let's say it's chr(3)) correspond to some particular data. However minicom will dispaly it as 03. And so forth. Now what I want to do is read those data in the m_data, grab some pieces, convert them to double and present them to the screen. Some data that I need are 2 bytes, some 3 bytes and some just 1 byte. I thought I could rely on the compiler to do the right thing in terms of endianess, however it looks like from my testing and what you all telling me I was wrong. And I need to take care of this by myself. I will look if I can compile serial port software to be run on this device to get a data dump from serial device and check if I need to do something additional. Thank you. > > Chris > > > _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list