diff options
author | Robert Gustafsson <robg@student.chalmers.se> | 2017-10-04 20:19:16 +0200 |
---|---|---|
committer | Andreas Lindhé <andreas@lindhe.io> | 2017-10-09 12:14:35 +0200 |
commit | c0c910535b03a7565dd57e2f8dddecf0ad6714df (patch) | |
tree | f36f5415cd56ac0ce6576beba8b3371a309ad90c /broccoli/src | |
parent | 4eb7dc8cc602a2c38c27eb6700fcb3ea79951c20 (diff) | |
download | midbro-c0c910535b03a7565dd57e2f8dddecf0ad6714df.tar.gz midbro-c0c910535b03a7565dd57e2f8dddecf0ad6714df.tar.bz2 |
Add function to release sensor values
Diffstat (limited to 'broccoli/src')
-rw-r--r-- | broccoli/src/midbropasad.c | 22 |
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; |