Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: common/utils.c
- Revision:
- 73:cae0c514bea6
- Parent:
- 71:7b5ebd969aa7
- Child:
- 74:27a28f452d71
--- a/common/utils.c Fri Apr 24 06:37:01 2020 +0000
+++ b/common/utils.c Fri Apr 24 11:51:13 2020 +0000
@@ -43,6 +43,27 @@
#include "utils.h"
#include "admw_log.h"
+#include "admw_spi.h"
+#include "admw1001/admw1001_api.h"
+#include "inc/nucleo_io.h"
+#include <stdio.h>
+
+void utils_runMeasurementsFromSerialPing(ADMW_DEVICE_HANDLE hDevice, ADMW_MEASUREMENT_MODE eMeasurementMode)
+{
+ int i_serialCheck = 0;
+ ADMW_RESULT result = ADMW_IN_USE;
+ while(true)
+ {
+ i_serialCheck = 0;
+ i_serialCheck = nucleo_in();
+
+ if(i_serialCheck == '=')
+ {
+ result = utils_runMeasurement(hDevice, eMeasurementMode);
+ i_serialCheck = 0;
+ }
+ }
+}
void utils_printStatus(
ADMW_STATUS *pStatus)
@@ -100,13 +121,30 @@
}
}
-void utils_printSamples(
- ADMW_DATA_SAMPLE *pSampleBuffer,
- uint32_t nNumSamples,
- ADMW_MEASUREMENT_MODE eMeasurementMode)
+char *rtrim(char *str, const char *seps)
+
+
+
{
+ int i;
+ if (seps == NULL) {
+ seps = "\t\n\v\f\r ";
+ }
+ i = strlen(str) - 1;
+ while (i >= 0 && strchr(seps, str[i]) != NULL) {
+ str[i] = '\0';
+ i--;
+ }
+ return str;
+}
+
+void utils_printSamples( ADMW_DATA_SAMPLE *pSampleBuffer, uint32_t nNumSamples, ADMW_MEASUREMENT_MODE eMeasurementMode)
+{
+ char *strbuilder = (char *)malloc((1000)*sizeof(char));
+ strbuilder[0] = '\0';
for (uint32_t i = 0; i < nNumSamples; i++) {
- ADMW_LOG_INFO("Sample # %2d Channel_ID # %2d :: Raw_Sample %f :: processedValue %f :: flags: ERROR:%X , ALERT:%X",
+ int str_length = strlen(strbuilder);
+ sprintf(strbuilder+str_length, "Sample#%2dChannel#%2d:Raw%f:Processed%f:flags:%s%s\r\n",
i+1,
pSampleBuffer[i].Channel_ID,
pSampleBuffer[i].Raw_Sample,
@@ -114,8 +152,13 @@
pSampleBuffer[i].Ch_Error,
pSampleBuffer[i].Ch_Alert);
}
+ rtrim(strbuilder, NULL/* */);
+ NUCLEO_OUT("%s", strbuilder);
+
+ free(strbuilder);
}
+
static void gpioCallbackFn(ADMW_GPIO_PIN ePinId, void * pArg)
{
volatile bool *pbFlag = (volatile bool *)pArg;