Skip to content

Commit 8247cae

Browse files
Merge pull request #107 from FrameworkComputer/expansion-bay-info
Add --expansion-bay command to print info
2 parents c8de3f1 + defcaa3 commit 8247cae

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

EXAMPLES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,15 @@ ALS: 76 Lux
138138
APU: 42 C
139139
Fan Speed: 0 RPM
140140
```
141+
142+
## Check expansion bay (Framework 16)
143+
144+
```
145+
> sudo framework_tool --expansion-bay
146+
Expansion Bay
147+
Enabled: true
148+
Has fault: false
149+
Hatch closed: true
150+
Board: DualInterposer
151+
Serial Number: FRAXXXXXXXXXXXXXXX
152+
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ Options:
181181
--inputmodules Show status of the input modules (Framework 16 only)
182182
--input-deck-mode <INPUT_DECK_MODE>
183183
Set input deck power mode [possible values: auto, off, on] (Framework 16 only) [possible values: auto, off, on]
184+
--expansion-bay Show status of the expansion bay (Framework 16 only)
184185
--charge-limit [<CHARGE_LIMIT>]
185186
Get or set max charge limit
186187
--get-gpio <GET_GPIO>

framework_lib/src/chromium_ec/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,27 @@ impl CrosEc {
817817
res
818818
}
819819

820+
pub fn check_bay_status(&self) -> EcResult<()> {
821+
println!("Expansion Bay");
822+
823+
let info = EcRequestExpansionBayStatus {}.send_command(self)?;
824+
println!(" Enabled: {}", info.module_enabled());
825+
println!(" Has fault: {}", info.module_fault());
826+
println!(" Hatch closed: {}", info.hatch_switch_closed());
827+
match info.expansion_bay_board() {
828+
Ok(board) => println!(" Board: {:?}", board),
829+
Err(err) => println!(" Board: {:?}", err),
830+
}
831+
832+
if let Ok(sn) = self.get_gpu_serial() {
833+
println!(" Serial Number: {}", sn);
834+
} else {
835+
println!(" Serial Number: Unknown");
836+
}
837+
838+
Ok(())
839+
}
840+
820841
/// Get the GPU Serial
821842
///
822843
pub fn get_gpu_serial(&self) -> EcResult<String> {

framework_lib/src/commandline/clap_std.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ struct ClapCli {
147147
#[arg(long)]
148148
input_deck_mode: Option<InputDeckModeArg>,
149149

150+
/// Show status of the expansion bay (Framework 16 only)
151+
#[arg(long)]
152+
expansion_bay: bool,
153+
150154
/// Get or set max charge limit
151155
#[arg(long)]
152156
charge_limit: Option<Option<u8>>,
@@ -352,6 +356,7 @@ pub fn parse(args: &[String]) -> Cli {
352356
intrusion: args.intrusion,
353357
inputmodules: args.inputmodules,
354358
input_deck_mode: args.input_deck_mode,
359+
expansion_bay: args.expansion_bay,
355360
charge_limit: args.charge_limit,
356361
get_gpio: args.get_gpio,
357362
fp_led_level: args.fp_led_level,

framework_lib/src/commandline/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub struct Cli {
173173
pub intrusion: bool,
174174
pub inputmodules: bool,
175175
pub input_deck_mode: Option<InputDeckModeArg>,
176+
pub expansion_bay: bool,
176177
pub charge_limit: Option<Option<u8>>,
177178
pub get_gpio: Option<String>,
178179
pub fp_led_level: Option<Option<FpBrightnessArg>>,
@@ -761,6 +762,10 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
761762
} else if let Some(mode) = &args.input_deck_mode {
762763
println!("Set mode to: {:?}", mode);
763764
ec.set_input_deck_mode((*mode).into()).unwrap();
765+
} else if args.expansion_bay {
766+
if let Err(err) = ec.check_bay_status() {
767+
error!("{:?}", err);
768+
}
764769
} else if let Some(maybe_limit) = args.charge_limit {
765770
print_err(handle_charge_limit(&ec, maybe_limit));
766771
} else if let Some(gpio_name) = &args.get_gpio {
@@ -1080,6 +1085,7 @@ Options:
10801085
--intrusion Show status of intrusion switch
10811086
--inputmodules Show status of the input modules (Framework 16 only)
10821087
--input-deck-mode Set input deck power mode [possible values: auto, off, on] (Framework 16 only)
1088+
--expansion-bay Show status of the expansion bay (Framework 16 only)
10831089
--charge-limit [<VAL>] Get or set battery charge limit (Percentage number as arg, e.g. '100')
10841090
--get-gpio <GET_GPIO> Get GPIO value by name
10851091
--fp-led-level [<VAL>] Get or set fingerprint LED brightness level [possible values: high, medium, low]

framework_lib/src/commandline/uefi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn parse(args: &[String]) -> Cli {
8686
intrusion: false,
8787
inputmodules: false,
8888
input_deck_mode: None,
89+
expansion_bay: false,
8990
charge_limit: None,
9091
get_gpio: None,
9192
fp_led_level: None,
@@ -247,6 +248,9 @@ pub fn parse(args: &[String]) -> Cli {
247248
None
248249
};
249250
found_an_option = true;
251+
} else if arg == "--expansion-bay" {
252+
cli.expansion_bay = true;
253+
found_an_option = true;
250254
} else if arg == "--charge-limit" {
251255
cli.charge_limit = if args.len() > i + 1 {
252256
if let Ok(percent) = args[i + 1].parse::<u8>() {

0 commit comments

Comments
 (0)