| // 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 { |
| |
| 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() => (DeviceInfo[] devices); |
| |
| // Creates a |Connection| to |path| with options specified by |options|, |
| // returning it via |connection|. 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); |
| }; |
| |
| interface Connection { |
| GetInfo() => (ConnectionInfo info); |
| SetOptions(ConnectionOptions options) => (bool success); |
| SetControlSignals(HostControlSignals signals) => (bool success); |
| GetControlSignals() => (DeviceControlSignals signals); |
| Flush() => (bool success); |
| }; |
| |
| } |