![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code clean up and handling FIFO errors
Diff: common/utils.c
- Revision:
- 67:d36977cbfe90
- Parent:
- 65:d91e1d63153d
- Child:
- 69:4305ac772a66
diff -r cc7069bc0ead -r d36977cbfe90 common/utils.c --- a/common/utils.c Tue Apr 14 11:43:05 2020 +0000 +++ b/common/utils.c Mon Apr 20 05:40:18 2020 +0000 @@ -48,7 +48,7 @@ ADMW_STATUS *pStatus) { ADMW_LOG_INFO("Status Summary:"); - + if (pStatus->deviceStatus == 0) { ADMW_LOG_INFO("\tNo errors detected"); } else { @@ -60,22 +60,19 @@ ADMW_LOG_INFO("\tActive Errors - RESET REQUIRED"); if (pStatus->deviceStatus & ADMW_DEVICE_STATUS_FIFO_ERROR) ADMW_LOG_INFO("\tActive FIFO Errors - ATTENTION REQUIRED"); + ADMW_LOG_INFO("\tFIFO buffer full"); + ADMW_LOG_INFO("\tExceeding measurements per cycle limit of %d",MAXIMUM_MEASUREMENTS_PER_CYCLE); if (pStatus->deviceStatus & ADMW_DEVICE_STATUS_CONFIG_ERROR) ADMW_LOG_INFO("\tActive Configuration Errors - ATTENTION REQUIRED"); if (pStatus->deviceStatus & ADMW_DEVICE_STATUS_ALERT) { ADMW_LOG_INFO("\tActive Alerts - ATTENTION REQUIRED:"); - ADMW_LOG_INFO("\t\tLast Alert Code: %u (0x%X)", - pStatus->alertCode, pStatus->alertCode); for (unsigned i = 0; i < ADMW1001_MAX_CHANNELS; i++) { if (pStatus->channelAlerts[i] == 0) continue; ADMW_LOG_INFO("\t\tChannel #%u:", i); - ADMW_LOG_INFO("\t\t\tLast Alert Code: %u (0x%X)", - pStatus->channelAlertCodes[i], - pStatus->channelAlertCodes[i]); if (pStatus->channelAlerts[i] & ADMW_ALERT_DETAIL_CH_ADC_NEAR_OVERRANGE) ADMW_LOG_INFO("\t\t\ADC near overrange detected"); if (pStatus->channelAlerts[i] & ADMW_ALERT_DETAIL_CH_SENSOR_UNDERRANGE) @@ -92,13 +89,6 @@ ADMW_LOG_INFO("\t\t\tChannel sensor hardfault alert detected"); } } - - if ((pStatus->deviceStatus & ADMW_DEVICE_STATUS_ERROR) || - (pStatus->deviceStatus & ADMW_DEVICE_STATUS_ALERT)) { - ADMW_LOG_INFO("\t\tLast Debug Code: %u-%u", - (pStatus->debugCode >> 16) & 0xFFFF, - (pStatus->debugCode >> 0) & 0xFFFF); - } } } @@ -264,12 +254,19 @@ uint32_t nSampleCount = 0; uint32_t nReturned; while (true) { - ADMW_STATUS status; + ADMW_STATUS status; /* * Wait until the next batch of 1 or more samples is ready, continuously * checking DATAREADY until it is asserted */ + //Checking the status of the device before capturing the data + res = admw_GetStatus(hDevice, &status); + if (res != ADMW_SUCCESS) + { + ADMW_LOG_ERROR("Failed to retrieve device status"); + } + utils_printStatus(&status); while (! (bDataReady || bError)); if (!bError) {