abcd12344445555
Programmer
I’ve got an equipment that receives some data from the network and map it to the structures below:
At some point, the received info is routed to another equipment using the following functions:
The problem is that now I need to generate one message locally invoking checkSet() with something like :
I don't know how to make this message not to fail at the assert of the function send();
The message must have size 0 and no data.
How can I create a message with msg->payload.data == NULL?
Im trying something like this, but it still fails at the assert, cause msg->payload.data != NULL and msg->payload.datasize == 0
Best Regards,
P.
Code:
struct a_s{
u_int16_t cmd;
u_int16_t dataSize;
u_int8_t data[MAX_DATA_SIZE];
};
typedef struct a_s a_t;
struct b_s {
u_int16_t part;
u_int16_t serial;
a_t payload;
};
typedef struct b_s b_t;
At some point, the received info is routed to another equipment using the following functions:
Code:
int checkSet(void * ne, b_t * msg)
{
(…)
send(ne->position, msg->payload.cmd, msg->payload.dataSize, msg->payload.data)
(...)
}
int send(u_int8_t pos, u_int16_t cmd, size_t len, void * payload)
{
assert( ((payload != NULL) && (len != 0)) || ((payload == NULL) && (len == 0)) );
assert( pre(Serial) != NULL );
(...)
}
The problem is that now I need to generate one message locally invoking checkSet() with something like :
Code:
struct b_s localMsg;
localMsg.part = 1;
localMsg.serial = 2;
localMsg.payload.cmd=3;
[COLOR=red] localMsg.dataSize = 0; [/color]
I don't know how to make this message not to fail at the assert of the function send();
The message must have size 0 and no data.
How can I create a message with msg->payload.data == NULL?
Im trying something like this, but it still fails at the assert, cause msg->payload.data != NULL and msg->payload.datasize == 0
Code:
unsigned char buffer[sizeof(b_t )];
memset(buffer,0,sizeof(b_t ));
b_t *msg;
msg = (b_t *) buffer;
msg->tlv.cmd = 0x00A0;
msg->tlv.dataSize = 0;
checkSet(something, msg);
Best Regards,
P.