Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / device / serial / serial.mojom
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
3 // found in the LICENSE file.
4
5 module device.serial {
6
7 struct DeviceInfo {
8   string path;
9   uint16 vendor_id;
10   bool has_vendor_id = false;
11   uint16 product_id;
12   bool has_product_id = false;
13   string display_name;
14 };
15
16 enum SendError {
17   NONE,
18   DISCONNECTED,
19   PENDING,
20   TIMEOUT,
21   SYSTEM_ERROR,
22 };
23
24 enum ReceiveError {
25   NONE,
26   DISCONNECTED,
27   TIMEOUT,
28   DEVICE_LOST,
29   SYSTEM_ERROR,
30 };
31
32 enum DataBits {
33   NONE,
34   SEVEN,
35   EIGHT,
36 };
37
38 enum ParityBit {
39   NONE,
40   NO,
41   ODD,
42   EVEN,
43 };
44
45 enum StopBits {
46   NONE,
47   ONE,
48   TWO,
49 };
50
51 struct ConnectionOptions {
52   uint32 bitrate = 0;
53   DataBits data_bits = NONE;
54   ParityBit parity_bit = NONE;
55   StopBits stop_bits = NONE;
56   bool cts_flow_control;
57   bool has_cts_flow_control = false;
58 };
59
60 struct ConnectionInfo {
61   uint32 bitrate = 0;
62   DataBits data_bits = NONE;
63   ParityBit parity_bit = NONE;
64   StopBits stop_bits = NONE;
65   bool cts_flow_control;
66 };
67
68 struct HostControlSignals {
69   bool dtr;
70   bool has_dtr = false;
71   bool rts;
72   bool has_rts = false;
73 };
74
75 struct DeviceControlSignals {
76   bool dcd;
77   bool cts;
78   bool ri;
79   bool dsr;
80 };
81
82 interface SerialService {
83   GetDevices() => (DeviceInfo[] devices);
84
85   // Creates a |Connection| to |path| with options specified by |options|,
86   // returning it via |connection|. This will fail and |connection| will not be
87   // usable if |path| does not specify a valid serial device or there is an
88   // error connecting to or configuring the connection.
89   Connect(string path,
90           ConnectionOptions options,
91           Connection& connection);
92 };
93
94 interface Connection {
95   GetInfo() => (ConnectionInfo info);
96   SetOptions(ConnectionOptions options) => (bool success);
97   SetControlSignals(HostControlSignals signals) => (bool success);
98   GetControlSignals() => (DeviceControlSignals signals);
99   Flush() => (bool success);
100 };
101
102 }