![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
Receiver.cpp@16:ffd311730575, 2018-04-18 (annotated)
- Committer:
- KlaasGovaerts
- Date:
- Wed Apr 18 09:17:14 2018 +0000
- Revision:
- 16:ffd311730575
- Parent:
- 6:9903a0906a72
- Child:
- 17:04fb7968592a
Versie 18/04 (4)
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 | 16:ffd311730575 | 9 | void Receiver::executeCommand(char* command){ |
KlaasGovaerts | 4:0d013b7e4dea | 10 | char *ID=strtok(command,","); |
KlaasGovaerts | 4:0d013b7e4dea | 11 | char *direction=strtok(NULL," "); |
KlaasGovaerts | 4:0d013b7e4dea | 12 | while((ID!=NULL)&&(direction!=NULL)){ |
KlaasGovaerts | 4:0d013b7e4dea | 13 | int IDNumber=atoi(ID); |
KlaasGovaerts | 4:0d013b7e4dea | 14 | int directionNumber=directionToNumber(direction); |
KlaasGovaerts | 5:0413d42377d1 | 15 | if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=-1)&&(directionNumber<=3)){ |
KlaasGovaerts | 6:9903a0906a72 | 16 | lock->lock(); |
KlaasGovaerts | 5:0413d42377d1 | 17 | LED[IDNumber]=directionNumber; |
KlaasGovaerts | 6:9903a0906a72 | 18 | lock->unlock(); |
KlaasGovaerts | 4:0d013b7e4dea | 19 | } |
KlaasGovaerts | 5:0413d42377d1 | 20 | ID=strtok(NULL,","); |
KlaasGovaerts | 5:0413d42377d1 | 21 | direction=strtok(NULL," "); |
KlaasGovaerts | 4:0d013b7e4dea | 22 | } |
KlaasGovaerts | 4:0d013b7e4dea | 23 | } |
KlaasGovaerts | 4:0d013b7e4dea | 24 | |
KlaasGovaerts | 4:0d013b7e4dea | 25 | int Receiver::directionToNumber(char* direction){ |
KlaasGovaerts | 4:0d013b7e4dea | 26 | if(strcmp(direction,"links")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 27 | return 0; |
KlaasGovaerts | 4:0d013b7e4dea | 28 | else if(strcmp(direction,"rechts")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 29 | return 1; |
KlaasGovaerts | 4:0d013b7e4dea | 30 | else if(strcmp(direction,"boven")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 31 | return 2; |
KlaasGovaerts | 4:0d013b7e4dea | 32 | else if(strcmp(direction,"onder")==0) |
KlaasGovaerts | 4:0d013b7e4dea | 33 | return 3; |
KlaasGovaerts | 4:0d013b7e4dea | 34 | else |
KlaasGovaerts | 4:0d013b7e4dea | 35 | return -1; |
KlaasGovaerts | 5:0413d42377d1 | 36 | } |