Chromium Code Reviews| 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..dcb46ba8a598754e0e58d02cf00e98662f01b3b5 100644 |
| --- a/device/serial/serial_io_handler_posix.h |
| +++ b/device/serial/serial_io_handler_posix.h |
| @@ -12,6 +12,12 @@ |
| namespace device { |
| +enum ByteRead { |
|
Reilly Grant (use Gerrit)
2015/07/28 22:06:03
These names still aren't very clear to me. Maybe s
juncai
2015/07/29 04:22:42
Done.
|
| + BYTEREAD_REGULAR, |
| + BYTEREAD_ALL_ONE, |
| + BYTEREAD_ALL_ZERO, |
| +}; |
| + |
| class SerialIoHandlerPosix : public SerialIoHandler, |
| public base::MessageLoopForIO::Watcher { |
| protected: |
| @@ -28,9 +34,67 @@ 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; |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, NoErrorReadOnce); |
|
Reilly Grant (use Gerrit)
2015/07/28 22:06:03
You can avoid adding all of these friend declarati
juncai
2015/07/29 04:22:41
Done.
|
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + NoErrorReadTwiceBytesReadTwoAndOne); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + NoErrorReadTwiceBytesReadOneAndTwo); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, NoErrorReadThreeTimes); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, BreakReadOnce); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + BreakReadTwiceBytesReadTwoAndOne); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + BreakReadTwiceBytesReadOneAndTwo); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, BreakReadThreeTimes); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, ParityErrorReadOnce); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityErrorReadTwiceBytesReadTwoAndOne); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityErrorReadTwiceBytesReadOneAndTwo); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, ParityErrorReadThreeTimes); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, TwoEOFsReadOnce); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, TwoEOFsReadTwice); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadOnce); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadTwiceBytesReadTwoAndOne); |
| + FRIEND_TEST_ALL_PREFIXES( |
| + SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadTwiceBytesReadTwoAndOneLargerBufferLen); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadTwiceBytesReadOneAndTwo); |
| + FRIEND_TEST_ALL_PREFIXES( |
| + SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadTwiceBytesReadOneAndTwoLargerBufferLen); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadThreeTimesBufferLenOne); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadThreeTimesBufferLenTwo); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + ParityCheckDisabledReadThreeTimesLargerBufferLen); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, BytesReadZero); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, InvalidSequenceReadOnce); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + InvalidSequenceReadTwiceBytesReadTwoAndOne); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + InvalidSequenceReadTwiceBytesReadOneAndTwo); |
| + FRIEND_TEST_ALL_PREFIXES( |
| + SerialIoHandlerPosixTest, |
| + InvalidSequenceReadTwiceBytesReadOneAndTwoLargerBufferLen); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + InvalidSequenceReadThreeTimes); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, |
| + InvalidSequenceReadThreeTimesLargerBufferLen); |
| + FRIEND_TEST_ALL_PREFIXES(SerialIoHandlerPosixTest, CharsIgnoredPreset); |
| SerialIoHandlerPosix( |
| scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| @@ -51,6 +115,11 @@ class SerialIoHandlerPosix : public SerialIoHandler, |
| bool is_watching_reads_; |
| bool is_watching_writes_; |
| + ByteRead byte_read_state_; |
| + bool parity_check_enabled_; |
| + char chars_ignored_[2]; |
| + int num_chars_ignored_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
| }; |