MQX 4.2
I think I found a bug in SNTP_oneshot(). By accident SNTP_oneshot() returns RTCS_OK while NTP server is not reachable.
If the TPC/IP is very busy, the select function will return RTCS_ERROR because RTCSCMD_issue can't alloc a message from queue pool. Then the err is not zero, it causes a wrong RTCS_OK return value.
static uint32_t SNTP_timed_send_recv
(
uint32_t sock,
/*[IN] socket */
_ip_address *destination,
/*[IN] remote IP NTP service */
uint32_t *msec_count_ptr
/*[IN] millisecond timeout value */
)
{ /* Body */
………………………………………..
/* Accept only correct replies */
do {
…………………………………………………
RTCS_FD_ZERO(&rfds);
RTCS_FD_SET(sock, &rfds);
err = select(1, &rfds, NULL, NULL, timeout);
if(RTCS_ERROR == err)
{
break;
}
…………………………………….
} while (msec_count > 0);
*msec_count_ptr = msec_count;
if (err == 0) {
error_code = RTCSERR_TIMEOUT;
} else {
error_code = RTCS_OK;
} /* Endif */
return error_code;
} /* Endbody */
已解决! 转到解答。
Hi S.z:
Thanks you for your feedback. I would suggest you change 'break' to 'continue', this maybe fix this issue.
Regards
Daniel