Skip to content

Commit

Permalink
feat: Add server CLI binary
Browse files Browse the repository at this point in the history
  • Loading branch information
DNedic committed Feb 15, 2024
1 parent 4d6ef83 commit 6dd355b
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: Build std
run: cargo build --verbose --no-default-features --features=std
- name: Build no_std
run: cargo build --verbose --no-default-features
run: cargo build --verbose --lib --no-default-features
- name: Run tests
run: cargo test --verbose
214 changes: 214 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ keywords = [

[dependencies]
serialport = { version = "4.2.0", optional = true, default-features = false }
clap = { version = "4.5", optional = true, features = ["derive"] }

[features]
default = ["std"]
std = ["serialport"]
std = ["serialport", "clap"]
23 changes: 23 additions & 0 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use clap::Parser;
use std::net::IpAddr;
use rfc2217_rs::Server;

#[derive(Parser, Debug)]
struct Args {
#[clap(long = "serial_port", short = 'p', default_value = "/dev/ttyUSB0")]
serial_port: String,
#[clap(long = "address", short = 'a', default_value = "127.0.0.1")]
address: IpAddr,
#[clap(long = "tcp_port", default_value = "7878")]
tcp_port: u16,
}

fn main() {
let Args { address, tcp_port, serial_port } = Args::parse();

let mut server = Server::new(&serial_port, (address, tcp_port)).unwrap();

loop {
server.run().unwrap();
}
}

0 comments on commit 6dd355b

Please sign in to comment.