发送缓冲测试

This commit is contained in:
Kidenygood 2023-04-03 21:01:17 +08:00
parent 607615e6b6
commit b37ceaa2e9
7 changed files with 17 additions and 14 deletions

View File

@ -83,8 +83,7 @@ int main(void)
/* MCU Configuration--------------------------------------------------------*/ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init(); HAL_Init();
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
/* USER CODE END Init */ /* USER CODE END Init */

View File

@ -381,4 +381,6 @@ static void UI_test_init(referee_info_t *_referee_info)
Char_Draw(&sdata[0], "s7", UI_Graph_ADD, 0, UI_Color_Green, 20, 2, 620, 710); Char_Draw(&sdata[0], "s7", UI_Graph_ADD, 0, UI_Color_Green, 20, 2, 620, 710);
Char_Write(&sdata[0], "number:%d", 123); Char_Write(&sdata[0], "number:%d", 123);
Char_ReFresh(&_referee_info->referee_id, sdata[0]); Char_ReFresh(&_referee_info->referee_id, sdata[0]);
RefereeSend();
} }

View File

@ -35,11 +35,12 @@ void RobotInit()
#endif #endif
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD) #if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
// Referee_Interactive_init();
ChassisInit(); ChassisInit();
#endif #endif
// 初始化完成,开启中断 // 初始化完成,开启中断
__enable_irq(); __enable_irq();
Referee_Interactive_init();
} }
void RobotTask() void RobotTask()

View File

@ -42,7 +42,7 @@ void UI_Delete(referee_id_t *_id, uint8_t Del_Operate, uint8_t Del_Layer)
UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF); UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF);
/* 填入0xFFFF,关于crc校验 */ /* 填入0xFFFF,关于crc校验 */
RefereeSend((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 RefereeLoadToBuffer((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送
UI_Seq++; // 包序号+1 UI_Seq++; // 包序号+1
} }
@ -388,17 +388,17 @@ void UI_ReFresh(referee_id_t *_id, int cnt, ...)
// 先发送帧头、命令码、交互数据帧头三部分并计算CRC16校验值 // 先发送帧头、命令码、交互数据帧头三部分并计算CRC16校验值
UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head, 0xFFFF); UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head, 0xFFFF);
RefereeSend((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head); RefereeLoadToBuffer((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head);
for (i = 0; i < cnt; i++) // 发送交互数据的数据帧并计算CRC16校验值 for (i = 0; i < cnt; i++) // 发送交互数据的数据帧并计算CRC16校验值
{ {
graphData = va_arg(ap, Graph_Data_t); // 访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量 graphData = va_arg(ap, Graph_Data_t); // 访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量
// 发送并计算CRC16 // 发送并计算CRC16
RefereeSend((uint8_t *)&graphData, UI_Operate_LEN_PerDraw); RefereeLoadToBuffer((uint8_t *)&graphData, UI_Operate_LEN_PerDraw);
UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&graphData, UI_Operate_LEN_PerDraw, UI_GraphReFresh_data.frametail); UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&graphData, UI_Operate_LEN_PerDraw, UI_GraphReFresh_data.frametail);
} }
RefereeSend((uint8_t *)&UI_GraphReFresh_data.frametail, LEN_TAIL); // 发送CRC16校验值 RefereeLoadToBuffer((uint8_t *)&UI_GraphReFresh_data.frametail, LEN_TAIL); // 发送CRC16校验值
va_end(ap); // 结束可变参数的获取 va_end(ap); // 结束可变参数的获取
UI_Seq++; // 包序号+1 UI_Seq++; // 包序号+1
@ -427,7 +427,7 @@ void Char_ReFresh(referee_id_t *_id, String_Data_t string_Data)
UI_CharReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF); UI_CharReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF);
RefereeSend((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 RefereeLoadToBuffer((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送
UI_Seq++; // 包序号+1 UI_Seq++; // 包序号+1
} }

View File

@ -40,6 +40,6 @@ void Communicate_SendData(referee_id_t *_id,robot_interactive_data_t *_data)
SendData.frametail = Get_CRC16_Check_Sum((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF); SendData.frametail = Get_CRC16_Check_Sum((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF);
RefereeSend((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送 RefereeLoadToBuffer((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送
UI_Seq++; // 包序号+1 UI_Seq++; // 包序号+1
} }

View File

@ -48,11 +48,12 @@ void RefereeLoadToBuffer(uint8_t *send, uint16_t tx_len)
/** /**
* @brief * @brief
* @param send * @param
*/ */
void RefereeSend(uint8_t *send, uint16_t tx_len) void RefereeSend()
{ {
USARTSend(referee_usart_instance, send, tx_len,USART_TRANSFER_IT);//syhtodo此函数需要重写 USARTSend(referee_usart_instance, (uint8_t *)(&referee_tx_buffer.buffer), referee_tx_buffer.pos,USART_TRANSFER_DMA);
referee_tx_buffer.pos=0;
/* syhtodo DMA请求过快会导致数据发送丢失考虑数据尽可能打成一个整包以及队列发送并且发送函数添加缓冲区 */ /* syhtodo DMA请求过快会导致数据发送丢失考虑数据尽可能打成一个整包以及队列发送并且发送函数添加缓冲区 */
} }

View File

@ -68,8 +68,8 @@ void RefereeLoadToBuffer(uint8_t *send, uint16_t tx_len);
/** /**
* @brief * @brief
* @todo * @todo
* @param send * @param
*/ */
void RefereeSend(uint8_t *send, uint16_t tx_len); void RefereeSend(void);
#endif // !REFEREE_H #endif // !REFEREE_H