ftdi-rs / ftdi-embedded-hal

Implementation of Rust Embedded HAL traits for FTDI devices
MIT License
36 stars 14 forks source link

hal::FtHal::init_freq(device, 400_000)? expected `Error`, found `TimeoutError` #53

Open circuit4u-medium opened 3 months ago

circuit4u-medium commented 3 months ago

after let device = libftd2xx::Ft232h::with_description("USB <-> Serial Converter")?; then let hal = hal::FtHal::init_freq(device, 400_000)?;

got this error message

image

newAM commented 3 months ago

Can you share the full code, and which version of this crate you are using?

This is similar to code that gets tested in lib.rs, it should work.

circuit4u-medium commented 3 months ago

Thanks for the quick reply. Yes, cargo run the code in examples folder doesn't have any issue.

I was trying to run Rust code in a Jupyter notebook interactively. Here are the snippets:

image

newAM commented 3 months ago

Can you try :dep ftdi-embbeded-hal = { version = "0.22.0", features = ["libftd2xx", "libftd2xx-static"] }?

I'm not sure how the resolver works in jupyter, it might not have enabled those.

circuit4u-medium commented 3 months ago

Thanks for the advice. I think the issue is resolved, but now there seems to be a new one: image

newAM commented 3 months ago

That's from the underlying libftd2xx driver. Never seen that one before myself. libftd2xx is closed source; you can debug as far as the driver call, which is probably worthwhile to check the handle (pointer) is reasonable. There's also logging in the rust wrapper for the driver which will log the pointer.

If you're on Linux then the open source drivers are worth a try (requires different feature flags). The open source drivers are easier to debug.