sertwer

Dependencies:   mbed

main.cpp

Committer:
Sergeev
Date:
2014-12-09
Revision:
0:a2f2d5b2bb5e

File content as of revision 0:a2f2d5b2bb5e:

#include "mbed.h"              
 
Serial pc(USBTX, USBRX);
 
DigitalOut pc_activity(LED1);
DigitalOut uart_activity(LED2);
 
int state = 0;
    
int main() {

    
    // set pc baud 115200
    pc.baud(115200);
    
   
    int packet_state = 0;  // STATE OF PACKET, ZERO = WAIT FOR 'snp'
     
    while(packet_state == 0) {
         //  pc.putc(uart.getc()); // Serial pass thru
     
      
      // READ 'snp' (START NEW PACKET) FROM UM6 AHRS
      
           if (pc.getc() == 0x73 ) {  
            // pc.putc(0x73);
             pc.putc('s');
             state = 1; 
          }
           
           if (pc.getc() == 0x6E ) {  
             // pc.putc(0x6E);
              pc.putc('n');
             state ++; 
             // uart_activity = !uart_activity;
          }
          
          
           if (pc.getc() == 0x70 ) {  
            // pc.putc(0x70);
             pc.putc('p');
             state ++; 
            //  uart_activity = !uart_activity;
          }
          
          
          // PT (packet type)
          if (pc.getc() == 0xC8 ) {
          state = 0;
          pc.putc('P');
          pc.putc('T');
          state ++;
          }
         
    }
}