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: mbed mbed-rtos Motor LSM9DS1_Library_cal X_NUCLEO_53L0A1
DataDistributor.cpp@10:8f4183d640d8, 2019-04-23 (annotated)
- Committer:
- abh15
- Date:
- Tue Apr 23 18:22:16 2019 +0000
- Revision:
- 10:8f4183d640d8
- Parent:
- 9:552805fac195
- Child:
- 13:c6afb59d2d3e
Added LEDs to transmit/receive functions
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| abh15 | 2:94d3f64f1297 | 1 | #include "DataDistributor.h" | 
| rpatelpj | 8:bfa4bf23522c | 2 | |
| rpatelpj | 8:bfa4bf23522c | 3 | void DataDistributor::transmitObstacles() { | 
| abh15 | 10:8f4183d640d8 | 4 | led = 0b0010; | 
| rpatelpj | 8:bfa4bf23522c | 5 | while(!pb); | 
| abh15 | 9:552805fac195 | 6 | wait(1); | 
| abh15 | 9:552805fac195 | 7 | |
| abh15 | 9:552805fac195 | 8 | bool sentData = false; | 
| abh15 | 9:552805fac195 | 9 | while(!sentData) { | 
| abh15 | 9:552805fac195 | 10 | if(pc.writeable()) { | 
| abh15 | 9:552805fac195 | 11 | pc.putc('s'); | 
| abh15 | 9:552805fac195 | 12 | for(int i = 0; i < 360; i++) { | 
| abh15 | 9:552805fac195 | 13 | pc.putc(obstacles[i]); | 
| abh15 | 9:552805fac195 | 14 | wait(0.1); | 
| abh15 | 9:552805fac195 | 15 | } | 
| abh15 | 9:552805fac195 | 16 | sentData = true; | 
| abh15 | 9:552805fac195 | 17 | } | 
| abh15 | 9:552805fac195 | 18 | } | 
| abh15 | 10:8f4183d640d8 | 19 | led = 0b0000; | 
| abh15 | 2:94d3f64f1297 | 20 | } | 
| abh15 | 2:94d3f64f1297 | 21 | |
| rpatelpj | 8:bfa4bf23522c | 22 | void DataDistributor::receiveTrajectory() { | 
| abh15 | 10:8f4183d640d8 | 23 | led = 0b0100; | 
| abh15 | 9:552805fac195 | 24 | while(pc.getc() != 's'); | 
| abh15 | 9:552805fac195 | 25 | wait(0.1); | 
| rpatelpj | 8:bfa4bf23522c | 26 | trajectoryLength = pc.getc(); | 
| abh15 | 9:552805fac195 | 27 | wait(0.1); | 
| abh15 | 9:552805fac195 | 28 | trajectory = new int[trajectoryLength]; | 
| rpatelpj | 8:bfa4bf23522c | 29 | |
| abh15 | 9:552805fac195 | 30 | bool readData = false; | 
| abh15 | 9:552805fac195 | 31 | while(!readData) { | 
| abh15 | 9:552805fac195 | 32 | if(pc.readable()) { | 
| abh15 | 9:552805fac195 | 33 | for(int i = 0; i < trajectoryLength; i++) { | 
| abh15 | 9:552805fac195 | 34 | trajectory[i] = pc.getc(); | 
| abh15 | 9:552805fac195 | 35 | wait(0.1); | 
| abh15 | 9:552805fac195 | 36 | } | 
| abh15 | 9:552805fac195 | 37 | readData = true; | 
| abh15 | 9:552805fac195 | 38 | } | 
| abh15 | 9:552805fac195 | 39 | } | 
| abh15 | 10:8f4183d640d8 | 40 | led = 0b0000; | 
| abh15 | 2:94d3f64f1297 | 41 | } | 
