From b977c947ff6d0f30d96703165cd4bb2c480221ec Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Fri, 12 Jun 2026 09:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E8=BD=B4=E7=AB=AF=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=9D=BF485=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Spoolend/Spoolend.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Spoolend/Spoolend.c b/Spoolend/Spoolend.c index 07a1d13..2b73fae 100644 --- a/Spoolend/Spoolend.c +++ b/Spoolend/Spoolend.c @@ -92,9 +92,37 @@ static int check_RS485_2(char *_pBuffer, uint32_t _iSize) return _iSize; } +void Myprint_Init(void) +{ + TUartUserData *ptUartUserData = UART_userdata_init(1, 115200, 4096); + g_ptRS485_2 = rd_ComCreate(NULL, NULL, RS485_2_Send, ptUartUserData->m_buf_size, ptUartUserData); + UART_IT_init(g_ptRS485_2); +} + +int Myprint_putchar(uint8_t ch) +{ + char tx_buf[2]; + + if (ch == '\n') + { + // 遇到换行,发送 \r\n + tx_buf[0] = '\r'; + tx_buf[1] = '\n'; + if (rd_ComSend(g_ptRS485_2, tx_buf, 2) < 0) return EOF; + return 2; + } + else + { + // 普通字符 + tx_buf[0] = ch; + if (rd_ComSend(g_ptRS485_2, tx_buf, 1) < 0) return EOF; + return 1; + } +} + void SpoolendInit(void) { - TUartUserData *ptUartUserData = UART_userdata_init(0, -1, 512); + 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); UART_IT_init(g_ptRS485_1); // TUartUserData *ptUartUserData1 = UART_userdata_init(0, 115200, 512);