SNTP_oneshot mistakenly return RTCS_OK

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SNTP_oneshot mistakenly return RTCS_OK

ソリューションへジャンプ
1,466件の閲覧回数
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,357件の閲覧回数
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,358件の閲覧回数
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 件の賞賛