| | |
| | | return ; |
| | | |
| | | dma_recv_cnt = dma_mar_reg_read - (uint32)up_comm_recv_buff; |
| | | if(dma_recv_cnt) |
| | | if( (dma_recv_cnt>0)&&(dma_recv_cnt <= UP_COMM_RECV_BUFF_LEN_MAX)) |
| | | { |
| | | if((dma_recv_cnt >= UP_COMM_RECV_BUFF_LEN_MAX) || (dma_recv_cnt >= UC_RECV_LEN_MAX) ) |
| | | return; |
| | | |
| | | uc_recv_para_p->uc_recv_length = dma_recv_cnt; |
| | | arrayA_2_arrayB(up_comm_recv_buff , uc_recv_para_p->uc_recv_buf_union.uc_recv_buf, dma_recv_cnt, LITTLE_ENDIAN) ; |
| | | uc_recv_para_p->uc_recv_flag = SET;//½ÓÊÕÍê³É |
| | |
| | | uc_respond_data_p->uc_recv_buf[crc_len] = send_crc_check >> 8; //¸ßλ |
| | | uc_respond_data_p->uc_recv_buf[crc_len + 1] = send_crc_check &0xff; |
| | | |
| | | UP_COMM_RE_SEND_EN; |
| | | UC_SEND_NORMAL((uint8_t *)uc_respond_data_p,crc_len + 2); |
| | | UP_COMM_RE_RECV_EN; |
| | | } |
| | | |
| | | |
| | |
| | | void upperComPro(void) |
| | | { |
| | | //½ÓÊÕÊý¾ÝÅÐ¶Ï |
| | | up_comm_RX_DMA_check(&uc_recv_para_g); |
| | | if(__SYS_STATUS_BYTES_GET(power_state) == SET){ |
| | | up_comm_RX_DMA_check(&uc_recv_para_g); //Í⹩µçϲŴ¦Àí½ÓÊÕ |
| | | } |
| | | |
| | | /*Ö¡¸ñʽ½âÎöÅжϣ¬´Ë´¦¼æÈÝmodbusÐÒ飬µÚÒ»¸ö×Ö½ÚÈç¹ûÊÇ0x68´ú±íÉÏλ»úÐÒ飬·Ç0x68ÔÙ½øÈëmodbus´¦Àí*/ |
| | | if ((uc_recv_para_g.uc_recv_flag ==SET)&&(uc_recv_para_g.uc_recv_length > UC_PROTOCOL_HEAD_LENGTH )&&(uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.frame_start_code == UC_FRAME_HEAD_CODE)) |
| | |
| | | if (uc_login_state_g == UC_OK && local_random_code_g == uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.random_number) |
| | | { |
| | | Upper_ComputerReadWriteHandler(&uc_recv_para_g.uc_recv_buf_union,&uc_respond_data_g); |
| | | Upper_ComputerLoginRespond(&uc_respond_data_g); |
| | | Upper_ComputerRespond(&uc_respond_data_g); |
| | | __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä |
| | | } |
| | | break; |
| | |
| | | if (uc_login_state_g == UC_OK && local_random_code_g == uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.random_number) |
| | | { |
| | | Upper_ComputerReadWriteHandler(&uc_recv_para_g.uc_recv_buf_union,&uc_respond_data_g); |
| | | Upper_ComputerLoginRespond(&uc_respond_data_g); |
| | | Upper_ComputerRespond(&uc_respond_data_g); |
| | | __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä |
| | | } |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | //ÉÏλ»ú³¬Ê±´¦Àí£¬µ±³¤Ê±¼äûÓн»»¥Ê±£¬Ëæ»úÂëʧЧ£¬ÐèÒªÖØÐµÇÈë²ÅÄܼÌÐøÊ¹Óà |
| | | if(__SYS_DELAY_SEC_FLAG_GET(UC_active_time) == SET){ |
| | | __SYS_DELAY_SEC_FLAG_CLEAR_(UC_active_time); |
| | | |
| | | local_random_code_g = 0; |
| | | } |
| | | |
| | | |
| | | //½øÈëmodbus´¦Àí |
| | | if ((uc_recv_para_g.uc_recv_flag ==SET)&&(uc_recv_para_g.uc_recv_length > 7 )&&(uc_recv_para_g.uc_recv_buf_union.uc_recv_buf[0] != UC_FRAME_HEAD_CODE)) |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |