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:
- 1:a770d742e28a
- Parent:
- 0:253a9226eb5b
- Child:
- 2:153ec87771a0
--- a/main.cpp Wed May 28 03:46:38 2014 +0000 +++ b/main.cpp Wed May 28 05:27:51 2014 +0000 @@ -1,6 +1,8 @@ #include "mbed.h" #include <fstream> +#define PACKET_COUNT 4 + Serial pc(USBTX, USBRX); // tx, rx DigitalOut myled1(LED1); DigitalOut myled2(LED2); @@ -12,24 +14,38 @@ int main() { + myled4 = 1; + int index = 0; + int num_packets = 0; + FILE *fp = fopen("/local/packet.txt", "w"); - for(; index < 10; index++){ - read_buffer[0][index] = pc.getc(); - fprintf(fp,"%d",read_buffer[0][index]); - fprintf(fp,"."); - - if(index%2 == 0){ - myled1 =1; - myled2 = 0; - } - else{ - myled1 =0; - myled2 = 1; - } + + +for(; num_packets < PACKET_COUNT; num_packets++){ + + for(; index < 19; index++){ + read_buffer[num_packets][index] = pc.getc() - 48; + fprintf(fp,"%d",read_buffer[num_packets][index]); + if(index == 1) + fprintf(fp,"."); + if(index == 5) + fprintf(fp,"."); + if(index == 9) + fprintf(fp,"."); + if(index == 16) + fprintf(fp,"."); + if(index == 18) + fprintf(fp,"."); + + } + index = 0; + fprintf(fp,"\n"); + } + fclose(fp); myled1 = 1;