RE: Question about GTK+ and timers
- From: "Mikhail Titov" <mlt gmx us>
- To: "'Igor Korot'" <ikorot01 gmail com>, <gtk-list gnome org>
- Subject: RE: Question about GTK+ and timers
- Date: Fri, 8 Apr 2011 18:36:41 -0500
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 .
> -----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?
> And then just get m_data, m_data, m_data, m_data,
> m_data and m_data?
> 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
] [Thread Prev