12 #ifndef ECL_DEVICES_SERIAL_POS_HPP_ 13 #define ECL_DEVICES_SERIAL_POS_HPP_ 19 #include <ecl/config.hpp> 20 #if defined(ECL_IS_POSIX) 28 #include <ecl/exceptions/standard_exception.hpp> 29 #include <ecl/errors/compile_time_assert.hpp> 30 #include <ecl/time/snooze.hpp> 31 #include <ecl/utilities/parameter.hpp> 32 #include <ecl/type_traits/fundamental_types.hpp> 33 #include "detail/error_handler.hpp" 34 #include "detail/exception_handler_pos.hpp" 35 #include "serial_parameters.hpp" 144 Serial() : is_open(false), error_handler(
NoError)
244 template <typename Byte>
257 template <typename Byte>
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
StandardException read_exception(const char *loc)
#define ecl_compile_time_assert(logical_expression)
#define ecl_throw_decl(exception)
Standard ecl throw exception declaration.
#define LOC
Stringify the line of code you are at.
The primary error handler for ecl libraries.
static bool const value
The value for this integral constant wrapper.
#define ecl_debug_throw_decl(exception)
Debug mode throw exception declaration.
StandardException write_exception(const char *loc)
#define ecl_debug_throw(exception)
Debug mode exception throw.