alexh-name / bsec_bme680_linux

Read the BME680 sensor with the BSEC library on Linux (e.g. Raspberry Pi)
Other
87 stars 48 forks source link

Strange sleep function #28

Closed wiedehopf closed 1 year ago

wiedehopf commented 3 years ago

https://github.com/alexh-name/bsec_bme680_linux/blob/aca3e1f21845f45dd0157b53163ce26de57f60e9/bsec_bme680.c#L139

Is there a reason this never sleeps more than a second? This would be the more obvious code for that function, actually assigning something to the sleep seconds?

void _sleep(uint32_t t_ms)
{
  struct timespec ts;
  ts.tv_sec = t_ms / 1000;
  /* mod because nsec must be in the range 0 to 999999999 */
  ts.tv_nsec = (t_ms % 1000) * 1000000LL;
  nanosleep(&ts, NULL);
}
alexh-name commented 1 year ago

Thanks, fixed in 027c96f.