hidapi-rs icon indicating copy to clipboard operation
hidapi-rs copied to clipboard

Error sending data: hidapi error: IOHIDDeviceSetReport failed: (0xE0005000) unknown error code #749

Open aliduchuy-dev97 opened this issue 6 months ago • 0 comments

Hi, guys! I have a problem when sending data to HID devices; it always returns an error: "Error sending data: hidapi error: IOHIDDeviceSetReport failed: (0xE0005000) unknown error code." This error only appears on macOS, while Windows is good.

This is my code:

use hidapi::HidApi;

fn main() -> Result<(), Box> {
let api = HidApi::new()?;

let device = api.open(0x0909, 0x0053);

println!("Opening device...");

match device {
    Ok(dev) => {
        println!("Device opened successfully");

        let mut report: Vec<u8>= vec![0x00,0x40, 0x01, 0x01];
        report.resize(64, 0);

        println!("Report buffer: {:?}", report);

        println!("Sending report...");

        let result = dev.send_feature_report(&report);

        match result {
            Ok(_) => println!("Data sent successfully"),
            Err(e) => eprintln!("Error sending data: {}", e),
        }

        let mut buf = [0u8; 64];
        let bytes_read = dev.read_timeout(&mut buf, 500); // timeout 5 giây

        match bytes_read {
            Ok(bytes) => println!("Read {} bytes", bytes),
            Err(e) => eprintln!("Error reading data: {}", e),
        }

        
        println!("Device closed successfully");

    }
    Err(e) => {
        eprintln!("Failed to open device: {}", e);
        return Err(Box::new(e));
    }
}


Ok(())
}

Please help me! Thanks, all.

aliduchuy-dev97 avatar Jun 02 '25 10:06 aliduchuy-dev97