message error?

Alex Bunnett alexb at fusionelectronics.com
Wed Jul 15 14:53:34 PDT 2009


Hi guys really in a pickle at the moment.
Trying to get dbus running on our arm9 platform and having problems creating a message. I have it all working the other day im sure but can no longer create/read a message sent across the bus.

This is the code im just trying to create and read a message with. Any help would be huge as im currently pulling out my hair and there is little to no help on the internet.

Thanks


    DBusMessage*                      message;
    dbus_uint32_t                        serial; // TODO What is this?

    int ret = dbus_bus_request_name(_connection, CLIENT_SEND_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &_error);

    dbus_connection_flush(_connection);

    if (dbus_error_is_set(&_error)) {
              __ALEX("Name Error (%s)", _error.message);
              dbus_error_free(&_error);
    }

    if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret)
    {
               if(ret != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
               {
                           __ALEX("Couldn't add signal source %i", ret);
                           __EXCEPT(EXCEPTION_APPLICATION);
               }
    }

    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;

 /*   if(!dbus_message_iter_init(message, &iter))
    {
                        __ALEX("Couldnt set up iter");
                        dbus_message_unref(message);
                        return 0;
    }*/

    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);

    __ALEX("address 0x%X",(int)&pBuff);
    __ALEX("address1 0x%X",(int)pBuff);

    if(!dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &pBuff, len))
    {
            __ALEX("couldnt append message");
                        dbus_message_unref(message);
            return 0;
    }
    dbus_message_iter_close_container(&iter, &sub);

    if(!dbus_connection_send(_connection, message, &serial))
    {
                        __ALEX("Couldn't Send message");
                        dbus_message_unref(message);
                        return 0;
    }

    dbus_connection_flush(_connection); // force message to be sent now
    //dbus_message_unref(message);
    //return len;

            DBusMessageIter args1, subiter;

            if (!dbus_message_iter_init(message, &args1))
            {
                        dbus_message_unref(message);

                        __ALEX("Couldnt get int")
            }

            if ( dbus_message_iter_get_arg_type(&args1) == DBUS_TYPE_ARRAY)
            {
                        int maxlen = 100;
                        uint8_t pBuff1[100];

                        dbus_message_iter_recurse (&args1, &subiter);

                        __ALEX("%i",dbus_message_iter_get_arg_type(&subiter));

                        dbus_message_iter_get_fixed_array(&subiter, &pBuff1, &maxlen);

                        __ALEX("TYPE ARRAY");

                        for(int i = 0; i < maxlen; i++)
                        {
                                    __ALEX("Sending [%i] -> 0x%02x  instead 0x%02x",i, pBuff1[i], pBuff[i])  // these are not matching!!
                        }

            }

    dbus_message_unref(message);
    return len;



[cid:image001.jpg at 01CA05FB.486CA3D0]<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/20090716/28f02ce8/attachment-0001.htm 
-------------- 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/20090716/28f02ce8/attachment-0001.bin 


More information about the dbus mailing list