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.
Diff: main.cpp
- Revision:
- 3:35151308f847
- Parent:
- 1:6f8bf5bdc70f
- Child:
- 4:4051a72a22f7
diff -r 6f8bf5bdc70f -r 35151308f847 main.cpp --- a/main.cpp Wed May 17 10:12:31 2017 +0000 +++ b/main.cpp Tue May 23 07:57:18 2017 +0000 @@ -9,6 +9,7 @@ Thread threadA; Thread threadB; +Thread threadC; CAN CanPort(p30, p29); @@ -16,7 +17,6 @@ CANMessage MessageTx; unsigned int Id; - void canReader(void) { @@ -25,22 +25,60 @@ if (CanPort.read(MessageRx)) { led1 = !led1; - threadA.signal_set(SIG_RX_CAN); + switch(MessageRx.id){ + case 0x111 : + threadA.signal_set(SIG_RX_CAN); + break; + + case 0x221 : + threadC.signal_set(SIG_RX_CAN); + break; + + case 0x222 : + threadC.signal_set(SIG_RX_CAN); + break; + + case 0x333 : + + break; + default: + printf("Id error = %X\n\r",MessageRx.id) ; + } + } } - -void thA() + void traitRFID() { + int i=0; + while(true) { Thread::signal_wait(SIG_RX_CAN); led2 = !led2; - printf("RX FRAME ID = %X\n\r",MessageRx.id); + for(i=0; i<8;i++){ + printf("Numero de carte = %X\n\r",MessageRx.data[i]); + } } } + +void thA() +{ + int i=0; + while(true) + { + Thread::signal_wait(SIG_RX_CAN); + led2 = !led2; + if(MessageRx.data[0]==0x01){ + printf("RX ID = %X \t\n\r",MessageRx.id); + for (i=0;i<8;i++){ + printf(" DATA = %X \n\r",MessageRx.data[i]); + } + } + } +} void thB() { @@ -79,8 +117,10 @@ threadA.start(thA); threadB.start(thB); + threadC.start(traitRFID); led1 = 0; + led2 =0 ; printf("Start OK\n\r"); LocalFileSystem local("local"); FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing