Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: device/serial/serial_io_handler_posix.h

Issue 1249933004: Add code to detect new added ReceiveError on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments, changed variable name. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/device_tests.gyp ('k') | device/serial/serial_io_handler_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « device/device_tests.gyp ('k') | device/serial/serial_io_handler_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698