Sending / Receiving of byte arrays
Bogdan Lotko
boguslaw.lotko at chello.at
Wed Feb 8 13:18:36 PST 2012
Hello,
I have to pass the structure of bit-fields over the D-Bus connection
e.g.
struct XXX
{
uint state1 : 2;
...
uint stateN : 5:
}
I thought (because of possible endianity) the ByteArray will be the best
transport for it.
So I'd like to use the
char buff[n];
and cast it to the struct XXX pointer
XXX *xxxStructPtr = ((XXX *)(buff));
xxxStructPtr->state1 = myStateEnum;
...
After filling the buffer I have to pass it to the QByteArray, I thought
the fromRawData(buff,n) will be most appropriate for it.
What I've been wondering, was if I can use the QByteArray directly as a
"buffer", i.e to cast it to get the pointer to my XXX struct.
Or maybe there is a quite different solution for it?
Thanks for your help
bogdan
On 2/8/2012 21:53, Thiago Macieira wrote:
> On Wednesday, 8 de February de 2012 21.34.45, Bogdan Lotko wrote:
>> I am not sure if the QByteArray will allow such a cast, so I'll probably
>> use the buffer as in the example.
> Or you could just find out if it does and then decide whether to use it using
> actual facts.
>
> Since there was no mention of "cast" in the previous conversation, "such a
> cast" doesn't make sense. It is not referring to a cast discussed in the past.
> If you had said what you wanted to do, I could have already answered you.
>
>
>
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
--
*Bogdan Lotko*
b.lotko at chello.at
Phone: +43 1 2852458
Mobile: +43 676 6615012
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20120208/61618975/attachment.html>
More information about the dbus
mailing list