ar-drivers-rs icon indicating copy to clipboard operation
ar-drivers-rs copied to clipboard

For XReal Air 1/Air 2 Pro on Windows, its IMU HID Device aways timeout on the first command to turn off IMU stream

Open tribbloid opened this issue 1 year ago • 11 comments

Just started testing it on Windows (x86 processor, running read_sensors example), both the glasses HID & IMU HID devices can be found. But on initialisation, read_timeout will return 0 bit of data (debugging screenshot attached)

image

this will lead to the following error:

thread 'main' panicked at examples\read_sensors.rs:8:37:
called `Result::unwrap()` on an `Err` value: NotFound
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:647
   1: core::panicking::panic_fmt
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\result.rs:1649
   3: enum2$<core::result::Result<alloc::boxed::Box<dyn$<ar_drivers::ARGlasses>,alloc::alloc::Global>,enum2$<ar_drivers::Error> > >::unwrap
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\result.rs:1073
   4: read_sensors::main
             at .\examples\read_sensors.rs:8
   5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\ops\function.rs:250
   6: core::hint::black_box
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\hint.rs:334
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I wonder if you have seen similar things on Windows? Is there a configuration I have to set before using it?

tribbloid avatar Apr 24 '24 01:04 tribbloid

I also have the same issue using the XReal Air 2 Pro. The same code works on Mac OS but not Windows.

shiptomorrow avatar Apr 24 '24 13:04 shiptomorrow

I have to admit, I never tried the code on windows.

This seems like an issue with the hidapi crate, and should probably be debugged there. It might be worthwhile to try the new-ish windows-native feature flag on it: https://www.reddit.com/r/rust/comments/192aa3h/comment/kh6h8lu/

badicsalex avatar Apr 24 '24 15:04 badicsalex

Tried with hidapi 2.6.1 (where the reddit comment issue was already fixed) with windows-native feature enabled but still get the same error.

shiptomorrow avatar Apr 24 '24 17:04 shiptomorrow

@SimDoes thanks, just changed the title.

hidapi-rs only has 1 unit test, which runs successfully but doesn't show much. That's my only attempt to fix it so far :-< Will try to compile & test the C library later

tribbloid avatar Apr 24 '24 18:04 tribbloid

there are 2 rust runtime in Windows: one built on MSVC (which I used for test) and the other on GCC

@SimDoes are you also using the MSVC one?

tribbloid avatar May 03 '24 17:05 tribbloid

there are 2 rust runtime in Windows: one built on MSVC (which I used for test) and the other on GCC

@SimDoes are you also using the MSVC one?

To be honest I have no clue, all I know is that I tried with windows-native feature flag enabled/not for hidapi-rs. Source code here might help.

shiptomorrow avatar May 07 '24 11:05 shiptomorrow

This fixed Rokid Max on windows for me. Can someone confirm Xreal:

https://github.com/3rl-io/headset-utils/commit/1afb8794a1d55d28a8b4d43ba8c445eacd0c40ce

kkota1 avatar Jun 06 '24 23:06 kkota1

@kkota1 It's really weird that "not detaching" the kernel driver helps. I don't really know what that even means on windows, because I never dove that deep into libusb.

Which driver are you using?

badicsalex avatar Jun 07 '24 08:06 badicsalex

@badicsalex the error message was something like “that method does not exist” so libusb for windows doesn’t have it . I forked peng’s fusion code and made some changes in the repo linked above

kkota1 avatar Jun 07 '24 14:06 kkota1

I'll test XReal Air 1 on Windows in the weekend, thanks a lot @kkota1 !

tribbloid avatar Jun 07 '24 18:06 tribbloid

nope, got the same error:

can't find RokidAir: Glasses not found
can't find NrealAir: Packet timeout
can't find NrealLight: Hidapi error
can't find GrawoowG530: Glasses not found
can't find MadGazeGlow: Glasses not found
Glasses not found

The problem is always IMU, not the glasses itself.

tribbloid avatar Jun 10 '24 19:06 tribbloid