| | |
| | | #include "uart.h" |
| | | #include "upper_com_data_pro.h" |
| | | #include "mb.h" |
| | | #include "upper_com_iap_pro.h" |
| | | |
| | | UC_RECV_PARA_T __attribute__ ((aligned (4))) uc_recv_para_g = {.uc_recv_flag = RESET}; |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | uint8_t *data_p; |
| | | if (uc_login_state_g == UC_OK && local_random_code_g == uc_recv_data_union_p->uc_protocol_head_s.random_number) |
| | | { |
| | | uc_respond_data_p->uc_protocol_head_s.data_table_id = uc_recv_data_union_p->uc_protocol_head_s.data_table_id; |
| | | data_category_ID= BSWAP_16(uc_recv_data_union_p->uc_protocol_head_s.data_table_id); |
| | | data_p = uc_recv_data_union_p->uc_recv_buf + UC_PROTOCOL_HEAD_LENGTH +sizeof (uc_recv_data_union_p->uc_protocol_head_s.data_table_id); |
| | | switch(data_category_ID)//?ÐèÒªÍêÉÆ |
| | |
| | | // case SYSTEM_FUNCTION_CTRL_WORD_ID : COM_system_function_ctrl_word_inf_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | // case SYSTEM_ALARM_CTRL_WORD_ID : COM_system_alarm_ctrl_word_inf_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | // case SYSTEM_ALARM_REPORT_CTRL_WORD_ID : COM_system_alarm_report_ctrl_word_inf_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | // case DEVICE_REAL_TIME_ID : COM_time_set_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | case DEVICE_REAL_TIME_ID : COM_time_set_handle(uc_recv_data_union_p->uc_protocol_head_s.cmd_code,data_category_ID,data_p,uc_respond_data_p) ;break; |
| | | // case DEBUG_STATE_SET_ID : COM_debug_state_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | // case DEBUG_PARA_SET_ID : COM_debug_para_set_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | | // case ORIGINAL_WAVEFORM_DATA_READ_ID : COM_original_para_set_handle(WriteOrRead, com_frame_receive_inf_in.data_category_ID,(DataPtr +2)) ;break; |
| | |
| | | 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; |
| | |
| | | // { |
| | | // uc_rw_result_g = Upper_ComputerLogProcess(Upper_ComputerPermissionsGet(uc_rec_para_p->uc_recv_buf_union.uc_recv_buf[2]), |
| | | // &uc_rec_para_p->uc_recv_buf_union.uc_recv_buf[UC_PROTOCOL_HEAD_LENGTH], |
| | | // &uc_temp_result_buffer[0][UC_PROTOCOL_HEAD_LENGTH + UC_DATA_TABLE_BYTES_LENGTH + UC_LOG_NUM_AND_FLAG_LENGTH]); |
| | | // &uc_temp_result_buffer[0][UC_PROTOCOL_HEAD_LENGTH + UC_PROTOCOL_TABLE_ID_LENGTH + UC_LOG_NUM_AND_FLAG_LENGTH]); |
| | | // __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä |
| | | // } |
| | | break; |
| | | case UC_CMD_IAP://? |
| | | // uc_rw_result_g = Upper_ComputerIapProcess(uc_table_id, &uc_rec_para_p->uc_recv_buf_union.uc_recv_buf[UC_PROTOCOL_HEAD_LENGTH + UC_DATA_TABLE_BYTES_LENGTH]); |
| | | // __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä |
| | | Upper_ComputerIapHandler(&uc_recv_para_g.uc_recv_buf_union,&uc_respond_data_g); |
| | | Upper_ComputerRespond(&uc_respond_data_g); |
| | | __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | //ÉÏλ»ú³¬Ê±´¦Àí£¬µ±³¤Ê±¼äûÓн»»¥Ê±£¬Ëæ»úÂëʧЧ£¬ÐèÒªÖØÐµÇÈë²ÅÄܼÌÐøÊ¹Óà |
| | | if(__SYS_DELAY_SEC_FLAG_GET(UC_active_time) == SET){ |
| | | __SYS_DELAY_SEC_FLAG_CLEAR_(UC_active_time); |
| | | |
| | | local_random_code_g = 0; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |