Re: Question about GTK+ and timers
- From: Igor Korot <ikorot01 gmail com>
- To: gtk-list gnome org
- Subject: Re: Question about GTK+ and timers
- Date: Fri, 8 Apr 2011 16:45:03 -0700
Mikhail,
On Fri, Apr 8, 2011 at 4:36 PM, Mikhail Titov <mlt gmx us> wrote:
> Just use something like __attribute__ ((__packed__)) for your structure and
> you can always cast back and forth from the pointer to your structure to an
> array of bytes (char*). Just make sure that both systems have same ending
> (little or big) and that members' order is correct. Otherwise you'll have to
> swap data within let's say m_voltageMask .
My intention is to run the program on the ARM architecture (armv4t) - S3C2440
mini2440 device from FriendlyARM. So I don't think the endianess will
be the same here.
I am building everything from the OpenEmbedded tree with the
arm-angstrom-gnueabi
gcc compiler.
What would be the syntax with it?
[code]
__attribute__((__packed__))
struct Data
{
.............
} m_data;
and what do you mean by swapping the order of the data?
I am just relying on the cross-compiler to do the right thing for me
in terms of endianess.
Should I care about that?
Thank you.
>
> Mikhail
>
>
>> -----Original Message-----
>> From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] On
>> Behalf Of Igor Korot
>> Sent: Friday, April 08, 2011 5:43 PM
>> To: gtk-list gnome org
>> Subject: Re: Question about GTK+ and timers
>> >> Is it possible to use m_data with GIOChannel?
>> >
>> > of course.
>> >
>> > but you'd better hope that the compiler packs that data structure in
>> > the same way the device is sending it. you'd be far better off not
>> > using a struct for this, but just reading (in your case) 10 bytes.
>> >
>> > sending raw C structs over any kind of "wire protocol" almost always
>> > turns out to be huge mistake unless its been very carefully thought
>> > about.
>>
>>
>> So best way is to use char m_data[10]?
>>
>> And then just get m_data[4], m_data[5], m_data[6], m_data[7],
>> m_data[8] and m_data[9]?
>>
>> I am getting bytes over the wire thru the serial port and transfer is
>> performed on the client side.
>>
>> read( handle, &m_data, 10 );
>>
>> I am just getting 10 bytes which are represented on the client as
>> m_data members.
>>
>> Am I wrong here? It's possible there will be a packing issue, but I'm
>> about to test this.
>>
>> Thank you.
>>
>> >
>> _______________________________________________
>> 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]