Skip to content

Commit

Permalink
Merge back from IOsonata
Browse files Browse the repository at this point in the history
  • Loading branch information
hnhoan committed Oct 25, 2019
1 parent c64b14f commit f9495c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion include/slip_intrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct __Slip_Device {
DEVINTRF DevIntrf; //!< This interface
DEVINTRF *pPhyIntrf; //!< Physical transport interface
void *pObj; //!< Slip object instance
volatile bool bSlipEnd; //!< true - indicate slip packet complete
} SLIPDEV;

#ifdef __cplusplus
Expand All @@ -65,7 +66,7 @@ static inline int SlipRx(SLIPDEV * const pDev, uint8_t *pBuff, int Bufflen) {
static inline int SlipTx(SLIPDEV * const pDev, uint8_t *pData, int Datalen) {
return DeviceIntrfTx(&pDev->DevIntrf, 0, pData, Datalen);
}

static inline bool SlipRxCompleted(SLIPDEV * const pDev) { return pDev->bSlipEnd; }

#ifdef __cplusplus
}
Expand Down Expand Up @@ -194,6 +195,8 @@ class Slip : public DeviceIntrf {
*/
virtual void StopTx(void) { DeviceIntrfStopTx(*this); }

bool RxCompleted() { return vDevData.bSlipEnd; }

private:
SLIPDEV vDevData;
};
Expand Down
16 changes: 12 additions & 4 deletions src/slip_intrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ int SlipIntrfRxDataBlocking(DEVINTRF * const pDevIntrf, uint8_t *pBuff, int Buff
uint8_t d;

uint8_t *p = pBuff;
dev->bSlipEnd = false;

while (BuffLen > 0)
{
if (dev->pPhyIntrf->RxData(dev->pPhyIntrf, pBuff, 1) > 0)
{
if (*pBuff == SLIP_END_CODE)
{
return cnt;
// cnt++;
dev->bSlipEnd = true;

break;
}
if (*pBuff == SLIP_ESC_CODE)
{
Expand Down Expand Up @@ -212,6 +216,8 @@ int SlipIntrfRxDataNonBlocking(DEVINTRF * const pDevIntrf, uint8_t *pBuff, int B
int cnt = 0;
uint8_t d;

dev->bSlipEnd = false;

if (*pBuff == SLIP_ESC_CODE)
{
if (dev->pPhyIntrf->RxData(dev->pPhyIntrf, &d, 1) <= 0)
Expand Down Expand Up @@ -242,7 +248,9 @@ int SlipIntrfRxDataNonBlocking(DEVINTRF * const pDevIntrf, uint8_t *pBuff, int B

if (*pBuff == SLIP_END_CODE)
{
cnt++;
//cnt++;
dev->bSlipEnd = true;

break;
}
if (*pBuff == SLIP_ESC_CODE)
Expand Down Expand Up @@ -320,7 +328,7 @@ bool SlipIntrfStartTx(DEVINTRF * const pDevIntrf, int DevAddr)
*
* @return Number of bytes sent including the SLIP code
*/
#if 1
#if 0
int SlipIntrfTxData(DEVINTRF * const pDevIntrf, uint8_t *pData, int DataLen)
{
SLIPDEV *dev = (SLIPDEV *)pDevIntrf->pDevData;
Expand Down Expand Up @@ -542,7 +550,7 @@ bool SlipInit(SLIPDEV * const pDev, DEVINTRF * const pPhyIntrf, bool bBlocking)
pDev->DevIntrf.StopTx = SlipIntrfStopTx;
pDev->DevIntrf.IntPrio = 0;
pDev->DevIntrf.EvtCB = nullptr;
pDev->DevIntrf.MaxRetry = 5;
pDev->DevIntrf.MaxRetry = 0;
pDev->DevIntrf.bDma = false;
pDev->DevIntrf.PowerOff = SlipIntrfPowerOff;
pDev->DevIntrf.EnCnt = 1;
Expand Down

0 comments on commit f9495c9

Please sign in to comment.