HID-to-UART driver for CP2110/CP2114 chipset.
It is wrapper around hid::Handle
intrinsically.
See documentation for details.
$ sudo apt-get install libudev-dev libhidapi-dev
$ cargo build
Requirements:
*-pc-windows-msvc
: VisualStudio 2015.*-pc-windows-gnu
: MinGW
$ cargo build --features build
``` rust extern crate hid; extern crate cp211x_uart;
use std::time::Duration; use cp211x_uart::{HidUart, UartConfig, DataBits, StopBits, Parity, FlowControl};
fn run() -> Result<(), cp211x_uart::Error> { let manager = hid::init()?; for device in manager.find(Some(0x10C4), Some(0xEA80)) { let handle = device.open()?; let mut uart = HidUart::new(handle)?;
let config = UartConfig {
baud_rate: 9600,
data_bits: DataBits::Bits8,
stop_bits: StopBits::Short,
parity: Parity::None,
flow_control: FlowControl::None,
};
uart.set_config(&config)?;
uart.set_read_timeout(Duration::from_millis(50));
uart.set_write_timeout(Duration::from_millis(500));
uart.flush_fifos(true, true)?;
uart.write(&[0x01, 0x02, 0x03][..])?;
let mut buf: [u8; 256] = [0; 256];
uart.read(&mut buf)?;
}
}
fn main() { match run() { Ok() => {} Err(err) => { eprintln!("ERROR: {}", err); } } } ```
This library licensed under the following: