| 291 | } |
| 292 | |
| 293 | size_t Serial::readAvailableBytes( void *data, size_t maximumBytes ) |
| 294 | { |
| 295 | #if defined( CINDER_MAC ) || defined( CINDER_LINUX ) |
| 296 | long bytesRead = ::read( mImpl->mFd, data, maximumBytes ); |
| 297 | #elif defined( CINDER_MSW ) |
| 298 | ::DWORD bytesRead = 0; |
| 299 | if( ! ::ReadFile( mImpl->mDeviceHandle, data, static_cast<DWORD>( maximumBytes ), &bytesRead, 0 ) ) |
| 300 | throw SerialExcReadFailure(); |
| 301 | #endif |
| 302 | |
| 303 | if( bytesRead < 0 ) |
| 304 | bytesRead = 0; |
| 305 | |
| 306 | return (size_t)bytesRead; |
| 307 | } |
| 308 | |
| 309 | void Serial::writeByte( uint8_t data ) |
| 310 | { |