Skip to content

Commit

Permalink
cir decode should try all protocols if none are specified
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed May 23, 2024
1 parent 3257ac0 commit 1631dd0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Necessary:
correct protocol numbers

Nice to have:
- cir decode irp should try all protocols if nothing specified
- pcmak leading gap not decoded
- encoding toggle_bit_mask not used when popcount > 1
- compare against kernel encoder/decoder
Expand Down
4 changes: 2 additions & 2 deletions cir/src/bin/cir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ struct Decode {
rawir: Vec<String>,

/// IRP Notation
#[arg(long = "irp", short = 'i', required_unless_present = "keymap")]
#[arg(long = "irp", short = 'i')]
irp: Vec<String>,

/// Keymap or lircd.conf file
#[arg(long = "keymap", short = 'k', required_unless_present = "irp")]
#[arg(long = "keymap", short = 'k')]
keymap: Vec<PathBuf>,

#[clap(flatten)]
Expand Down
28 changes: 28 additions & 0 deletions cir/src/bin/commands/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,34 @@ pub fn decode(global: &crate::App, decode: &crate::Decode) {
}
}

if decode.irp.is_empty() && decode.keymap.is_empty() {
match get_irp_protocols(&global.irp_protocols) {
Ok(res) => {
irp_protocols_xml = res;
}
Err(e) => {
log::error!("{}: {e}", &global.irp_protocols.display());
std::process::exit(2);
}
}

for protocol in irp_protocols_xml.iter().filter(|e| {
e.decodable && e.irp != "{38.4k,msb,564}<1,-1|1,-3>(16,-8,data:length,-50m) "
}) {
log::debug!("decoding IRP: {} {}", protocol.name, protocol.irp);

let irp = match Irp::parse(&protocol.irp) {
Ok(m) => m,
Err(s) => {
eprintln!("unable to parse irp ‘{}’: {s}", protocol.irp);
std::process::exit(2);
}
};

irps.push((&protocol.name, &protocol.irp, irp));
}
}

let input_on_cli = !decode.file.is_empty() || !decode.rawir.is_empty();

#[cfg(target_os = "linux")]
Expand Down

0 comments on commit 1631dd0

Please sign in to comment.