Re: Question about GTK+ and timers



Robert,

On Fri, Apr 8, 2011 at 11:53 PM, Robert Pearce <rob bdt-home demon co uk> wrote:
> Hi Igor,
>
> On Fri, 8 Apr 2011 18:08:30 -0700 you wrote:
>> So, what is the best course of action?
>> I just tested the program on the device and on x86. On x86 it produced correct
>> results, whereas on the ARM device it didn't.
>> So it looks like I will have to switch the endianess when running on the ARM?
>>
> When talking to a remote device over a serial port, what you are
> receiving is fundamentally a byte stream, so the best way to handle it
> is to admit that in your code. Read it into an array of (unsigned)
> char, do any formatting / alignment checks that you can, and then
> extract the data into the variables you want it in. If there are raw
> binary values of more than one byte, extract them explicitly:
>
>   MyWordVal = buf[2] + ( buf[3] * 256 );  /* data stream is little endian */
>
> This is portable and clear to any future maintainer. The efficiency
> loss is negligible.

Is there any way to find out if the device is little- or big-endian?

Also, I believe that the device spit out raw data in forms of characters.

And I failed to produce the same result as I got on x86.

But I want to know for sure.

And the code for the big-endian will look like:

MyWordVal = buf[3] + ( buf[2] * 256 );

right?

Thank you.

>
> Cheers,
> Rob
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]