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.
Dependencies: X_NUCLEO_IKS01A1-f255a2c75ecb mbed-rtos mbed
Diff: sensor.cpp
- Revision:
- 33:2ee6fbdad7b4
- Parent:
- 32:e4cd87b7064c
- Child:
- 34:0d51133891d0
- Child:
- 35:34bbca276f99
diff -r e4cd87b7064c -r 2ee6fbdad7b4 sensor.cpp
--- a/sensor.cpp Wed May 18 01:28:46 2016 +0000
+++ b/sensor.cpp Wed May 18 02:30:17 2016 +0000
@@ -16,24 +16,13 @@
{
if(flag) printf("\nAbout to alloc\n");
log_data *log_d;
-/*
+
if (log_d == NULL) {
- mail_box.get(5000);
+ queue.get();
if(flag) printf("Out of memory, last sample deleted\n");
- log_data* log_d = (log_data*)mail_box.alloc(5000);
+ log_data* log_d;
if(flag) printf("Allocated after out of memory\n");
}
-*/
-
- if(v.size() >= 4){
- printf("Vector size: %d", v.size());
- osEvent evt = queue.get();
- if(evt.status == osEventMessage){
- log_data *message = (log_data*)evt.value.p;
- printf("Pressure: %f", message->pressure);
- printf("Temperature: %f", message->tempCelsius);
- }
- }
if(flag) printf("Not null, reading values\n");
@@ -50,28 +39,20 @@
//Send pointer to sample to the queue
queue.put(log_d);
- v.push_back(*log_d);
+ //v.push_back(*log_d);
printf("After vector");
- /*
- if(flag) printf("Log added to maibox\n");
- // Check for resource error
- if (stat == osErrorResource) {
- if(flag) printf("mail_box->put() Error %4Xh\n", stat);
- //Error, free up memory block taken
- mail_box.free(log_d);
- }
- */
+
}
// This is the consumer
-/*
+
void ExpansionBoard::getData(const void*)
{
while(true) {
//Block on queue if no data is available
- osEvent event = mail_box.get();
+ osEvent event = queue.get(2000);
if(flag) {
printf("MAIL_BOX.GET\n");
}
@@ -79,15 +60,14 @@
if (event.status == osEventMail) {
// Successful, store log_data
log_data* temp = (log_data*) event.value.p;
- v->push_back(*temp);
- mail_box.free(temp);
+ v.push_back(*temp);
if(flag) {
printf("GET value stored and freed up mail_box\n");
}
}
}
}
-*/
+
// Helper function for printing floats & doubles
char *ExpansionBoard::printDouble(char* str, double v, int decimalDigits)
