Can not create a array message correctly
Alex Bunnett
alexb at fusionelectronics.com
Tue Jul 21 17:46:30 PDT 2009
Sorry to keep posting about this Problem but I can not find a solution for this problem.
I am unable to send a byte message across the bus correctly!
This is the methods I am creating the message with and reading with.
Can you see any problems?
When I read the message out I get the correct type and length but data is incorrect
Creating....
message = dbus_message_new_method_call(CLIENT_SEND_NAME, CLIENT_SEND_OBJECT, SEND_INTERFACE_SERVER, "servermessage");
if(message == NULL)
{
__ALEX("Message NULL cant send");
return 0;
}
DBusMessageIter iter, sub;
dbus_message_iter_init_append(message, &iter);
char buf[2];
buf[0] = DBUS_TYPE_BYTE;
buf[1] = '\0';
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, buf, &sub);
if(!dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &pBuff, len))
{ dbus_message_unref(message);
return 0;
}
dbus_message_iter_close_container(&iter, &sub);
if(!dbus_connection_send(_connection, message, &serial))
{
dbus_message_unref(message);
return 0;
}
dbus_connection_flush(_connection); // force message to be sent now
Reading.....
DBusMessageIter args1, subiter;
if (!dbus_message_iter_init(message, &args1))
{
dbus_message_unref(message);
}
if ( dbus_message_iter_get_arg_type(&args1) == DBUS_TYPE_ARRAY)
{
int maxlen = 100;
uint8_t pBuff1[100];
dbus_message_iter_recurse (&args1, &subiter);
dbus_message_iter_get_fixed_array(&subiter, &pBuff1, &maxlen); // this is incorrect not what I wrote in
}
Thanks for your times
[cid:image001.jpg at 01CA0ACA.0B1C5C40]<http://www.fusioncaraudio.com/>
Alex Bunnett
Embedded Software Engineer
Ph: +64-9-369-2900
DDI: +64-9-369-2940
Fax: +64-9-369-2907
Email: alexb at fusionelectronics.co.nz<mailto:alexb at fusionelectronics.co.nz>
Website: http://www.fusionelectronics.com
The information in this email and any attachments is confidential. This information may be subject to legal, professional, or other privilege. It must not be disclosed to any person without our authority. If you are not the intended recipient you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. Please return this message to the sender immediately and delete any and all copies from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20090722/ff4e00d9/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/x-citrix-jpeg
Size: 3610 bytes
Desc: image001.jpg
Url : http://lists.freedesktop.org/archives/dbus/attachments/20090722/ff4e00d9/attachment-0001.bin
More information about the dbus
mailing list