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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright 2014 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.
module device.serial;
import "data_stream.mojom";
struct DeviceInfo {
string path;
uint16 vendor_id;
bool has_vendor_id = false;
uint16 product_id;
bool has_product_id = false;
string? display_name;
};
enum SendError {
NONE,
DISCONNECTED,
PENDING,
TIMEOUT,
SYSTEM_ERROR,
};
enum ReceiveError {
NONE,
DISCONNECTED,
TIMEOUT,
DEVICE_LOST,
SYSTEM_ERROR,
};
enum DataBits {
NONE,
SEVEN,
EIGHT,
};
enum ParityBit {
NONE,
NO,
ODD,
EVEN,
};
enum StopBits {
NONE,
ONE,
TWO,
};
struct ConnectionOptions {
uint32 bitrate = 0;
DataBits data_bits = NONE;
ParityBit parity_bit = NONE;
StopBits stop_bits = NONE;
bool cts_flow_control;
bool has_cts_flow_control = false;
};
struct ConnectionInfo {
uint32 bitrate = 0;
DataBits data_bits = NONE;
ParityBit parity_bit = NONE;
StopBits stop_bits = NONE;
bool cts_flow_control;
};
struct HostControlSignals {
bool dtr;
bool has_dtr = false;
bool rts;
bool has_rts = false;
};
struct DeviceControlSignals {
bool dcd;
bool cts;
bool ri;
bool dsr;
};
interface SerialService {
GetDevices() => (array<DeviceInfo> devices);
// Creates a |Connection| to |path| with options specified by |options|,
// returning it via |connection|. Sending and receiving data over this
// connection is handled by |sink| and |source|, respectively. This will fail
// and |connection| will not be usable if |path| does not specify a valid
// serial device or there is an error connecting to or configuring the
// connection.
Connect(string path,
ConnectionOptions? options,
Connection& connection,
DataSink& sink,
DataSource& source);
};
interface Connection {
GetInfo() => (ConnectionInfo? info);
SetOptions(ConnectionOptions options) => (bool success);
SetControlSignals(HostControlSignals signals) => (bool success);
GetControlSignals() => (DeviceControlSignals? signals);
Flush() => (bool success);
};
|