Skip to content

Commit

Permalink
fix(pdi-scanner): use a smaller USB buffer in development (#5551)
Browse files Browse the repository at this point in the history
Closes #5541
  • Loading branch information
eventualbuddha authored Oct 24, 2024
1 parent 0d0e272 commit 5800d86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/pdi-scanner/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main() {
println!("cargo::rustc-check-cfg=cfg(production)");
println!("cargo:rerun-if-env-changed=NODE_ENV");

let is_production = match std::env::var("NODE_ENV") {
Ok(env) => env == "production",
Err(_) => false,
};

if is_production {
println!("cargo:rustc-cfg=production");
}
}
7 changes: 7 additions & 0 deletions libs/pdi-scanner/src/rust/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ impl Scanner {
/// bit trying to catch the paper, we might need a bit more. So for any
/// reasonable paper size, 4 MB should be plenty and doesn't really put
/// a dent in available memory.
#[cfg(production)]
const BUFFER_SIZE: usize = 4_194_304;

/// For development, we want a smaller buffer because, for reasons we
/// don't understand, communicating with the scanner times out with a
/// larger buffer.
#[cfg(not(production))]
const BUFFER_SIZE: usize = 16_384;

let (host_to_scanner_tx, host_to_scanner_rx) =
mpsc::channel::<(usize, packets::Outgoing)>();
let (host_to_scanner_ack_tx, host_to_scanner_ack_rx) = mpsc::channel::<usize>();
Expand Down

0 comments on commit 5800d86

Please sign in to comment.