MCPcopy Create free account
hub / github.com/cinder/Cinder / readBytes

Method readBytes

src/cinder/Serial.cpp:272–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272void Serial::readBytes( void *data, size_t numBytes )
273{
274 size_t totalBytesRead = 0;
275 while( totalBytesRead < numBytes ) {
276#if defined( CINDER_MAC ) || defined( CINDER_LINUX )
277 long bytesRead = ::read( mImpl->mFd, data, numBytes - totalBytesRead );
278 if( ( bytesRead == -1 ) && ( errno != EAGAIN ) )
279 throw SerialExcReadFailure();
280#elif defined( CINDER_MSW )
281 ::DWORD bytesRead = 0;
282 if( ! ::ReadFile( mImpl->mDeviceHandle, data, static_cast<DWORD>( numBytes - totalBytesRead ), &bytesRead, 0 ) )
283 throw SerialExcReadFailure();
284#endif
285 if( bytesRead != -1 )
286 totalBytesRead += bytesRead;
287
288 // yield thread time to the system
289 this_thread::yield();
290 }
291}
292
293size_t Serial::readAvailableBytes( void *data, size_t maximumBytes )
294{

Callers

nothing calls this directly

Calls 1

readFunction · 0.50

Tested by

no test coverage detected