From 760b38e025f3448ca1eca284ce8392f8425a2c10 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Wed, 19 Aug 2026 13:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8A=A8=E6=80=81=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- peripheral/com.c | 12 ++++++------ peripheral/include/com.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/peripheral/com.c b/peripheral/com.c index fc6ee26..207d4c0 100644 --- a/peripheral/com.c +++ b/peripheral/com.c @@ -73,6 +73,7 @@ TComCtrl *rd_ComCreate(cbk_ComCheck _pfCheck, cbk_ComDecode _pfDecode, cbk_ComSe ptComCtrl->m_iBufferSize = _iSize; ptComCtrl->m_pUserData = _pUserData; ptComCtrl->m_pSendTempBuffer = RD_CALLOC(1, _iSize); + ptComCtrl->m_ptPeakBuf = RD_CALLOC(1, _iSize); Rd_SemInit(&ptComCtrl->m_stComBuf.m_sem_Recv, 0, 0); Rd_SemInit(&ptComCtrl->m_stComBuf.m_sem_Send, 0, 0); ptComCtrl->m_stComBuf.m_ptRecv = rd_RingbufferCreate(_iSize); @@ -229,8 +230,7 @@ int rd_ComRead(TComCtrl *_ptComCtrl, char *_pBuffer, uint32_t _iSize) char *pPeakData = NULL; int iPeakLen = rd_RingbufferPeak(_ptComCtrl->m_stComBuf.m_ptRecv, &pPeakData); - char cPeekBuf[512]; - int iPeekLenLinear = rd_RingbufferPeekLinear(_ptComCtrl->m_stComBuf.m_ptRecv, cPeekBuf, sizeof(cPeekBuf)); + int iPeekLenLinear = rd_RingbufferPeekLinear(_ptComCtrl->m_stComBuf.m_ptRecv, _ptComCtrl->m_ptPeakBuf, _ptComCtrl->m_iBufferSize); if (iPeakLen < 0) { @@ -240,7 +240,7 @@ int rd_ComRead(TComCtrl *_ptComCtrl, char *_pBuffer, uint32_t _iSize) { Rd_SemWait(&_ptComCtrl->m_stComBuf.m_sem_Recv, __func__, NULL); iPeakLen = rd_RingbufferPeak(_ptComCtrl->m_stComBuf.m_ptRecv, &pPeakData); - iPeekLenLinear = rd_RingbufferPeekLinear(_ptComCtrl->m_stComBuf.m_ptRecv, cPeekBuf, sizeof(cPeekBuf)); + iPeekLenLinear = rd_RingbufferPeekLinear(_ptComCtrl->m_stComBuf.m_ptRecv, _ptComCtrl->m_ptPeakBuf, _ptComCtrl->m_iBufferSize); if (iPeakLen < 0) { @@ -272,7 +272,7 @@ int rd_ComRead(TComCtrl *_ptComCtrl, char *_pBuffer, uint32_t _iSize) iPackLen = 1; if (NULL != ptMutiDev->m_pfCheck) { - iPackLen = ptMutiDev->m_pfCheck(cPeekBuf, iPeekLenLinear); + iPackLen = ptMutiDev->m_pfCheck(_ptComCtrl->m_ptPeakBuf, iPeekLenLinear); } if (iPackLen > 0) @@ -344,7 +344,7 @@ int rd_ComRead(TComCtrl *_ptComCtrl, char *_pBuffer, uint32_t _iSize) iPackLen = 1; if (NULL != ptMutiDev->m_pfCheck) { - iPackLen = ptMutiDev->m_pfCheck(cPeekBuf, iPeekLenLinear); + iPackLen = ptMutiDev->m_pfCheck(_ptComCtrl->m_ptPeakBuf, iPeekLenLinear); } } @@ -453,4 +453,4 @@ int rd_ComIDSend(TComCtrl *_ptComCtrl, uint32_t _iFrameID, char *_pBuffer, uint3 RD_MEMCPY(&sendBuf[sizeof(uint32_t)], _pBuffer, _iSize); return rd_ComSend(_ptComCtrl, sendBuf, _iSize); -} \ No newline at end of file +} diff --git a/peripheral/include/com.h b/peripheral/include/com.h index a28064d..c2ddf8d 100644 --- a/peripheral/include/com.h +++ b/peripheral/include/com.h @@ -96,6 +96,7 @@ typedef struct { TComBuffer m_stComBuf; char *m_pSendTempBuffer; + char *m_ptPeakBuf; int m_iBufferSize; int m_iDevIndex; // 表示当前正在接收的设备索引,-1表示当前无设备在处理 UT_array *m_pMutiDevArray;