12 #ifndef ECL_DEVICES_SERIAL_POS_HPP_ 13 #define ECL_DEVICES_SERIAL_POS_HPP_ 20 #if defined(ECL_IS_POSIX) 144 Serial() : is_open(false), error_handler(
NoError)
244 template <typename Byte>
245 long write(const Byte &byte) ecl_debug_throw_decl(StandardException);
257 template <typename Byte>
258 long write(const Byte *bytes, const
unsigned long &n) ecl_debug_throw_decl(StandardException);
290 void block(
const unsigned long &timeout = 500);
323 template <
typename Byte>
339 template <
typename Byte>
352 { tcflush(file_descriptor,TCIOFLUSH);}
358 void clearInputBuffer()
359 { tcflush(file_descriptor,TCIFLUSH);}
365 void clearOutputBuffer()
366 { tcflush(file_descriptor,TCOFLUSH);}
374 const Error& error()
const 375 {
return error_handler;}
389 unsigned long read_timeout_ms;
390 ecl::Snooze fake_snooze;
391 unsigned int fake_loop_count;
400 template <
typename Byte>
410 ssize_t no_written = ::write(file_descriptor, &byte, 1);
411 if ( no_written < 0 )
421 template <
typename Byte>
422 long Serial::write(
const Byte *bytes,
const unsigned long &n)
ecl_debug_throw_decl(StandardException)
431 ssize_t no_written = ::write(file_descriptor, bytes, n);
432 if ( no_written < 0 )
442 template <
typename Byte>
453 if ( ( read_timeout_ms != NonBlocking ) && ( read_timeout_ms < 100 ) )
455 fake_snooze.initialise();
456 for (
unsigned int i = 0; i < fake_loop_count; ++i )
458 no_read = ::read(file_descriptor, &byte, 1);
468 no_read = ::read(file_descriptor, &byte, 1);
481 template <
typename Byte>
492 if ( ( read_timeout_ms != NonBlocking ) && ( read_timeout_ms < 100 ) )
494 fake_snooze.initialise();
495 for (
unsigned int i = 0; i < fake_loop_count; ++i )
497 no_read = ::read(file_descriptor, bytes, n);
507 no_read = ::read(file_descriptor, bytes, n);
528 class is_sink<Serial> :
public True 537 class is_source<Serial> :
public True 546 class is_sourcesink<Serial> :
public True
StopBits
Stop bits used in a serial packet.
Embedded control libraries.
Cross-platform abstractions for the serial class.
StandardException read_exception(const char *loc)
#define ecl_compile_time_assert(logical_expression)
Defines error handlers for posix devices.
Parity
Parity of the serial packet.
DataBits
Data bits used in a serial packet.
#define ecl_debug_throw_decl(exception)
StandardException write_exception(const char *loc)
#define ecl_debug_throw(exception)
BaudRate
Serial connection baud rate.
Defines exception handlers for posix devices.