summaryrefslogtreecommitdiff
path: root/broccoli
diff options
context:
space:
mode:
authorRobert Gustafsson <robg@student.chalmers.se>2017-10-04 20:19:16 +0200
committerRobert Gustafsson <robg@student.chalmers.se>2017-10-04 20:19:16 +0200
commitb82bb594b7143e04ce39b84be12e001e57f17527 (patch)
tree0e02466ac12aba5811a2530ed54147dd9d3e239b /broccoli
parent6701024e285d4e64b600ab87c88eb85dd64ad336 (diff)
downloadmidbro-b82bb594b7143e04ce39b84be12e001e57f17527.tar.gz
midbro-b82bb594b7143e04ce39b84be12e001e57f17527.tar.bz2
Add function to release sensor values
Diffstat (limited to 'broccoli')
-rw-r--r--broccoli/src/midbropasad.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/broccoli/src/midbropasad.c b/broccoli/src/midbropasad.c
index 756e558..d3c6829 100644
--- a/broccoli/src/midbropasad.c
+++ b/broccoli/src/midbropasad.c
@@ -6,6 +6,24 @@
#include <broccoli.h>
#endif
+Fifo_q * q;
+
+ int *
+request_sensor_data(int number)
+{
+ int i;
+ int * arrayOfValues;
+ Sensor_t * sensor;
+ arrayOfValues = (int *) malloc(number*sizeof(int));
+ for(i=0; i<number; ++i){
+ sensor = pop_from_queue(q);
+ arrayOfValues[i] = sensor->value;
+ free(sensor);
+ }
+ printf("Release %d sensor data values\n", number);
+ return arrayOfValues;
+}
+
void
start_data_capture(Fifo_q * q)
{
@@ -23,10 +41,10 @@ main(int argc, char **argv)
{
Fifo_q * q = init_queue(50);
start_data_capture(q);
+ sleep(10);
while(true){
- printf("Main thread\n");
- sleep(10);
print_queue(q);
+ free(request_sensor_data(5));
}
free(q);
return 0;