| | |
| | | } |
| | | } |
| | | extern uint8_t bind_flag; |
| | | extern uint32_t dev_id; |
| | | uint16_t temp_id; |
| | | |
| | | |
| | | |
| | | void Usart0ParseDataHandler(uint8_t data) |
| | | { |
| | | if(state5V_prase_flag&&!g_com_map[MODBUS_MODE]) |
| | |
| | | uint16_t checksum = 0; |
| | | static uint8_t pack_datalen = 0,pack_length = 0,pack_index = 0,pack_msgtype = 0,pack_cmd = CMD_READ; |
| | | static uint8_t index = 0; |
| | | |
| | | if(usart_receive_state == UsartReceiveWaitChecksum) |
| | | { //若收到校验和包 |
| | | checksum = 0; |
| | |
| | | case CMD_READ: |
| | | //read包中data字节,即mUsart2ReceivePack[0]表示数据长度; |
| | | //从g_com_data结构体中的第index位置读取长度为mUsart2ReceivePack[0]的字节,发送出来 |
| | | SendComMap0(pack_datalen,pack_index>>1); |
| | | memcpy(&temp_id,&mUsart2ReceivePack[0],2); |
| | | //SendComMap0(pack_datalen,pack_index>>1); |
| | | if(memcmp(&temp_id,&dev_id,2)==0) |
| | | buffer_message_send(); |
| | | //SendComMap0(pack_datalen,pack_index>>1); |
| | | break; |
| | | default: |
| | | break; |