|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|