cmSerialPort.h/c : Added cmSeSetCallback() and cmSeStart().
This commit is contained in:
parent
18b815d387
commit
08ae2446b2
@ -282,12 +282,6 @@ cmSeH_t cmSeCreate( cmCtx_t* ctx, cmSeH_t* hp, const char* deviceStr, unsigned b
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if( cmThreadPause(p->_thH,0) != kOkThRC )
|
||||
{
|
||||
rc = cmErrMsg(&p->_err,kThreadErrSeRC,0,"Thread start failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if( hp != NULL )
|
||||
hp->h = p;
|
||||
else
|
||||
@ -321,6 +315,26 @@ cmSeRC_t cmSeDestroy(cmSeH_t* hp )
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmSeRC_t cmSeSetCallback( cmSeH_t h, cmSeCallbackFunc_t cbFunc, void* cbArg )
|
||||
{
|
||||
cmSerialPort_t* p = _cmSePtrFromHandle(h);
|
||||
p->_cbFunc = cbFunc;
|
||||
p->_cbArg = cbArg;
|
||||
return kOkSeRC;
|
||||
}
|
||||
|
||||
cmSeRC_t cmSeStart( cmSeH_t h )
|
||||
{
|
||||
cmSerialPort_t* p = _cmSePtrFromHandle(h);
|
||||
|
||||
if( cmThreadPause(p->_thH,0) != kOkThRC )
|
||||
return cmErrMsg(&p->_err,kThreadErrSeRC,0,"Thread start failed.");
|
||||
|
||||
return kOkSeRC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool cmSeIsOpen( cmSeH_t h)
|
||||
{
|
||||
if( h.h == NULL )
|
||||
@ -542,6 +556,9 @@ cmSeRC_t cmSePortTest(cmCtx_t* ctx)
|
||||
|
||||
h = cmSeCreate(ctx,&h,device,baud,serialCfgFlags,_cmSePortTestCb,NULL,pollPeriodMs);
|
||||
|
||||
if( cmSeIsOpen(h) )
|
||||
cmSeStart(h);
|
||||
|
||||
bool quitFl = false;
|
||||
printf("q=quit\n");
|
||||
while(!quitFl)
|
||||
|
@ -48,8 +48,11 @@ extern "C" {
|
||||
|
||||
typedef cmHandle_t cmSeH_t;
|
||||
|
||||
cmSeH_t cmSeCreate( cmCtx_t* ctx, cmSeH_t* hp, const char* device, unsigned baudRate, unsigned cfgFlags, cmSeCallbackFunc_t cbFunc, void* cbArg, unsigned pollPeriodMs );
|
||||
cmSeRC_t cmSeDestroy(cmSeH_t* hp );
|
||||
cmSeH_t cmSeCreate( cmCtx_t* ctx, cmSeH_t* hp, const char* device, unsigned baudRate, unsigned cfgFlags, cmSeCallbackFunc_t cbFunc, void* cbArg, unsigned pollPeriodMs );
|
||||
cmSeRC_t cmSeDestroy(cmSeH_t* hp );
|
||||
|
||||
cmSeRC_t cmSeSetCallback( cmSeH_t h, cmSeCallbackFunc_t cbFunc, void* cbArg );
|
||||
cmSeRC_t cmSeStart( cmSeH_t h );
|
||||
|
||||
bool cmSeIsOpen( cmSeH_t h);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user