![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
Receiver.cpp@6:9903a0906a72, 2018-03-28 (annotated)
- Committer:
- KlaasGovaerts
- Date:
- Wed Mar 28 14:19:06 2018 +0000
- Revision:
- 6:9903a0906a72
- Parent:
- 5:0413d42377d1
- Child:
- 16:ffd311730575
Versie 28/03
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KlaasGovaerts | 4:0d013b7e4dea | 1 | #include "Receiver.h" |
KlaasGovaerts | 4:0d013b7e4dea | 2 | |
KlaasGovaerts | 4:0d013b7e4dea | 3 | Receiver::Receiver(int* LEDinput,Mutex* lockinput){ |
KlaasGovaerts | 4:0d013b7e4dea | 4 | LED=LEDinput; |
KlaasGovaerts | 4:0d013b7e4dea | 5 | lock=lockinput; |
KlaasGovaerts | 4:0d013b7e4dea | 6 | |
KlaasGovaerts | 4:0d013b7e4dea | 7 | } |
KlaasGovaerts | 4:0d013b7e4dea | 8 | |
KlaasGovaerts | 5:0413d42377d1 | 9 | void Receiver::init(){ |
KlaasGovaerts | 4:0d013b7e4dea | 10 | char command[512]; |
KlaasGovaerts | 5:0413d42377d1 | 11 | listener.receivePacket(command,sizeof(command)); |
KlaasGovaerts | 4:0d013b7e4dea | 12 | char *ID=strtok(command,","); |
KlaasGovaerts | 4:0d013b7e4dea | 13 | char *direction=strtok(NULL," "); |
KlaasGovaerts | 4:0d013b7e4dea | 14 | while((ID!=NULL)&&(direction!=NULL)){ |
KlaasGovaerts | 4:0d013b7e4dea | 15 | int IDNumber=atoi(ID); |
KlaasGovaerts | 4:0d013b7e4dea | 16 | int directionNumber=directionToNumber(direction); |
KlaasGovaerts | 5:0413d42377d1 | 17 | if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=-1)&&(directionNumber<=3)){ |
KlaasGovaerts | 6:9903a0906a72 | 18 | lock->lock(); |
KlaasGovaerts | 5:0413d42377d1 | 19 | LED[IDNumber]=directionNumber; |
KlaasGovaerts | 6:9903a0906a72 | 20 | lock->unlock(); |
KlaasGovaerts | 4:0d013b7e4dea | 21 | } |
KlaasGovaerts | 5:0413d42377d1 | 22 | ID=strtok(NULL,","); |
KlaasGovaerts | 5:0413d42377d1 | 23 | direction=strtok(NULL," "); |
KlaasGovaerts | 4:0d013b7e4dea | 24 | } |
KlaasGovaerts | 4:0d013b7e4dea | 25 | } |
KlaasGovaerts | 4:0d013b7e4dea | 26 | |
KlaasGovaerts | 4:0d013b7e4dea | 27 | int Receiver::directionToNumber(char* direction){ |
KlaasGovaerts | 4:0d013b7e4dea | 28 | if(strcmp(direction,"links")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 29 | return 0; |
KlaasGovaerts | 4:0d013b7e4dea | 30 | else if(strcmp(direction,"rechts")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 31 | return 1; |
KlaasGovaerts | 4:0d013b7e4dea | 32 | else if(strcmp(direction,"boven")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 33 | return 2; |
KlaasGovaerts | 4:0d013b7e4dea | 34 | else if(strcmp(direction,"onder")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 35 | return 3; |
KlaasGovaerts | 4:0d013b7e4dea | 36 | else |
KlaasGovaerts | 4:0d013b7e4dea | 37 | return -1; |
KlaasGovaerts | 5:0413d42377d1 | 38 | } |