Skip to content

Commit

Permalink
Fix some more timing issues in USB drivers
Browse files Browse the repository at this point in the history
In combination with slow USB hubs or KVM switches, some drivers
apparently fail to initialize due to too strict timing constraints.
So be more lenient with timings, and increase the time we wait between
issuing of commands.

Fix some more timing issues

Referencs #161
  • Loading branch information
X3n0m0rph59 committed Oct 11, 2022
1 parent 6745d9e commit afaf816
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions eruption/src/hwdevices/roccat_elo_71_air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::time::Duration;
use std::{any::Any, thread};
use std::{mem::size_of, sync::Arc};

use crate::constants;
use crate::constants::{self, DEVICE_SETTLE_MILLIS};

use super::{
DeviceCapabilities, DeviceInfoTrait, DeviceStatus, DeviceTrait, HwDeviceError, MiscDevice,
Expand Down Expand Up @@ -203,7 +203,7 @@ impl RoccatElo71Air {
Err(_) => return Err(HwDeviceError::InvalidResult {}.into()),
}

// thread::sleep(Duration::from_millis(10));
// thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

// let mut buf: [u8; 64] = [0x00; 64];
// buf[0] = 0xa1;
Expand Down Expand Up @@ -237,7 +237,7 @@ impl RoccatElo71Air {
Err(_) => return Err(HwDeviceError::InvalidResult {}.into()),
};

thread::sleep(Duration::from_millis(10));
thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

let buf: [u8; 64] = [
0xff, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand All @@ -256,7 +256,7 @@ impl RoccatElo71Air {
Err(_) => return Err(HwDeviceError::InvalidResult {}.into()),
};

thread::sleep(Duration::from_millis(10));
thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

let buf: [u8; 64] = [
0xff, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand All @@ -275,7 +275,7 @@ impl RoccatElo71Air {
Err(_) => return Err(HwDeviceError::InvalidResult {}.into()),
};

thread::sleep(Duration::from_millis(10));
thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

let buf: [u8; 64] = [
0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -322,8 +322,12 @@ impl RoccatElo71Air {

#[allow(clippy::if_same_then_else)]
if buf[1] == 0x00 || buf[0..5] == [0xe6, 0x06, 0x03, 0x00, 0x04] {
thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

Ok(())
} else if buf[0..4] == [0xa1, 0x84, 0x06, 0x02] {
thread::sleep(Duration::from_millis(DEVICE_SETTLE_MILLIS));

Ok(()) // directly after device reset
} else {
hexdump::hexdump_iter(&buf).for_each(|s| debug!(" {}", s));
Expand Down

0 comments on commit afaf816

Please sign in to comment.