MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / Read

Method Read

cpp/src/platform/unix/SerialControllerImpl.cpp:321–357  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Read data from the serial port -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

319// Read data from the serial port
320//-----------------------------------------------------------------------------
321void SerialControllerImpl::Read
322(
323 Event* _exitEvent
324)
325{
326 uint8 buffer[256];
327
328 while( !_exitEvent->IsSignalled() )
329 {
330 int32 bytesRead;
331 int err;
332
333 do
334 {
335 bytesRead = read( m_hSerialController, buffer, sizeof(buffer) );
336 if( bytesRead > 0 )
337 m_owner->Put( buffer, bytesRead );
338 } while( bytesRead > 0 );
339
340 do
341 {
342 struct timeval *whenp;
343 fd_set rds, eds;
344 int oldstate;
345
346 FD_ZERO( &rds );
347 FD_SET( m_hSerialController, &rds );
348 FD_ZERO( &eds );
349 FD_SET( m_hSerialController, &eds );
350 whenp = NULL;
351
352 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
353 err = select( m_hSerialController + 1, &rds, NULL, &eds, whenp );
354 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
355 } while( err <= 0 );
356 }
357}
358
359//-----------------------------------------------------------------------------
360// <SerialControllerImpl::Write>

Callers

nothing calls this directly

Calls 2

PutMethod · 0.80
IsSignalledMethod · 0.45

Tested by

no test coverage detected