Skip to content

Commit

Permalink
Use default port if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Aug 9, 2023
1 parent 72da20f commit 58ab28d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# - name: Install dependencies
# run: sudo apt-get install -y protobuf-compiler

- name: Show environment
run: rustup show

Expand Down
8 changes: 4 additions & 4 deletions glonax-input/src/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub(crate) struct Gamepad {
}

impl Gamepad {
pub(crate) async fn new(path: &Path) -> Self {
Self {
driver: glonax_gamepad::AsyncGamepad::new(path).await.unwrap(),
pub(crate) async fn new(path: &Path) -> std::io::Result<Self> {
Ok(Self {
driver: glonax_gamepad::AsyncGamepad::new(path).await?,
node_path: path.to_path_buf(),
reverse_left: false,
reverse_right: false,
}
})
}
}

Expand Down
14 changes: 10 additions & 4 deletions glonax-input/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async fn main() -> anyhow::Result<()> {
}

async fn daemonize(config: &config::InputConfig) -> anyhow::Result<()> {
let mut input_device = gamepad::Gamepad::new(std::path::Path::new(&config.device)).await;
let mut input_device = gamepad::Gamepad::new(std::path::Path::new(&config.device)).await?;

let mut input_state = input::InputState {
drive_lock: false,
Expand All @@ -109,11 +109,17 @@ async fn daemonize(config: &config::InputConfig) -> anyhow::Result<()> {
log::info!("Motion is locked on startup");
}

log::debug!("Waiting for connection to {}", config.address.clone());
let host = if !config.address.contains(':') {
config.address.to_owned() + ":30051"
} else {
config.address.to_owned()
};

log::debug!("Waiting for connection to {}", host);

let stream = tokio::net::TcpStream::connect(config.address.clone()).await?;
let stream = tokio::net::TcpStream::connect(&host).await?;

log::info!("Connected to {}", config.address.clone());
log::info!("Connected to {}", host);

let mut protocol = glonax::transport::Protocol::new(stream);

Expand Down

0 comments on commit 58ab28d

Please sign in to comment.