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

Side by Side Diff: device/serial/serial_io_handler_posix.cc

Issue 2501613002: Explicitly put serial port fd in non-blocking mode on Chrome OS. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "device/serial/serial_io_handler_posix.h" 5 #include "device/serial/serial_io_handler_posix.h"
6 6
7 #include <sys/ioctl.h> 7 #include <sys/ioctl.h>
8 #include <termios.h> 8 #include <termios.h>
9 9
10 #include "base/files/file_util.h"
10 #include "base/posix/eintr_wrapper.h" 11 #include "base/posix/eintr_wrapper.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 13
13 #if defined(OS_LINUX) 14 #if defined(OS_LINUX)
14 #include <linux/serial.h> 15 #include <linux/serial.h>
15 16
16 // The definition of struct termios2 is copied from asm-generic/termbits.h 17 // The definition of struct termios2 is copied from asm-generic/termbits.h
17 // because including that header directly conflicts with termios.h. 18 // because including that header directly conflicts with termios.h.
18 extern "C" { 19 extern "C" {
19 struct termios2 { 20 struct termios2 {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (ioctl(file().GetPlatformFile(), IOSSIOSPEED, &bitrate) == -1) { 277 if (ioctl(file().GetPlatformFile(), IOSSIOSPEED, &bitrate) == -1) {
277 VPLOG(1) << "Failed to set custom baud rate"; 278 VPLOG(1) << "Failed to set custom baud rate";
278 return false; 279 return false;
279 } 280 }
280 } 281 }
281 #endif 282 #endif
282 283
283 return true; 284 return true;
284 } 285 }
285 286
287 bool SerialIoHandlerPosix::PostOpen() {
288 #if defined(OS_CHROMEOS)
289 // The Chrome OS permission broker does not open devices in async mode.
290 return base::SetNonBlocking(file().GetPlatformFile());
291 #else
292 return true;
293 #endif
294 }
295
286 SerialIoHandlerPosix::SerialIoHandlerPosix( 296 SerialIoHandlerPosix::SerialIoHandlerPosix(
287 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 297 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
288 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) 298 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
289 : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner), 299 : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner),
290 is_watching_reads_(false), 300 is_watching_reads_(false),
291 is_watching_writes_(false) { 301 is_watching_writes_(false) {
292 } 302 }
293 303
294 SerialIoHandlerPosix::~SerialIoHandlerPosix() { 304 SerialIoHandlerPosix::~SerialIoHandlerPosix() {
295 } 305 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 memcpy(buffer, chars_stashed_, std::min(new_bytes_read, 2)); 653 memcpy(buffer, chars_stashed_, std::min(new_bytes_read, 2));
644 memcpy(chars_stashed_, tmp, num_chars_stashed_); 654 memcpy(chars_stashed_, tmp, num_chars_stashed_);
645 return new_bytes_read; 655 return new_bytes_read;
646 } 656 }
647 657
648 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { 658 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) {
649 return port_name; 659 return port_name;
650 } 660 }
651 661
652 } // namespace device 662 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698