Skip to content

Commit

Permalink
Enable separate input and output driver types
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed Nov 7, 2023
1 parent b1c415a commit 131ab60
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ struct Options {
/// The interface to read traffic from
///
/// Can be either a string interface name, or an integer interface index
#[clap(short, long, default_value_t = String::from("can0"))]
#[clap(short = 'i', long, default_value_t = String::from("can0"))]
pub input_interface: String,

/// The interface to write traffic to
///
/// Can be either a string interface name, or an integer interface index
#[clap(short, long, default_value_t = String::from("can1"))]
#[clap(short = 'o', long, default_value_t = String::from("can1"))]
pub output_interface: String,

#[clap(short, long)]
pub driver: CanDriver,
/// The driver type to use for the input
#[clap(short = 'I', long)]
pub input_driver: CanDriver,

/// The driver type to use for the output
#[clap(short = 'O', long)]
pub output_driver: CanDriver,
}

fn create_driver(iface: &str, driver: CanDriver) -> Box<dyn Driver> {
Expand Down Expand Up @@ -106,8 +111,8 @@ fn main() {
opts.output_interface
);

let mut input = create_driver(&opts.input_interface, opts.driver.clone());
let mut output = create_driver(&opts.output_interface, opts.driver);
let mut input = create_driver(&opts.input_interface, opts.input_driver);
let mut output = create_driver(&opts.output_interface, opts.output_driver);

input.open().unwrap();
output.open().unwrap();
Expand Down

0 comments on commit 131ab60

Please sign in to comment.