Skip to content

Commit

Permalink
update(bug contain : send 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neyzoter committed Apr 18, 2019
1 parent 22703fb commit 2a9396c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion HARDWARE/QUEUE/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion HARDWARE/QUEUE/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) /*!< 队列最大容量>*/
/**
* @}
*/
Expand Down
2 changes: 1 addition & 1 deletion HARDWARE/TIMER/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();//蜂鸣器取反
}
Expand Down
30 changes: 12 additions & 18 deletions HARDWARE/WIFI/userwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
/* 发送到远程服务器*/
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions HARDWARE/WIFI/userwifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ typedef enum{
* @}
*/

/** @defgroup 超时发送
/** @defgroup CAN超时发送
* @{
*/
#define CAN_OVERTIME_SEND_TIME 600000 /*!< 8000ms>*/
#define CAN_OVERTIME_SEND_TIME 600000 /*!< 600ms>*/
/**
* @}
*/
Expand Down

0 comments on commit 2a9396c

Please sign in to comment.