| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
| 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "device/serial/serial_io_handler.h" | 12 #include "device/serial/serial_io_handler.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 // Linux reports breaks and parity errors by inserting the sequence '\377\0x' | 16 // Linux reports breaks and parity errors by inserting the sequence '\377\0x' |
| 17 // into the byte stream where 'x' is '\0' for a break and the corrupted byte for | 17 // into the byte stream where 'x' is '\0' for a break and the corrupted byte for |
| 18 // a parity error. | 18 // a parity error. |
| 19 enum class ErrorDetectState { NO_ERROR, MARK_377_SEEN, MARK_0_SEEN }; | 19 enum class ErrorDetectState { NO_ERROR, MARK_377_SEEN, MARK_0_SEEN }; |
| 20 | 20 |
| 21 class SerialIoHandlerPosix : public SerialIoHandler, | 21 class SerialIoHandlerPosix : public SerialIoHandler, |
| 22 public base::MessageLoopForIO::Watcher { | 22 public base::MessageLoopForIO::Watcher { |
| 23 protected: | 23 protected: |
| 24 // SerialIoHandler impl. | 24 // SerialIoHandler impl. |
| 25 void ReadImpl() override; | 25 void ReadImpl() override; |
| 26 void WriteImpl() override; | 26 void WriteImpl() override; |
| 27 void CancelReadImpl() override; | 27 void CancelReadImpl() override; |
| 28 void CancelWriteImpl() override; | 28 void CancelWriteImpl() override; |
| 29 bool ConfigurePortImpl() override; | 29 bool ConfigurePortImpl() override; |
| 30 bool PostOpen() override; |
| 30 bool Flush() const override; | 31 bool Flush() const override; |
| 31 serial::DeviceControlSignalsPtr GetControlSignals() const override; | 32 serial::DeviceControlSignalsPtr GetControlSignals() const override; |
| 32 bool SetControlSignals( | 33 bool SetControlSignals( |
| 33 const serial::HostControlSignals& control_signals) override; | 34 const serial::HostControlSignals& control_signals) override; |
| 34 serial::ConnectionInfoPtr GetPortInfo() const override; | 35 serial::ConnectionInfoPtr GetPortInfo() const override; |
| 35 bool SetBreak() override; | 36 bool SetBreak() override; |
| 36 bool ClearBreak() override; | 37 bool ClearBreak() override; |
| 37 int CheckReceiveError(char* buffer, | 38 int CheckReceiveError(char* buffer, |
| 38 int buffer_len, | 39 int buffer_len, |
| 39 int bytes_read, | 40 int bytes_read, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 bool parity_check_enabled_; | 73 bool parity_check_enabled_; |
| 73 char chars_stashed_[2]; | 74 char chars_stashed_[2]; |
| 74 int num_chars_stashed_; | 75 int num_chars_stashed_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); | 77 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 } // namespace device | 80 } // namespace device |
| 80 | 81 |
| 81 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 82 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
| OLD | NEW |