1 Reply Latest reply on Jun 18, 2015 5:58 PM by erthc_2130261

    bug in time.c wiced_time_get_iso8601_time() function

      This wiced_time_get_iso8601_time() does not do a bitwise AND of a number that is frequently greater than 65000, when it converts to a uint16_t. Consequently the result is normally wrong.

       

      Specifics: the local variable uint16_t sub_second is computed as follows. You should always have "000" on the end of the final result, because you take a millisecond value and convert it to microseconds by multiplying by 1000.

       

      wiced_time_get_utc_time_ms( &utc_time_ms );

      second     = utc_time_ms / 1000;               /* Time is in milliseconds. Convert to seconds */
      sub_second = (uint16_t) (( utc_time_ms % 1000 ) * 1000 ); /* Sub-second is in microseconds               */

       

      /************** Code corrected with int temp variable ***********************/
          temp = (int) (utc_time_ms & 0xFFFF);
          temp = (temp % 1000) * 1000;
          printf("******* temp: %d; sub_sec: %d\r\n", temp, sub_second);
        

      /************ temp and sub_second should be identical, but they almost never are.

      Code extracted from WICED version 3.1.2

      ******/