blob: 2ce28cf0c9cb1141a3f17b097c65f33034359f1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/serial/serial_connection.h"
#include <termios.h>
namespace extensions {
bool SerialConnection::PostOpen() {
struct termios options;
// Start with existing options and modify.
tcgetattr(file_, &options);
// Bitrate 57,600
cfsetispeed(&options, B57600);
cfsetospeed(&options, B57600);
// 8N1
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
// Enable receiver and set local mode
// See http://www.easysw.com/~mike/serial/serial.html to understand.
options.c_cflag |= (CLOCAL | CREAD);
// Write the options.
tcsetattr(file_, TCSANOW, &options);
return true;
}
} // namespace extensions
|