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

Side by Side Diff: chrome/browser/extensions/api/serial/serial_connection_posix.cc

Issue 10961009: Use cfsetispeed and cfsetospeed helpers to set bitrate. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/serial/serial_connection.h" 5 #include "chrome/browser/extensions/api/serial/serial_connection.h"
6 6
7 #include <sys/ioctl.h> 7 #include <sys/ioctl.h>
8 #include <termios.h> 8 #include <termios.h>
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 bool SerialConnection::PostOpen() { 12 bool SerialConnection::PostOpen() {
13 struct termios options; 13 struct termios options;
14 14
15 // Start with existing options and modify. 15 // Start with existing options and modify.
16 tcgetattr(file_, &options); 16 tcgetattr(file_, &options);
17 17
18 // Bitrate (sometimes erroneously referred to as baud rate). 18 // Bitrate (sometimes erroneously referred to as baud rate).
19 if (bitrate_ >= 0) { 19 if (bitrate_ >= 0) {
20 options.c_ispeed = bitrate_; 20 cfsetispeed(&options, bitrate_);
21 options.c_ospeed = bitrate_; 21 cfsetospeed(&options, bitrate_);
22 } 22 }
23 23
24 // 8N1 24 // 8N1
25 options.c_cflag &= ~PARENB; 25 options.c_cflag &= ~PARENB;
26 options.c_cflag &= ~CSTOPB; 26 options.c_cflag &= ~CSTOPB;
27 options.c_cflag &= ~CSIZE; 27 options.c_cflag &= ~CSIZE;
28 options.c_cflag |= CS8; 28 options.c_cflag |= CS8;
29 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 29 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
30 30
31 // Enable receiver and set local mode 31 // Enable receiver and set local mode
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (control_signals.rts) 65 if (control_signals.rts)
66 status |= TIOCM_RTS; 66 status |= TIOCM_RTS;
67 else 67 else
68 status &= ~TIOCM_RTS; 68 status &= ~TIOCM_RTS;
69 } 69 }
70 70
71 return ioctl(file_, TIOCMSET, &status) == 0; 71 return ioctl(file_, TIOCMSET, &status) == 0;
72 } 72 }
73 73
74 } // namespace extensions 74 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698