Code clean up and handling FIFO errors

Revision:
55:215da406282b
Parent:
50:d84305e5e1c0
Child:
56:38b36e947602
--- a/common/utils.c	Wed Feb 19 10:08:13 2020 +0000
+++ b/common/utils.c	Mon Feb 24 07:04:35 2020 +0000
@@ -132,7 +132,7 @@
     uint32_t nNumSamples,
     ADMW_MEASUREMENT_MODE eMeasurementMode)
 {
-
+    static uint32_t samplesCounter;
     for (uint32_t i = 0; i < nNumSamples; i++) {
         ADMW_LOG_INFO("Sample # %2d Channel # %2d :: Raw %X %f :: Processed %f :: flags:%s%s",
                       i+1,
@@ -142,6 +142,8 @@
                       pSampleBuffer[i].status & ADMW_DEVICE_STATUS_ERROR ? " ERROR" : "",
                       pSampleBuffer[i].status & ADMW_DEVICE_STATUS_ALERT ? " ALERT" : "");
     }
+    samplesCounter++;
+    ADMW_LOG_INFO("Sample count=%d",samplesCounter);
 }
 
 static void gpioCallbackFn(ADMW_GPIO_PIN ePinId, void * pArg)
@@ -237,7 +239,7 @@
     ADMW_MEASUREMENT_MODE eMeasurementMode)
 {
     ADMW_RESULT res;
-
+    static uint32_t samplesLost;
     volatile bool bDataReady = false;
     volatile bool bError = false;
     volatile bool bAlert = false;
@@ -314,8 +316,11 @@
                          * be non-zero for some channels, resulting in
                          * variable-length sequences
                          */
+                         
                         ADMW_LOG_DEBUG("Retrieved %u of %u requested data samples",
                                        nReturned, nSamplesPerDataready);
+                        samplesLost++;
+                        ADMW_LOG_INFO("samples lost=%d",samplesLost);               
                         continue;
                     } else {
                         ADMW_LOG_WARN("Failed to get data samples from device");