a1ien / rusb

A safe Rust wrapper for libusb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Err: Busy

chrontax opened this issue · comments

i constantly get

thread 'main' panicked at src/main.rs:27:40:
called `Result::unwrap()` on an `Err` value: Busy

with this code

use std::time::Duration;

use rusb::Direction;

fn main() {
    let mut uwu = rusb::open_device_with_vid_pid(0x5844, 0x0000).unwrap();
    let owo = uwu.device();
    let mut conf = 0;
    let mut ifn = 0;
    let mut set = 0;
    let mut ep = 0;
    for i in 0..owo.device_descriptor().unwrap().num_configurations() {
        for i in owo.config_descriptor(i).unwrap().interfaces() {
            for d in i.descriptors() {
                for e in d.endpoint_descriptors() {
                    if e.direction() == Direction::Out {
                        conf = i.number();
                        ifn = d.interface_number();
                        set = d.setting_number();
                        ep = e.address();
                    }
                }
            }
        }
    }

    uwu.set_active_configuration(conf).unwrap();
    uwu.claim_interface(ifn).unwrap();
    uwu.set_alternate_setting(ifn, set).unwrap();

    uwu.write_interrupt(ep, b"boot", Duration::from_secs(1))
        .unwrap();
}

please help T_T

You can try to search by LIBUSB_ERROR_BUSY in internet. Probably some driver or other application already open this device

The issue is probably that a driver cdc_acm has opened the device, but I have no idea how I could solve this.

Nevermind, seems I wasn't looking for a usb library, but a serial library