Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Neyzoter committed Apr 23, 2019
1 parent b491539 commit 53686c3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion HARDWARE/QUEUE/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void queue_arr_memcpy(Queue * pQueue, u8 * buf , u8 len){

}else{
memcpy((u8 *)&(pQueue->arr[pQueue->tail]),buf,QUEUE_SIZE - pQueue->tail);
memcpy((u8 *)&(pQueue->arr[0]),buf+QUEUE_SIZE - pQueue->tail,len - QUEUE_SIZE + pQueue->tail);
memcpy((u8 *)&(pQueue->arr[0]),buf + QUEUE_SIZE - pQueue->tail,len - QUEUE_SIZE + pQueue->tail);
}
pQueue->tail = (pQueue->tail + len) % QUEUE_SIZE;

Expand Down
4 changes: 2 additions & 2 deletions HARDWARE/QUEUE/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* @{
*/
#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+120) /*!< 队列最大容量>*/
#define QUEUE_SIZE 700 /*!< 队列正常容量,必须比UDP_SEND_SIZE大一些,不然会在被后面的信息覆盖>*/
#define ARR_SIZE (QUEUE_SIZE + UDP_SEND_SIZE+52) /*!< 队列最大容量>*/
/**
* @}
*/
Expand Down
37 changes: 23 additions & 14 deletions HARDWARE/WIFI/userwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,28 @@ u8 wifi_send_package()
rsi_send_ludp_data(socketDescriptor_txrx, &adc_queue.arr[Adc_Head],Adc_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)destIp_txrx, destSocket_txrx, &bytes_sent);

DATA_AUTO_CHECK_EN = temp;
delay_ms(5);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
temp = DATA_AUTO_CHECK_EN;
DATA_AUTO_CHECK_EN = 0;
/* 发送到远程服务器*/
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);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
temp = DATA_AUTO_CHECK_EN;
DATA_AUTO_CHECK_EN = 0;
/* ADC数据发送到局域网*/
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);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
temp = DATA_AUTO_CHECK_EN;
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;

delay_ms(WIFI_MODUEL_WAIT_MSTIME);
Time_Sync_Flag = 0;//时钟同步位清零
}
/* ADC队列已满*/
Expand All @@ -209,13 +209,13 @@ u8 wifi_send_package()
rsi_send_ludp_data(socketDescriptor_txrx, &adc_queue.arr[Adc_Head],Adc_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)destIp_txrx, destSocket_txrx, &bytes_sent);

DATA_AUTO_CHECK_EN = temp;
delay_ms(5);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
//发送到局域网
temp = DATA_AUTO_CHECK_EN;
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);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
}
/* CAN队列已满*/
if( queue_length(can_queue) >= (UDP_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){
Expand All @@ -226,17 +226,26 @@ u8 wifi_send_package()
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);
}
// for(int i =0 ;i < Can_Length+PACKAGE_HEAD_FRAME_LENGTH;i++){
// printf("%x ",can_queue.arr[can_queue.head+i]);
// }

//! 是否打印出要发出去的CAN数据
#if PRINTF_CAN_QUEUE_DATA
for(int i =0 ;i < Can_Length+PACKAGE_HEAD_FRAME_LENGTH;i++){
printf("%x ",can_queue.arr[(Can_Head+i)%QUEUE_SIZE]);
}
printf("\r\n");
#endif
temp = DATA_AUTO_CHECK_EN;
DATA_AUTO_CHECK_EN = 0;
/* 发送到远程服务器*/
//! 是否打印发送数据到模组的时间
#if PRINTF_WIFI_SEND2MODULE_TIME
u32 time0 = SYSTEMTIME;
#endif
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);

#if PRINTF_WIFI_SEND2MODULE_TIME
printf("Time of Send to Module : %d\r\n",SYSTEMTIME - time0);
#endif
DATA_AUTO_CHECK_EN = temp;
delay_ms(5);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
temp = DATA_AUTO_CHECK_EN;
DATA_AUTO_CHECK_EN = 0;
/* CAN数据发送到局域网*/
Expand All @@ -257,13 +266,13 @@ u8 wifi_send_package()
/* 发送到远程服务器*/
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);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
temp = DATA_AUTO_CHECK_EN;
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;
delay_ms(5);
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
}
}
return 1;
Expand Down
8 changes: 8 additions & 0 deletions HARDWARE/WIFI/userwifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ typedef enum{
* @}
*/

/** @defgroup WIFI模组等待的时间
* @{
*/
#define WIFI_MODUEL_WAIT_MSTIME 2 /*!< 用于防止缓存区被重写>*/
/**
* @}
*/

/** @defgroup 上位机命令,UDP数据包第1个字节
* @{
*/
Expand Down

0 comments on commit 53686c3

Please sign in to comment.