blob: be9f4bea06f53f33f9251d4c6718054009b6f42d [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.serial;
using zx;
/// Description of what type of serial device this is
type Class = strict enum : uint8 {
GENERIC = 1;
/// A Bluetooth host controller
BLUETOOTH_HCI = 2;
/// An interactive console
CONSOLE = 3;
/// Kernel debug serial
KERNEL_DEBUG = 4;
};
/// Number of bits per character
type CharacterWidth = strict enum : uint8 {
BITS_5 = 1;
BITS_6 = 2;
BITS_7 = 3;
BITS_8 = 4;
};
/// Number of stop bits
type StopWidth = strict enum : uint8 {
BITS_1 = 1;
BITS_2 = 2;
};
/// Which parity computation to use, if any.
type Parity = strict enum : uint8 {
NONE = 1;
EVEN = 2;
ODD = 3;
};
/// What flow control mechanism to use
type FlowControl = strict enum : uint8 {
NONE = 1;
/// Clear To Send/Request To Send
CTS_RTS = 2;
};
type Config = struct {
character_width CharacterWidth;
stop_width StopWidth;
parity Parity;
control_flow FlowControl;
baud_rate uint32;
};
type SerialPortInfo = struct {
serial_class Class;
/// Vendor and product ID of hardware attached to this serial port,
/// or zero if not applicable.
serial_vid uint32;
serial_pid uint32;
};
/// A serial device.
closed protocol Device {
/// Lookup what type of serial device this is.
strict GetClass() -> (struct {
device_class Class;
});
/// Set the configuration of this serial device.
strict SetConfig(struct {
config Config;
}) -> (struct {
s zx.Status;
});
/// Reads data from the serial port.
strict Read() -> (struct {
data vector<uint8>:MAX;
}) error zx.Status;
/// Writes data to the serial port.
strict Write(struct {
data vector<uint8>:MAX;
}) -> () error zx.Status;
};
@discoverable
closed protocol DeviceProxy {
strict GetChannel(resource struct {
req server_end:Device;
});
};