| | |
| | | #include <stdio.h> |
| | | #include "beep.h" |
| | | #include "modbus.h" |
| | | |
| | | #include "CRC.h" |
| | | /*------------------------------------ Marcos ------------------------------------------*/ |
| | | /* Inter-ranging delay period, in milliseconds. */ |
| | | #define RNG_DELAY_MS 100 |
| | |
| | | uint16_t rec_ancpos; |
| | | uint8_t dist_noutenough_count; |
| | | uint8_t ancdist_hist[11]; |
| | | |
| | | uint16_t calCRC; |
| | | void NearPoll(void) |
| | | { |
| | | |
| | |
| | | } |
| | | |
| | | if(para_update) |
| | | { |
| | | |
| | | pack_msgtype = rec_remotepara[0]; |
| | | pack_index = rec_remotepara[1]; |
| | | pack_length = rec_remotepara[2]; |
| | | if(pack_msgtype==2) |
| | | { |
| | | if( pack_index == MOTOR_ONTIME_INDEX) |
| | | { |
| | | // if(motor_keeptime==0) |
| | | motor_keeptime = rec_remotepara[3]; |
| | | }else{ |
| | | if(pack_index<200) |
| | | { |
| | | |
| | | calCRC = CRC_Compute(rec_remotepara,5); |
| | | if(memcmp(&calCRC,&rec_remotepara[5],2)==0) |
| | | { |
| | | pack_msgtype = rec_remotepara[0]; |
| | | pack_index = rec_remotepara[1]; |
| | | pack_length = rec_remotepara[2]; |
| | | if(pack_msgtype==2) |
| | | { |
| | | if( pack_index == MOTOR_ONTIME_INDEX) |
| | | { |
| | | memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length); |
| | | //返回一个error状态 |
| | | //SendComMap(pack_datalen,pack_index); |
| | | save_com_map_to_flash(); |
| | | delay_ms(100); |
| | | NVIC_SystemReset(); |
| | | // if(motor_keeptime==0) |
| | | motor_keeptime = rec_remotepara[3]; |
| | | }else{ |
| | | if(pack_index<200) |
| | | { |
| | | memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length); |
| | | //返回一个error状态 |
| | | //SendComMap(pack_datalen,pack_index); |
| | | save_com_map_to_flash(); |
| | | delay_ms(100); |
| | | NVIC_SystemReset(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(get_newdist>=2) |
| | | { |