[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

RE: Question about GTK+ and timers



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 .

Mikhail


> -----Original Message-----
> From: gtk-list-bounces@xxxxxxxxx [mailto:gtk-list-bounces@xxxxxxxxx] On
> Behalf Of Igor Korot
> Sent: Friday, April 08, 2011 5:43 PM
> To: gtk-list@xxxxxxxxx
> 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@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[GIMP Users]     [Yosemite News]    [Yosemite Photos]    [Gimp's Home]     [Steve's Art]

Add to Google Powered by Linux