blob: 79b020f984b897846fdf623e926697c337199f22 [file] [log] [blame]
// Copyright 2018 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.serialimpl;
using zx;
using fuchsia.hardware.serial;
// Start of `flags` that can be passed to Config.
// Select the character width
const SERIAL_DATA_BITS_5 uint32 = 0x0;
const SERIAL_DATA_BITS_6 uint32 = 0x1;
const SERIAL_DATA_BITS_7 uint32 = 0x2;
const SERIAL_DATA_BITS_8 uint32 = 0x3;
const SERIAL_DATA_BITS_MASK uint32 = 0x3;
// Select the number of stop bits
const SERIAL_STOP_BITS_1 uint32 = 0x0;
const SERIAL_STOP_BITS_2 uint32 = 0x4;
const SERIAL_STOP_BITS_MASK uint32 = 0x4;
// Select the parity mechanism
const SERIAL_PARITY_NONE uint32 = 0x00;
const SERIAL_PARITY_EVEN uint32 = 0x08;
const SERIAL_PARITY_ODD uint32 = 0x10;
const SERIAL_PARITY_MASK uint32 = 0x18;
// Select the flow control mechanism
const SERIAL_FLOW_CTRL_NONE uint32 = 0x00;
const SERIAL_FLOW_CTRL_CTS_RTS uint32 = 0x20;
const SERIAL_FLOW_CTRL_MASK uint32 = 0x20;
// Set this flag to change baud rate but leave other properties unchanged
const SERIAL_SET_BAUD_RATE_ONLY uint32 = 0x80000000;
// End of `flags` that can be passed to Config.
type SerialState = strict bits : uint32 {
READABLE = 0x1;
WRITABLE = 0x2;
};
@transport("Driver")
open protocol Device {
flexible GetInfo() -> (struct {
info fuchsia.hardware.serial.SerialPortInfo;
}) error zx.Status;
/// Configures the given serial port.
/// Values of `flags` are defined in the constants above.
flexible Config(struct {
baud_rate uint32;
flags uint32;
}) -> () error zx.Status;
/// Enable or disable the device.
/// If already enabled and `enable` is true, this is a no-op and returns successfully.
/// If already disabled and `enable` is false, this is a no-op and returns successfully.
flexible Enable(struct {
enable bool;
}) -> () error zx.Status;
/// Do a read operation. If there is already one in progress this returns a
/// ZX_ERR_NOT_SUPPORTED.
/// The `CancelAll` method can be used to cancel a Read, which will result in a
/// ZX_ERR_CANCELED error to be returned.
/// Returns the read data when the read is completed successfully.
flexible Read() -> (struct {
data vector<uint8>:MAX;
}) error zx.Status;
/// Do a write operation. If there is already one in progress this returns a
/// ZX_ERR_NOT_SUPPORTED.
/// The `CancelAll` method can be used to cancel a Write, which will result in a
/// ZX_ERR_CANCELED error to be returned.
/// Returns when the write is completed successfully.
flexible Write(struct {
data vector<uint8>:MAX;
}) -> () error zx.Status;
/// Event for notification of readable/writeable state changes
flexible -> OnSerialStateChanged(struct {
state SerialState;
});
/// Immediately cancels all outstanding asynchronous I/O
flexible CancelAll() -> ();
};
service Service {
device client_end:Device;
};