@@ -269,6 +269,13 @@ unsafe fn fan_set(ec: &mut Ec<Box<dyn Access>>, index: u8, duty: u8) -> Result<(
269269 ec. fan_set ( index, duty)
270270}
271271
272+ unsafe fn fan_tach ( ec : & mut Ec < Box < dyn Access > > , index : u8 ) -> Result < ( ) , Error > {
273+ let tach = ec. fan_tach ( index) ?;
274+ println ! ( "{}" , tach) ;
275+
276+ Ok ( ( ) )
277+ }
278+
272279unsafe fn keymap_get ( ec : & mut Ec < Box < dyn Access > > , layer : u8 , output : u8 , input : u8 ) -> Result < ( ) , Error > {
273280 let value = ec. keymap_get ( layer, output, input) ?;
274281 println ! ( "{:04X}" , value) ;
@@ -312,6 +319,9 @@ enum SubCommand {
312319 index : u8 ,
313320 duty : Option < u8 > ,
314321 } ,
322+ FanTach {
323+ index : u8 ,
324+ } ,
315325 Flash {
316326 path : String ,
317327 } ,
@@ -377,8 +387,6 @@ struct Args {
377387}
378388
379389fn main ( ) {
380- //.subcommand(Command::new("security").arg(Arg::new("state").value_parser(["lock", "unlock"])))
381-
382390 let args = Args :: parse ( ) ;
383391
384392 let get_ec = || -> Result < _ , Error > {
@@ -404,7 +412,9 @@ fn main() {
404412 // System76 launch_2
405413 ( 0x3384 , 0x0006 , 1 ) |
406414 // System76 launch_heavy_1
407- ( 0x3384 , 0x0007 , 1 ) => {
415+ ( 0x3384 , 0x0007 , 1 ) |
416+ // System76 thelio_io_2
417+ ( 0x3384 , 0x000B , 1 ) => {
408418 let device = info. open_device ( & api) ?;
409419 let access = AccessHid :: new ( device, 10 , 100 ) ?;
410420 return Ok ( Ec :: new ( access) ?. into_dyn ( ) ) ;
@@ -451,6 +461,15 @@ fn main() {
451461 } ,
452462 }
453463 } ,
464+ SubCommand :: FanTach { index } => {
465+ match unsafe { fan_tach ( & mut ec, index) } {
466+ Ok ( ( ) ) => ( ) ,
467+ Err ( err) => {
468+ eprintln ! ( "failed to get fan {} tachometer: {:X?}" , index, err) ;
469+ process:: exit ( 1 ) ;
470+ } ,
471+ }
472+ } ,
454473 SubCommand :: Flash { path } => {
455474 match unsafe { flash ( & mut ec, & path, SpiTarget :: Main ) } {
456475 Ok ( ( ) ) => ( ) ,
0 commit comments