Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usb(NotFound) when receiving #9

Closed
luizribeiro opened this issue May 21, 2021 · 3 comments
Closed

Usb(NotFound) when receiving #9

luizribeiro opened this issue May 21, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@luizribeiro
Copy link

Hi! Thanks for your work on this library.

I've been trying to get it to work with macOS and I haven't been able to receive anything. rx() always gives me an Err(Usb(NotFound)), while device_version() seems to work correctly.

This is the basic example I've tried running:

use hackrfone::{HackRfOne, RxMode, UnknownMode};

fn main() {
    let radio: HackRfOne<UnknownMode> = HackRfOne::new().unwrap();
    println!("{:?}", radio.device_version());

    let mut radio: HackRfOne<RxMode> = radio.into_rx_mode().unwrap();
    radio.rx().unwrap();
}

Which gives me this output:

Version(1, 0, 4)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Usb(NotFound)', src/main.rs:8:16

I also tried your rx.rs example and got this:

Spawned sample thread
Sample thread disconnected
Shutting down sample thread
thread 'main' panicked at 'Failed to send exit event to sample thread: "SendError(..)"', src/main.rs:89:10

Have you encountered anything like this? Which platforms have you been able to test your library against?

@newAM
Copy link
Owner

newAM commented May 21, 2021

I have onky used Linux to test this out. Unfortunately I do not have any Mac platforms available so I cannot test it out with that :/

If the original libhackrf works then this should in theory also work because rusb is just a wrapper for libusb which is what libhackrf is using.

If I recall correctly the device version is reported in a header during USB negotiation, which may explain why the version works, but the RX endpoint does not.

As for the SendError that is probably just my crappy code 😅. It works for me in the positive path, but I have done zero testing with what happens when the sample thread stops before the main thread tells it to, which is probably the issue there.

Some TODOs for me:

  • Add tested platforms in README.
  • Fix example for negative path.

@newAM newAM added bug Something isn't working documentation Improvements or additions to documentation labels May 21, 2021
@newAM newAM self-assigned this May 21, 2021
@newAM
Copy link
Owner

newAM commented May 21, 2021

Took a look at the example failure, that's my crummy code, sorry about that!

A send operation can only fail if the receiving end of a channel is disconnected, implying that the data could never be received. The error contains the data being sent as a payload so it can be recovered.

If the sample thread ran up to here:

hackrfone/examples/rx.rs

Lines 36 to 42 in 4c7edbc

let sample_thread = thread::Builder::new()
.name("sample".to_string())
.spawn(move || -> Result<(), hackrfone::Error> {
println!("Spawned sample thread");
loop {
let samples: Vec<u8> = radio.rx()?;

Then failed at the rx()? it would disconnect and later result in the SendError being unwrapped.

@newAM newAM removed the documentation Improvements or additions to documentation label May 21, 2021
@newAM
Copy link
Owner

newAM commented Jul 6, 2021

Hopefully this is fixed by #12 (included in v0.2.1), going to close this issue for now, feel free to re-open if it occurs again.

@newAM newAM closed this as completed Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants