STMicroelectronics / fp-sns-datalog2

The FP-SNS-DATALOG2 function pack represents an evolution of FP-SNS-DATALOG1 and provides a comprehensive solution for saving data from any combination of sensors and microphones configured up to the maximum sampling rate. Please check st.com where a more recent version of the software might be available.
https://www.st.com/en/embedded-software/fp-sns-datalog2.html
Other
17 stars 1 forks source link

Data recording stops for a second #12

Closed Ferag-AG closed 3 months ago

Ferag-AG commented 7 months ago

Hi

As I already mentioned in the issue https://github.com/STMicroelectronics/fp-sns-datalog2/issues/11#issuecomment-1947921869 there are sporadic recording gaps occuring.

This only applies to sensors that are read periodically using an OS timer, i.e. in the case of the basic FW implementation, the temperature sensor STTS22H and it seems to depend on the device configuration. When I define the configuration to use only the STTS22H, no gaps appear, but using the configuration as below, the time between each execution of the timer function may randomly exceed one second.

I modified the STTS22HTaskTimerCallbackFunction to detect this condition as follows:

static void STTS22HTaskTimerCallbackFunction(ULONG param)
{
  STTS22HTask *p_obj = (STTS22HTask *) param;
  SMMessage report;
  report.sensorDataReadyMessage.messageId = SM_MESSAGE_ID_DATA_READY;
  report.sensorDataReadyMessage.fTimestamp = SysTsGetTimestampF(SysGetTimestampSrv());

  double delta_timestamp = report.sensorDataReadyMessage.fTimestamp - p_obj->prev_timer_timestamp;

  if (delta_timestamp > 1.5f * (p_obj->task_delay / 1000.0f))
  {
    SYS_DEBUGF(SYS_DBG_LEVEL_WARNING, ("STTS22H: timer interval exceeded %.2f\r\n", delta_timestamp));
  }
  p_obj->prev_timer_timestamp = report.sensorDataReadyMessage.fTimestamp;

  if (TX_SUCCESS != tx_queue_send(&p_obj->in_queue, &report, TX_NO_WAIT))
  {
    /* unable to send the report. Signal the error */
    sys_error_handler();
  }
}

As the following log file shows, during recodring the console output the message STTS22H: timer interval exceeded 1.02.

STWIN.box.log

Here is the recorded data: DL2_00001.zip

Remark


Setup

Device : STWIN.box (USB or battery powered) Device Config: device_config.json IDE: µVision V5.38.0.0 Compiler: V6.19

Ferag-AG commented 7 months ago

Hi

Here what I found out today:

As the reading of my sensor is activated by an OS timer, I searched for a possible reason for the gap at this level. I noticed that the OS timer task was set to 20 (TX_TIMER_THREAD_PRIORITY) whereas most of the other tasks have a higher priority (resp. a lower value). I set the timer priority to 2 and since then the error seems to be gone.

It would be wise to review the distribution of OS priorities to ensure that this change does not have any further impact.

Regards Ludwig