From 2a9396cdd9cad2b12b32a7be77e567f7bdc1bd1f Mon Sep 17 00:00:00 2001 From: Neyzoter Date: Thu, 18 Apr 2019 10:31:23 +0800 Subject: [PATCH] update(bug contain : send 0) --- HARDWARE/QUEUE/queue.c | 2 +- HARDWARE/QUEUE/queue.h | 2 +- HARDWARE/TIMER/timer.c | 2 +- HARDWARE/WIFI/userwifi.c | 30 ++++++++++++------------------ HARDWARE/WIFI/userwifi.h | 4 ++-- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/HARDWARE/QUEUE/queue.c b/HARDWARE/QUEUE/queue.c index 8cc4dc2..bf3d8bc 100644 --- a/HARDWARE/QUEUE/queue.c +++ b/HARDWARE/QUEUE/queue.c @@ -113,7 +113,7 @@ void queue_addtime_addIO(volatile Queue * pQueue, u32 count, u8 id, u8 IO_input1 pQueue->arr[(pQueue->head+12)% QUEUE_SIZE] = id; pQueue->arr[(pQueue->head+13)% QUEUE_SIZE] = IO_input1 | (IO_input2 << 1); pQueue->arr[(pQueue->head+14)% QUEUE_SIZE] = dataType; - pQueue->arr[(pQueue->head+15)% QUEUE_SIZE] = pQueue->arr[(pQueue->head+4)% QUEUE_SIZE];//校验位 + pQueue->arr[(pQueue->head+15)% QUEUE_SIZE] = pQueue->arr[(pQueue->head + 4)% QUEUE_SIZE];//校验位 queue_add_name(pQueue,test_name);//添加本次实验的名称,长度为MAX_TEST_NAME_LENGTH diff --git a/HARDWARE/QUEUE/queue.h b/HARDWARE/QUEUE/queue.h index c605fc4..d0b0121 100644 --- a/HARDWARE/QUEUE/queue.h +++ b/HARDWARE/QUEUE/queue.h @@ -32,7 +32,7 @@ */ #define UDP_SEND_SIZE (8*40 + PACKAGE_HEAD_FRAME_LENGTH) /*!< UDP数据包最大大小 540 = 8 * 60 + PACKAGE_HEAD_FRAME_LENGTH>*/ #define QUEUE_SIZE 500 /*!< 队列正常容量,必须比UDP_SEND_SIZE大一些,不然会在被后面的信息覆盖>*/ -#define ARR_SIZE (QUEUE_SIZE + UDP_SEND_SIZE+52) /*!< 队列最大容量>*/ +#define ARR_SIZE (QUEUE_SIZE + UDP_SEND_SIZE+120) /*!< 队列最大容量>*/ /** * @} */ diff --git a/HARDWARE/TIMER/timer.c b/HARDWARE/TIMER/timer.c index cc05e95..83d4405 100644 --- a/HARDWARE/TIMER/timer.c +++ b/HARDWARE/TIMER/timer.c @@ -178,7 +178,7 @@ void TIM3_IRQHandler(void) CAN2_Send_Msg((u8 *)msg,8); } }else if(RSI_WIFI_OPER_MODE == RSI_WIFI_AP_MODE_VAL){/*!< AP模式下快速闪烁>*/ - if(MS_TIME%200==0){ + if(MS_TIME%150==0){ WORKING_LED_CONV();//工作灯 BEEP_CONV();//蜂鸣器取反 } diff --git a/HARDWARE/WIFI/userwifi.c b/HARDWARE/WIFI/userwifi.c index bb3f34e..104e837 100644 --- a/HARDWARE/WIFI/userwifi.c +++ b/HARDWARE/WIFI/userwifi.c @@ -126,7 +126,7 @@ s32 TcpCount = 0; */ u8 wifi_send_package() { - u16 Adc_Head;u16 Can_Head; + u16 Adc_Head,Can_Head; u32 Adc_Length;u32 Can_Length; u8 temp; @@ -142,10 +142,12 @@ u8 wifi_send_package() Can_Length = queue_length(can_queue); /* ADC Queue加入帧头*/ + //1.加入帧头 queue_addtime_addIO(&adc_queue,Adc_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,ADC_DATA_PACKAGE); - /**获取队列头,并更新队列*/ + //2.获取队列头 Adc_Head = adc_queue.head; - adc_queue.head = adc_queue.tail; + //3.更新队列 + adc_queue.head = adc_queue.tail; //队列清空,则会启动下一个包的ADC采集,包括1、在tail后加ADC数据;2、更新时间;3、更新tail /* CAN Queue加入帧头*/ queue_addtime_addIO(&can_queue,Can_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,CAN_DATA_PACKAGE); Can_Head = can_queue.head; @@ -213,17 +215,14 @@ u8 wifi_send_package() DATA_AUTO_CHECK_EN = 0; rsi_send_ludp_data(localSocketDescriptor_txrx, &adc_queue.arr[Adc_Head],Adc_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)localDestIp_txrx, localDestSocket_txrx, &bytes_sent); DATA_AUTO_CHECK_EN = temp; + delay_ms(5); } /* CAN队列已满*/ if( queue_length(can_queue) >= (UDP_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){ - /* 得到can队列的长度,只有数据*/ Can_Length = queue_length(can_queue); - /* CAN Queue加入帧头*/ queue_addtime_addIO(&can_queue,Can_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,CAN_DATA_PACKAGE); Can_Head = can_queue.head; can_queue.head = can_queue.tail; - - /* 如果分成两段,将前面一段复制到后面*/ if(Can_Head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH > QUEUE_SIZE ) { queue_oversize(&can_queue,Can_Head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH - QUEUE_SIZE); } @@ -234,31 +233,25 @@ u8 wifi_send_package() temp = DATA_AUTO_CHECK_EN; DATA_AUTO_CHECK_EN = 0; /* 发送到远程服务器*/ - rsi_send_ludp_data(socketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length, RSI_PROTOCOL_UDP_V4, (uint8 *)destIp_txrx, destSocket_txrx, &bytes_sent); + rsi_send_ludp_data(socketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)destIp_txrx, destSocket_txrx, &bytes_sent); DATA_AUTO_CHECK_EN = temp; delay_ms(5); temp = DATA_AUTO_CHECK_EN; DATA_AUTO_CHECK_EN = 0; /* CAN数据发送到局域网*/ - rsi_send_ludp_data(localSocketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length, RSI_PROTOCOL_UDP_V4, (uint8 *)localDestIp_txrx, localDestSocket_txrx, &bytes_sent); + rsi_send_ludp_data(localSocketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)localDestIp_txrx, localDestSocket_txrx, &bytes_sent); DATA_AUTO_CHECK_EN = temp; }else if(queue_length(can_queue) > 0){ /* CAN队列中数据存储时间过长,以us为单位,就发出来*/ if(((SYSTEMTIME - ((u32)(can_queue.arr[can_queue.head+1]&0xff)|((u32)(can_queue.arr[can_queue.head+2]&0xff)<<8)|((u32)(can_queue.arr[can_queue.head+3]&0xff)<<16) |((u32)(can_queue.arr[can_queue.head+4]&0xff)<<24)))*(TIM4_ARR + 1)*(TIM4_PSC + 1) / TIM3_4_PCLK_MHZ) > CAN_OVERTIME_SEND_TIME){ - /* 得到can队列的长度,只有数据*/ Can_Length = queue_length(can_queue); - /* CAN Queue加入帧头*/ queue_addtime_addIO(&can_queue,Can_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,CAN_DATA_PACKAGE); - /**获取队列头,并更新队列*/ Can_Head = can_queue.head; can_queue.head = can_queue.tail; - /* 如果分成两段,将前面一段复制到后面*/ - if(can_queue.head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH > QUEUE_SIZE ) { - queue_oversize(&can_queue,can_queue.head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH - QUEUE_SIZE); + if(Can_Head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH > QUEUE_SIZE ) { + queue_oversize(&can_queue,Can_Head + Can_Length + PACKAGE_HEAD_FRAME_LENGTH - QUEUE_SIZE); }; - - temp = DATA_AUTO_CHECK_EN; DATA_AUTO_CHECK_EN = 0; /* 发送到远程服务器*/ @@ -269,7 +262,8 @@ u8 wifi_send_package() DATA_AUTO_CHECK_EN = 0; /* CAN数据发送到局域网*/ rsi_send_ludp_data(localSocketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)localDestIp_txrx, localDestSocket_txrx, &bytes_sent); - DATA_AUTO_CHECK_EN = temp; + DATA_AUTO_CHECK_EN = temp; + delay_ms(5); } } return 1; diff --git a/HARDWARE/WIFI/userwifi.h b/HARDWARE/WIFI/userwifi.h index 5b5f857..0a3850e 100644 --- a/HARDWARE/WIFI/userwifi.h +++ b/HARDWARE/WIFI/userwifi.h @@ -54,10 +54,10 @@ typedef enum{ * @} */ -/** @defgroup 超时发送 +/** @defgroup CAN超时发送 * @{ */ -#define CAN_OVERTIME_SEND_TIME 600000 /*!< 8000ms>*/ +#define CAN_OVERTIME_SEND_TIME 600000 /*!< 600ms>*/ /** * @} */