
prueba 001
main.cpp@0:f5375e67929f, 2017-05-31 (annotated)
- Committer:
- DiegoColl
- Date:
- Wed May 31 21:26:54 2017 +0000
- Revision:
- 0:f5375e67929f
- Child:
- 1:fbf9b50fe4f0
probando
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DiegoColl | 0:f5375e67929f | 1 | #include "mbed.h" |
DiegoColl | 0:f5375e67929f | 2 | |
DiegoColl | 0:f5375e67929f | 3 | //DigitalOut myled(LED1); |
DiegoColl | 0:f5375e67929f | 4 | Serial pc(USBTX, USBRX); |
DiegoColl | 0:f5375e67929f | 5 | |
DiegoColl | 0:f5375e67929f | 6 | //char cadena[32]=""; |
DiegoColl | 0:f5375e67929f | 7 | char buffer[32]=""; |
DiegoColl | 0:f5375e67929f | 8 | //char ID[2]="C1",ST[2]="OK",OR[2]="",RP[2]="",QY[2]="",AK[2]=""; |
DiegoColl | 0:f5375e67929f | 9 | char IDs[2],STs[2],ACs[2],AKs[2]; |
DiegoColl | 0:f5375e67929f | 10 | char * pch; |
DiegoColl | 0:f5375e67929f | 11 | int i=0; |
DiegoColl | 0:f5375e67929f | 12 | |
DiegoColl | 0:f5375e67929f | 13 | void borrar_buffer(char *cadena){ |
DiegoColl | 0:f5375e67929f | 14 | for(i=0;i<31;i++){ |
DiegoColl | 0:f5375e67929f | 15 | cadena[i]=0x00; |
DiegoColl | 0:f5375e67929f | 16 | } |
DiegoColl | 0:f5375e67929f | 17 | //pc.printf("\nbuffer: %s", buffer); |
DiegoColl | 0:f5375e67929f | 18 | } |
DiegoColl | 0:f5375e67929f | 19 | |
DiegoColl | 0:f5375e67929f | 20 | void interrup(){ |
DiegoColl | 0:f5375e67929f | 21 | char c; |
DiegoColl | 0:f5375e67929f | 22 | i=0; |
DiegoColl | 0:f5375e67929f | 23 | c=pc.getc(); |
DiegoColl | 0:f5375e67929f | 24 | //pc.putc(c); |
DiegoColl | 0:f5375e67929f | 25 | if(c=='<'){ |
DiegoColl | 0:f5375e67929f | 26 | //pc.putc(c); |
DiegoColl | 0:f5375e67929f | 27 | while(c!='>'){ |
DiegoColl | 0:f5375e67929f | 28 | c=pc.getc(); |
DiegoColl | 0:f5375e67929f | 29 | if(c!='>'){ |
DiegoColl | 0:f5375e67929f | 30 | //pc.putc(c); |
DiegoColl | 0:f5375e67929f | 31 | buffer[i++]=c; |
DiegoColl | 0:f5375e67929f | 32 | } |
DiegoColl | 0:f5375e67929f | 33 | } |
DiegoColl | 0:f5375e67929f | 34 | //pc.puts(buffer); |
DiegoColl | 0:f5375e67929f | 35 | |
DiegoColl | 0:f5375e67929f | 36 | i=0; |
DiegoColl | 0:f5375e67929f | 37 | pch=strtok(buffer,";"); |
DiegoColl | 0:f5375e67929f | 38 | |
DiegoColl | 0:f5375e67929f | 39 | while(pch != NULL){ |
DiegoColl | 0:f5375e67929f | 40 | //pc.printf("\n%s",pch); |
DiegoColl | 0:f5375e67929f | 41 | |
DiegoColl | 0:f5375e67929f | 42 | pch=strtok(NULL, ";"); |
DiegoColl | 0:f5375e67929f | 43 | if(i==0) |
DiegoColl | 0:f5375e67929f | 44 | strcpy(IDs,pch); |
DiegoColl | 0:f5375e67929f | 45 | if(i==1) |
DiegoColl | 0:f5375e67929f | 46 | STs=pch; |
DiegoColl | 0:f5375e67929f | 47 | if(i==2) |
DiegoColl | 0:f5375e67929f | 48 | ACs=pch; |
DiegoColl | 0:f5375e67929f | 49 | if(i==3) |
DiegoColl | 0:f5375e67929f | 50 | AKs=pch; |
DiegoColl | 0:f5375e67929f | 51 | i++; |
DiegoColl | 0:f5375e67929f | 52 | } |
DiegoColl | 0:f5375e67929f | 53 | borrar_buffer(buffer); |
DiegoColl | 0:f5375e67929f | 54 | } |
DiegoColl | 0:f5375e67929f | 55 | } |
DiegoColl | 0:f5375e67929f | 56 | |
DiegoColl | 0:f5375e67929f | 57 | int main() { |
DiegoColl | 0:f5375e67929f | 58 | pc.printf("Inicio de programa\n"); |
DiegoColl | 0:f5375e67929f | 59 | pc.attach(&interrup); |
DiegoColl | 0:f5375e67929f | 60 | |
DiegoColl | 0:f5375e67929f | 61 | while(1){ |
DiegoColl | 0:f5375e67929f | 62 | |
DiegoColl | 0:f5375e67929f | 63 | } |
DiegoColl | 0:f5375e67929f | 64 | } |