sht3x-esp-idf icon indicating copy to clipboard operation
sht3x-esp-idf copied to clipboard

ESP32: sdk_system_get_time() does not overflow properly

Open shaffenmeister opened this issue 4 years ago • 0 comments

Observation: sdk_system_get_time() returns 0xFFFFFFFF instead of rolling over properly when the term time.tv_sec*1e6 + time.tv_usec exceeds max(uint32_t).

Module: components/esp8266_wrapper/esp8266_wrapper.c

Workaround: uint32_t sdk_system_get_time () { struct timeval time; gettimeofday(&time,0); return (uint32_t) (time.tv_sec*(long int)1e6 + time.tv_usec); }

I am not sure which type cast would be required here instead of (long int).

Environment:

  • ESP 32 WROOM 32
  • Ubuntu 18.04 64 bit
  • espidf 4.0.0
  • cmake 3.16.4
  • esptool.py 2.6.0
  • ninja 1.7.1
  • esp32ulp 1.22851.190618 (2.28.51)
  • xtensa32 2.80200.200226 (8.2.0)

Kind regards,

Christoph

P.S. Thank you for sharing this excellent piece of code.

shaffenmeister avatar May 12 '20 09:05 shaffenmeister