File tree Expand file tree Collapse file tree 5 files changed +78
-0
lines changed
Expand file tree Collapse file tree 5 files changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ ALS: 76 Lux
139139 Fan Speed: 0 RPM
140140```
141141
142+
142143## Check expansion bay (Framework 16)
143144
144145```
@@ -149,4 +150,23 @@ Expansion Bay
149150 Hatch closed: true
150151 Board: DualInterposer
151152 Serial Number: FRAXXXXXXXXXXXXXXX
153+
154+ ## Check charger and battery status (Framework 12/13/16)
155+
156+ ```
157+ > sudo framework_tool --power
158+ Charger Status
159+ AC is: not connected
160+ Charger Voltage: 17048mV
161+ Charger Current: 0mA
162+ Chg Input Current:384mA
163+ Battery SoC: 93%
164+ Battery Status
165+ AC is: not connected
166+ Battery is: connected
167+ Battery LFCC: 3693 mAh (Last Full Charge Capacity)
168+ Battery Capacity: 3409 mAh
169+ 58.96 Wh
170+ Charge level: 92%
171+ Battery discharging
152172```
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ pub enum EcCommands {
4040 I2cPassthrough = 0x009e ,
4141 ConsoleSnapshot = 0x0097 ,
4242 ConsoleRead = 0x0098 ,
43+ ChargeState = 0x00A0 ,
4344 /// List the features supported by the firmware
4445 GetFeatures = 0x000D ,
4546 /// Force reboot, causes host reboot as well
Original file line number Diff line number Diff line change @@ -377,6 +377,38 @@ impl EcRequest<()> for EcRequestConsoleRead {
377377 }
378378}
379379
380+ #[ repr( u8 ) ]
381+ pub enum ChargeStateCmd {
382+ GetState = 0 ,
383+ GetParam ,
384+ SetParam ,
385+ NumCmds ,
386+ }
387+
388+ #[ repr( C , packed) ]
389+ pub struct EcRequestChargeStateGetV0 {
390+ pub cmd : u8 ,
391+ pub param : u32 ,
392+ }
393+
394+ #[ repr( C , packed) ]
395+ pub struct EcResponseChargeStateGetV0 {
396+ pub ac : u32 ,
397+ pub chg_voltage : u32 ,
398+ pub chg_current : u32 ,
399+ pub chg_input_current : u32 ,
400+ pub batt_state_of_charge : u32 ,
401+ }
402+
403+ impl EcRequest < EcResponseChargeStateGetV0 > for EcRequestChargeStateGetV0 {
404+ fn command_id ( ) -> EcCommands {
405+ EcCommands :: ChargeState
406+ }
407+ fn command_version ( ) -> u8 {
408+ 0
409+ }
410+ }
411+
380412/// Supported features
381413#[ derive( Debug , FromPrimitive ) ]
382414pub enum EcFeatureCode {
Original file line number Diff line number Diff line change @@ -1083,6 +1083,29 @@ impl CrosEc {
10831083 }
10841084 }
10851085
1086+ pub fn get_charge_state ( & self ) -> EcResult < ( ) > {
1087+ let res = EcRequestChargeStateGetV0 {
1088+ cmd : ChargeStateCmd :: GetState as u8 ,
1089+ param : 0 ,
1090+ }
1091+ . send_command ( self ) ?;
1092+ println ! ( "Charger Status" ) ;
1093+ println ! (
1094+ " AC is: {}" ,
1095+ if res. ac == 1 {
1096+ "connected"
1097+ } else {
1098+ "not connected"
1099+ }
1100+ ) ;
1101+ println ! ( " Charger Voltage: {}mV" , { res. chg_voltage } ) ;
1102+ println ! ( " Charger Current: {}mA" , { res. chg_current } ) ;
1103+ println ! ( " Chg Input Current:{}mA" , { res. chg_input_current } ) ;
1104+ println ! ( " Battery SoC: {}%" , { res. batt_state_of_charge } ) ;
1105+
1106+ Ok ( ( ) )
1107+ }
1108+
10861109 /// Check features supported by the firmware
10871110 pub fn get_features ( & self ) -> EcResult < ( ) > {
10881111 let data = EcRequestGetFeatures { } . send_command ( self ) ?;
Original file line number Diff line number Diff line change @@ -471,6 +471,7 @@ pub fn is_standalone(ec: &CrosEc) -> bool {
471471}
472472
473473pub fn get_and_print_power_info ( ec : & CrosEc ) -> i32 {
474+ print_err_ref ( & ec. get_charge_state ( ) ) ;
474475 if let Some ( power_info) = power_info ( ec) {
475476 print_battery_information ( & power_info) ;
476477 if let Some ( _battery) = & power_info. battery {
@@ -481,6 +482,7 @@ pub fn get_and_print_power_info(ec: &CrosEc) -> i32 {
481482}
482483
483484fn print_battery_information ( power_info : & PowerInfo ) {
485+ println ! ( "Battery Status" ) ;
484486 print ! ( " AC is: " ) ;
485487 if power_info. ac_present {
486488 println ! ( "connected" ) ;
You can’t perform that action at this time.
0 commit comments