中継機能つけた受け取りオムニ
Dependencies: mbed MultiSerial
Diff: main.cpp
- Revision:
- 33:9c98ab97084e
- Parent:
- 30:00277f63ffeb
- Child:
- 34:aa464f72d111
--- a/main.cpp Tue Oct 07 10:09:54 2014 +0000 +++ b/main.cpp Sat Oct 11 05:05:12 2014 +0000 @@ -53,7 +53,7 @@ } xbee_packet; -xbee_packet packet; +xbee_packet packet = {0}; uint8_t get_data[DATA_NUM]= {0}; uint8_t check_data[2]= {0}; @@ -68,7 +68,7 @@ case 0: //err check check = 0xA; wait(0.5); - check != 0xF; + check = 0x5; wait(0.5); break; @@ -105,7 +105,6 @@ } } - int main() { @@ -118,8 +117,9 @@ xbee_packet *pt_packet=&packet; //connect_check(); - int radio_check=0; - + int abs_count=0; + int radio_count=0; + xbee.start_read(); xbee.read_data(get_data,XBEE_KEY); @@ -128,36 +128,48 @@ display_LED(1); - int counter=0; + //int counter=0; + + // int pwm_check=0; for(;;) { - wait_ms(0.5); + //wait_ms(0.5); //memcpy(&packet, get_data, DATA_NUM); packet.arm[0] = get_data[1]; packet.leg = get_data[0]; - //check = get_data[1]; - counter++; - check = counter/1000; - if(counter>=15*100) { - counter=0; - } - + abs_count++; if(xbee.readable_check() == 0) { - - radio_check++; - - if(radio_check>=500) { - safety_mode(); + + radio_count++; + + } + + if(abs_count>=10){ + abs_count=0; + + if(radio_count>=5){ + + motors = 0; + + pwm[0] = 0; + pwm[1] = 0; + pwm[2] = 0; + pwm[3] = 0; + + check =0x3; + + packet.arm[0] = 0; //できれば構造体を直接初期化 + packet.leg = 0; + } - - } else { - - radio_check = 0; - } + + radio_count=0; + + } /* Stop */ if(packet.leg==0x0) {