Using the unet_recv function I notice a possible problem when using it with NO_TIMEOUT.
If NO_TIMEOUT is used, and there is no information to be read, the
semaphore will return by EXIT_BY_NO_ENTRY_AVAILABLE, which isn't equal to
TIMEOUT. This implied in reading wrong information from network to the
application.
I propose this small change to ensure to read the information only if it's was OK.
And to improve it a little bit, return the semaphore status.
int unet_recv(unet_transport_t server_client, uint8_t buffer, uint16_t timeout){
int ret;
if ((ret = OSSemPend(server_client->wake_up,timeout)) == OK)
{
memcpy(buffer,server_client->packet,server_client->payload_size);
}
return ret;
}
Greatings,
Using the unet_recv function I notice a possible problem when using it with NO_TIMEOUT. If NO_TIMEOUT is used, and there is no information to be read, the semaphore will return by EXIT_BY_NO_ENTRY_AVAILABLE, which isn't equal to TIMEOUT. This implied in reading wrong information from network to the application.
I propose this small change to ensure to read the information only if it's was OK. And to improve it a little bit, return the semaphore status.
int unet_recv(unet_transport_t server_client, uint8_t buffer, uint16_t timeout){ int ret; if ((ret = OSSemPend(server_client->wake_up,timeout)) == OK) { memcpy(buffer,server_client->packet,server_client->payload_size); } return ret; }
Best regards! Fabricio