Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ categories = ["hardware-support"]
include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE"]

[dependencies]
hid = "^0.4.1"
hidapi = "^2.4.1"
error-chain = "^0.11.0"

[badges]
Expand Down
14 changes: 8 additions & 6 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
extern crate hid;
extern crate cp211x_uart;
extern crate hidapi;

use cp211x_uart::{DataBits, FlowControl, HidUart, Parity, StopBits, UartConfig};
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 manager = hidapi::HidApi::new()?;
for device_info in manager.device_list().filter(|device_info| {
device_info.vendor_id() == 0x10C4 && device_info.product_id() == 0xEA80
}) {
let handle = device_info.open_device(&manager)?;
let mut uart = HidUart::new(handle)?;

let config = UartConfig {
Expand Down Expand Up @@ -37,4 +39,4 @@ fn main() {
}
_ => {}
}
}
}
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error_chain! {
foreign_links {
HidError(::hid::Error);
HidError(::hidapi::HidError);
}

errors {
Expand All @@ -9,4 +9,4 @@ error_chain! {
display("write operation is time out")
}
}
}
}
Loading