From cf4d12fd8322cbb350dd3bc5af8c748e8790ac64 Mon Sep 17 00:00:00 2001
From: jinlicong <493886250@qq.com>
Date: Wed, 05 Jun 2024 17:38:06 +0800
Subject: [PATCH] 继续测试修改
---
Function/UPPER_COMPUTER/upper_com.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/Function/UPPER_COMPUTER/upper_com.c b/Function/UPPER_COMPUTER/upper_com.c
index ffc8bf0..9657c0b 100644
--- a/Function/UPPER_COMPUTER/upper_com.c
+++ b/Function/UPPER_COMPUTER/upper_com.c
@@ -73,8 +73,11 @@
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;//�������
@@ -146,7 +149,9 @@
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;
}
@@ -241,7 +246,9 @@
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))
@@ -277,7 +284,7 @@
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;
@@ -285,7 +292,7 @@
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;
@@ -308,10 +315,14 @@
break;
}
-
-
-
}
+ }
+
+ //��λ����ʱ��������ʱ��û�н���ʱ�������ʧЧ����Ҫ���µ�����ܼ���ʹ��
+ if(__SYS_DELAY_SEC_FLAG_GET(UC_active_time) == SET){
+ __SYS_DELAY_SEC_FLAG_CLEAR_(UC_active_time);
+
+ local_random_code_g = 0;
}
@@ -332,5 +343,8 @@
}
+
+
+
}
--
Gitblit v1.9.3