From 0a1e3ef8a560192eae7ad51dc18f570c1bd5a424 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 18 Jun 2026 15:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E5=90=88=E4=BF=AE=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E7=94=A8=EF=BC=8C=E5=90=8C=E6=97=B6=E8=A7=A3?= =?UTF-8?q?=E5=86=B3CAN=E5=9B=9E=E5=8F=91=E6=97=B6=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8E=9F=E5=9B=A0=E6=98=AF?= =?UTF-8?q?check=E4=BC=9A=E8=A7=A6=E5=8F=91=E4=B8=A4=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/RBcore/drv_interface.c | 4 ++-- project/Spoolend/Spoolend.c | 32 +++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/project/RBcore/drv_interface.c b/project/RBcore/drv_interface.c index 52c2b91..a8dafb8 100644 --- a/project/RBcore/drv_interface.c +++ b/project/RBcore/drv_interface.c @@ -118,12 +118,12 @@ int RS485_4_Send(char *_pBuffer, uint32_t _iSize) int FDCAN1_Send(char *_pBuffer, uint32_t _iSize) { - return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer[0], &_pBuffer[4], _iSize); + return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer, _iSize); } int FDCAN2_Send(char *_pBuffer, uint32_t _iSize) { - return CAN_TX_FIFOQ(g_ptFDCAN2, _pBuffer[0], &_pBuffer[4], _iSize); + return CAN_TX_FIFOQ(g_ptFDCAN2, _pBuffer, _iSize); } #ifndef CONFIG_UART_IT_IDLEDMA diff --git a/project/Spoolend/Spoolend.c b/project/Spoolend/Spoolend.c index c73524b..41d01db 100644 --- a/project/Spoolend/Spoolend.c +++ b/project/Spoolend/Spoolend.c @@ -18,6 +18,7 @@ ******************************************************************************/ #include "bsp_uart.h" #include "bsp_CAN.h" +#include "com.h" #include "fdcan.h" /*----------------------------------------------* * 外部变量说明 * @@ -84,27 +85,39 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) static int check_RS485_1(char *_pBuffer, uint32_t _iSize) { - rd_ComSend(g_ptRS485_1, _pBuffer, _iSize); return _iSize; } static int check_RS485_2(char *_pBuffer, uint32_t _iSize) { - rd_ComSend(g_ptRS485_2, _pBuffer, _iSize); return _iSize; } static int check_Spoolend(char *_pBuffer, uint32_t _iSize) { - TCANUserData *ptCANUserData = (TCANUserData *)g_ptFDCAN1->m_pUserData; - uint32_t iCANId = (uint8_t)ptCANUserData->m_canrx->Identifier; - rd_ComIDSend(g_ptFDCAN1, iCANId, _pBuffer, _iSize); return _iSize; } +static void decode_RS485_1(const char *_pBuffer, uint32_t _iSize) +{ + rd_ComSend(g_ptRS485_1, (char *)_pBuffer, _iSize); +} + +static void decode_RS485_2(const char *_pBuffer, uint32_t _iSize) +{ + rd_ComSend(g_ptRS485_2, (char *)_pBuffer, _iSize); +} + +static void decode_Spoolend(const char *_pBuffer, uint32_t _iSize) +{ + TCANUserData *ptCANUserData = (TCANUserData *)g_ptFDCAN1->m_pUserData; + uint32_t iCANId = (uint32_t)ptCANUserData->m_canrx->Identifier; + rd_ComIDWrite(g_ptFDCAN1, iCANId, (char *)_pBuffer, _iSize); +} + static int FDCAN1_Send(char *_pBuffer, uint32_t _iSize) { - return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer[0], &_pBuffer[4], _iSize); + return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer, _iSize); } void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs) @@ -154,13 +167,13 @@ int Myprint_putchar(uint8_t ch) void SpoolendInit(void) { TUartUserData *ptUartUserData = UART_userdata_init(0, 115200, 512); - g_ptRS485_1 = rd_ComCreate(check_RS485_1, NULL, RS485_1_Send, ptUartUserData->m_buf_size, ptUartUserData); + g_ptRS485_1 = rd_ComCreate(check_RS485_1, decode_RS485_1, RS485_1_Send, ptUartUserData->m_buf_size, ptUartUserData); UART_IT_init(g_ptRS485_1); // TUartUserData *ptUartUserData1 = UART_userdata_init(0, 115200, 512); -// g_ptRS485_2 = rd_ComCreate(check_RS485_2, NULL, RS485_2_Send, ptUartUserData1->m_buf_size, ptUartUserData1); +// g_ptRS485_2 = rd_ComCreate(check_RS485_2, decode_RS485_2, RS485_2_Send, ptUartUserData1->m_buf_size, ptUartUserData1); // UART_IT_init(g_ptRS485_2); TCANUserData *ptCANUserData = CAN_userdata_init(&hfdcan1, 8, 0); - g_ptFDCAN1 = rd_ComCreate(check_Spoolend, NULL, FDCAN1_Send, CONFIG_UART_BUFFER_SIZE, ptCANUserData); + g_ptFDCAN1 = rd_ComCreate(check_Spoolend, decode_Spoolend, FDCAN1_Send, CONFIG_UART_BUFFER_SIZE, ptCANUserData); CAN_IT_init(g_ptFDCAN1); } @@ -178,6 +191,7 @@ void SpoolendTask(void) HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin); HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); + rd_ComSendProc(g_ptFDCAN1); HAL_Delay(500); }