StopBits
One or two stops bits are reserved to end the communication.
enum StopBitsOne or two stops bits are reserved to end the communication.
enum StopBitsimport SwiftIOThe SwiftIO library allows you to access and control the hardware in an easy way.
final class UARTUART is a two-wire serial communication protocol used to communicate with serial devices. The devices must agree on a common transmisson rate before communication.
case oneBitcase twoBits@discardableResult func setBaudRate(_ baudRate: Int) -> Result<(), Errno> Sets the baud rate for communication. It should be set ahead of time to ensure the same baud rate between devices.
func getBaudRate() -> Int Gets the current baud rate for serial communication.
func checkBufferReceived() -> Int Returns the number of received data from the serial buffer.
@discardableResult func clearBuffer() -> Result<(), Errno> Clears all bytes from the buffer to store the incoming data.
enum DataBitsThe length of the data being transmitted.
enum ParityThe parity bit used to verify if data has changed during transmission. It counts the number of logical-high bits and see if it equals an odd or even number.
init(_ idName: Id, baudRate: Int = 115200, parity: Parity = .none, stopBits: StopBits = .oneBit, dataBits: DataBits = .eightBits, readBufferLength: Int = 1024) Initializes an interface for UART communication.
let obj: UnsafeMutableRawPointer@discardableResult func read(into buffer: inout [UInt8], count: Int? = nil, timeout: Int? = nil) -> Result<Int, Errno> Reads a specified amount of bytes from the external device.
@discardableResult func read(into buffer: UnsafeMutableRawBufferPointer, count: Int? = nil, timeout: Int? = nil) -> Result<Int, Errno> Reads a specified amount of bytes from the external device into the buffer pointer.
@discardableResult func read(into buffer: inout UInt8, timeout: Int? = nil) -> Result<Int, Errno> Reads a byte from the external device.
@discardableResult func write(_ byte: UInt8) -> Result<(), Errno> Writes a byte to the external device through the serial connection.
@discardableResult func write(_ string: String, addNullTerminator: Bool = false) -> Result<(), Errno> Writes a string to the external device through the serial connection.
@discardableResult func write(_ data: UnsafeRawBufferPointer, count: Int? = nil) -> Result<(), Errno> Writes buffer pointer of the data in the underlying storage to the external device.
@discardableResult func write(_ data: [UInt8], count: Int? = nil) -> Result<(), Errno> Writes a series of bytes to the external device through the serial connection.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.