SNTP_oneshot mistakenly return RTCS_OK

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SNTP_oneshot mistakenly return RTCS_OK

跳至解决方案
1,739 次查看
shaozhongliangs
NXP Employee
NXP Employee

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 */

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,630 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi S.z:

Thanks you for your feedback. I would suggest you change 'break' to 'continue', this maybe fix this issue. 

Regards

Daniel

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,631 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi S.z:

Thanks you for your feedback. I would suggest you change 'break' to 'continue', this maybe fix this issue. 

Regards

Daniel

0 项奖励
回复