ER_BUS_BAD_ VALUE_TYPE from Signal() with multiple arguments

asked 2015-10-02 11:36:23 -0700

wongni gravatar image


I am trying to send a signal with multiple arguments; an integer and a string. But I am getting an error from BusObject::Signal() method like below.

   2.153 ****** ERROR ALLJOYN external14312     ...re\src\Message_Gen.cc:1030 |
MarshalMessage: SIGNAL[11] com.se.Bus.Discovery.DeviceStatusChanged: ER_BUS_BAD_

I added a signal to the interface like this.

testIntf->AddSignal("DeviceStatusChanged", "us", "Branch,DeviceStatus", 0);

When I print an XML of the interface I get this.

<interface name="com.se.Bus.Discovery">
  <signal name="DeviceStatusChanged">
    <arg name="Branch" type="u" direction="out"/>
    <arg name="DeviceStatus" type="s" direction="out"/>

I sent a signal like this.

MsgArg deviceStatusChangedArg("(us)", i + 1, deviceStatusArray[i]);
uint8_t flags = 0;
busObject->Signal(NULL, s_sessionId, *deviceStatusChangedSignalMember, &deviceStatusChangedArg, 2, 0, flags);

If I print the MsgArg before sending the signal, I get this.


Does anyone know what I miss here? When I tried the same thing with a single argument it worked perfectly.

Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-10-02 13:17:00 -0700

bspencer gravatar image

updated 2015-10-05 10:53:55 -0700


This is actually quite simple to solve. When you construct your message arg you have "(us)" which is a record/structure of an unsigned int and a string, which does not match with a unsigned int and string that you have defined for the interface "us". The print out of the message arg should just be the inner parts of the struct tag to match the definition of the signal arguments. So you should have the following and then your code will work:

MsgArg deviceStatusChangedArg[2];
deviceStatusChangedArg[0].Set("u", i+1);
deviceStatusChangedArg[1].Set("s", deviceStatusArray[i]);

You should be good once you make the above change.

edit flag offensive delete publish link more


Hi, Thank you for your reply. However, I got another error when I removed '()' from the first argument of the MsgArg constructor. 2.153 ****** ERROR ALLJOYN external10828 ...yn_core\src\MsgArg.cc:1193 | MsgArg constructor signature "s" failed: ER_OK <invalid/>

wongni ( 2015-10-05 08:44:10 -0700 )edit

What is deviceStatusArray defined as? Is this an array of chars? the value going into an "s" needs to be a char*. You can look at the MsgArg unit test(https://git.allseenalliance.org/cgit/core/alljoyn.git/tree/alljoyn_core/unit_test/MsgArgTest.cc). You need "us" since you have it in the interface.

bspencer ( 2015-10-05 10:15:33 -0700 )edit

const char** deviceStatusArray = new const char*[maxNumDevice]; so deviceStatusArray[i] is defined as const char *, I think.

wongni ( 2015-10-05 10:27:12 -0700 )edit

Sorry, the multi-arg creation wasn't working since you are trying to set multiple MsgArg elements to a single MsgArg, if it was a Struct (contained "()") or Dictionary(contained "{}") then you can use the constructor. Otherwise you need to do as I have done in the edit of my answer.

bspencer ( 2015-10-05 10:55:21 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-10-02 11:36:23 -0700

Seen: 28 times

Last updated: Oct 05 '15