![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
First version
Dependencies: mbed EthernetInterface mbed-rto
Diff: Receiver.cpp
- Revision:
- 4:0413d42377d1
- Parent:
- 3:0d013b7e4dea
- Child:
- 5:9903a0906a72
--- a/Receiver.cpp Wed Mar 28 12:25:14 2018 +0000 +++ b/Receiver.cpp Wed Mar 28 13:28:14 2018 +0000 @@ -6,33 +6,22 @@ } -void Receiver::run(){ - //Recieve Packet. +void Receiver::init(){ char command[512]; - - bool inCommand=true; - - + listener.receivePacket(command,sizeof(command)); char *ID=strtok(command,","); char *direction=strtok(NULL," "); while((ID!=NULL)&&(direction!=NULL)){ - - - if(){ - - } else { - - } - - int IDNumber=atoi(ID); int directionNumber=directionToNumber(direction); - if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=0)&&(directionNumber<=3)){ - LED[IDNumber]= + if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=-1)&&(directionNumber<=3)){ + lock.lock(); + LED[IDNumber]=directionNumber; + lock.unlock(); } - inCommand=false; + ID=strtok(NULL,","); + direction=strtok(NULL," "); } - } int Receiver::directionToNumber(char* direction){ @@ -46,12 +35,4 @@ return 3; else return -1; -} - - -/* -in - -int Receiver::directionToNumber(char *direction){ - -}*/ \ No newline at end of file +} \ No newline at end of file