zproto icon indicating copy to clipboard operation
zproto copied to clipboard

in generated xxx_send function codec puts code from one message into another.

Open steve6354 opened this issue 7 years ago • 1 comments

When 2 different xml defined messages each contain a 'msg' field, the code for only one of them ends up in the send handling for both. Here is a snip of the two definitions from the xml file.

A single CommandMessageData object 231B14A411

A sequence of 'protobuf' defined parameters SomeParam4145851f

and here is a snip of the relevant section from the xxx_send function

switch (self->id) { case CODEC_ERROR_COMMANDMESSAGEDATA: PUT_NUMBER2 (self->sequence); nbr_frames += self->command_message_data? zmsg_size (self->command_message_data): 1; have_param_sequence = true; break;

    case CODEC_ERROR_SETPARAMETER:
        PUT_NUMBER2 (self->sequence);
        nbr_frames += self->param_sequence? zmsg_size (self->param_sequence): 1;
        have_param_sequence = true;
        break;

}
//  Now send the data frame
zmq_msg_send (&frame, zsock_resolve (output), --nbr_frames? ZMQ_SNDMORE: 0);

//  Now send the param_sequence if necessary
if (have_param_sequence) {
    if (self->param_sequence) {
        zframe_t *frame = zmsg_first (self->param_sequence);
        while (frame) {
            zframe_send (&frame, output, ZFRAME_REUSE + (--nbr_frames? ZFRAME_MORE: 0));
            frame = zmsg_next (self->param_sequence);
        }
    }
    else
        zmq_send (zsock_resolve (output), NULL, 0, 0);
}

You can see in the switch statement the 'have_param_sequence' variable is set to true for both message IDs. Then there is only an 'if (have_param_sequence)' block which will only check for 'param_sequence'. So a COMMANDMESSAGEDATA message type will always send an empty frame.

steve6354 avatar May 31 '17 18:05 steve6354

Sorry, the xml code I tried to add directly to the original post did not copy properly. Here is a pdf of the xml 'message' definitions.

codec_error_xml.pdf

steve6354 avatar May 31 '17 18:05 steve6354