0

AJTCL Bus Inspector

asked 2015-01-20 08:36:34 -0700

iker gravatar image

Hi, I woul like to know or if someone can give me some advices about a proove of concept i want to do.

My idea is to try to generate a bus XML inspector/injector..

I mean a tool that show all AllJoun Buss events like notifications as an XML object and also that tools would allow to submit a notifications using XML

xml <-- listen <-- bus : to listen for notification xml --> push --> bus : to send a notification

My idea is to do in it on C.

PD: I have seen that the best way could be handling AJ_Messages.. and the convert message to xml and XML to message..

Regards.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-01-22 15:35:22 -0700

Nikhil Dabhade gravatar image

Hi iker,

I am not sure about the use case you are trying to target but if I were to make a guess it would be so that you could have the xml ready in a form that is consumable by a web service which can be used to push these notification over the web.

Keeping the use case aside and coming to the good part: the code :)

AJ_Status AJ_UnmarshalMsg(AJ_BusAttachment* bus, AJ_Message* msg, uint32_t timeout);

unmarshals a message and converts it to a message structure which if you look at the header file aj_msg.h it will get converted to

struct _AJ_Message {
    uint32_t msgId;            /**< Identifies the message to the application */
    AJ_MsgHeader* hdr;         /**< The message header */
    union {
        const char* objPath;   /**< The nul terminated object path string or NULL */
        uint32_t replySerial;  /**< The reply serial number */
    };
    union {
        const char* member;    /**< The nul terminated member name string or NULL */
        const char* error;     /**< The nul terminated error name string or NULL */
    };
    const char* iface;         /**< The nul terminated interface string or NULL */
    const char* sender;        /**< The nul terminated sender string or NULL */
    const char* destination;   /**< The nul terminated destination string or NULL */
    const char* signature;     /**< The nul terminated signature string or NULL */
    uint32_t sessionId;        /**< Session id */
    uint32_t timestamp;        /**< Timestamp */
    uint32_t ttl;              /**< Time to live */
    /*
     * Private message state - the application should not touch this data
     */
    uint8_t sigOffset;         /**< Offset to current position in the signature */
    uint8_t varOffset;         /**< For variant marshalling/unmarshalling - Offset to start of variant signature */
    uint16_t bodyBytes;        /**< Running count of the number body bytes written */
    AJ_BusAttachment* bus;     /**< Bus attachment for this message */
    struct _AJ_Arg* outer;     /**< Container arg current being marshaled */

};

You could convert the structure above to xml and pass it above to the application layers which will present the data in xml format that you want. This will be additional processing and you will need to consider scalability considering if you can get too many notifications in a short period and also memory depending on the intended platform.

Nikhil

edit flag offensive delete publish link more
0

answered 2015-01-23 00:52:40 -0700

iker gravatar image

Hi Nikhil,

That was exactly was i was trying..

AJ_Status local_status;

local_status = AJ_UnmarshalMsg(&msg->bus, &nmsg, AJAPP_UNMARSHAL_TIMEOUT);
if(local_status == AJ_OK){
    printf("\tHandling message!!\n");
    printf("\tInterfcace----> %s\n", nmsg.iface);
    printf("\tSender----> %s\n", nmsg.sender);
    printf("\tDestination----> %s\n", nmsg.destination);
}

while(AJ_UnmarshalArg(msg, &arg) == AJ_OK){

    printf("Arg Type----> %i\n", arg.typeId);
    printf("Arg PAth----> %s\n", arg.val.v_objPath);
    //printf("Arg String----> %s\n", arg.val.v_data);
}

I can get some values but i do not know how to parse entire message, if i inspect the whole message with wireshark i see a lot of info.. that was the reason I was asking if any kind of XML generator/Inspector existed.. to use it to convert object --> xml and xml ---> object in a "standar" way...

PD: yes, the motivation of this POC is to route some al_message over internet with an xml based protocol..

Regards.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2015-01-20 08:36:34 -0700

Seen: 149 times

Last updated: Jan 23 '15