Skip to content

Instantly share code, notes, and snippets.

@meh
Created April 22, 2016 17:27
Show Gist options
  • Save meh/0a2297429542f2819fa364dde4339d3e to your computer and use it in GitHub Desktop.
Save meh/0a2297429542f2819fa364dde4339d3e to your computer and use it in GitHub Desktop.
#[doc(hidden)]
#[cfg(target_os = "linux")]
pub fn details_raw(&mut self) -> Res<([u8; 64], [u8; 64])> {
let mut first = [0u8; 64];
first[0] = 0x83;
try!(self.handle.write_control(0x21, 0x09, 0x0300, self.index, &first, Duration::from_secs(0)));
try!(self.handle.read_control(0xa1, 0x01, 0x0300, self.index, &mut first, Duration::from_secs(0)));
let mut second = [0u8; 64];
second[0] = 0xba;
try!(self.handle.write_control(0x21, 0x09, 0x0300, self.index, &second, Duration::from_secs(0)));
try!(self.handle.read_control(0xa1, 0x01, 0x0300, self.index, &mut second, Duration::from_secs(0)));
Ok((first, second))
}
#[doc(hidden)]
#[cfg(not(target_os = "linux"))]
pub fn details_raw(&mut self) -> Res<([u8; 64], [u8; 64])> {
let mut first = [0u8; 65];
first[1] = 0x83;
try!(self.handle.feature().send(&first));
try!(self.handle.feature().get(&mut first));
let mut second = [0u8; 65];
second[1] = 0xba;
try!(self.handle.feature().send(&second));
try!(self.handle.feature().get(&mut second));
Ok((first[1..], second[1..]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment