Index: device/serial/serial_io_handler_posix.h |
diff --git a/device/serial/serial_io_handler_posix.h b/device/serial/serial_io_handler_posix.h |
index c9c5fb5416472c0d7edae75c630705cf2f3e49df..5050d2304fe21b3365b8c9c3ca3f25dac46389ae 100644 |
--- a/device/serial/serial_io_handler_posix.h |
+++ b/device/serial/serial_io_handler_posix.h |
@@ -12,6 +12,11 @@ |
namespace device { |
+// Linux reports breaks and parity errors by inserting the sequence '\377\0x' |
+// into the byte stream where 'x' is '\0' for a break and the corrupted byte for |
+// a parity error. |
+enum class ErrorDetectState { NO_ERROR, MARK_377_SEEN, MARK_0_SEEN }; |
+ |
class SerialIoHandlerPosix : public SerialIoHandler, |
public base::MessageLoopForIO::Watcher { |
protected: |
@@ -28,9 +33,15 @@ class SerialIoHandlerPosix : public SerialIoHandler, |
serial::ConnectionInfoPtr GetPortInfo() const override; |
bool SetBreak() override; |
bool ClearBreak() override; |
+ int CheckReceiveError(char* buffer, |
+ int buffer_len, |
+ int bytes_read, |
+ bool& break_detected, |
+ bool& parity_error_detected); |
private: |
friend class SerialIoHandler; |
+ friend class SerialIoHandlerPosixTest; |
SerialIoHandlerPosix( |
scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
@@ -51,6 +62,11 @@ class SerialIoHandlerPosix : public SerialIoHandler, |
bool is_watching_reads_; |
bool is_watching_writes_; |
+ ErrorDetectState error_detect_state_; |
+ bool parity_check_enabled_; |
+ char chars_stashed_[2]; |
+ int num_chars_stashed_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
}; |