Skip to content

Commit

Permalink
commit before rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
rrasmuss4200 committed Sep 12, 2024
1 parent 5d125f2 commit 0fef3f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ex3_ground_station/cli_ground_station/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async fn main() {

eprintln!("Connecting to Coms handler via TCP at {ipaddr}...");

let mut tcp_interface = match TcpInterface::new_client(ipaddr.to_string(), SIM_UHF_GS_PORT) {
let mut tcp_interface = match TcpInterface::new_client(ipaddr.to_string(), ports::SIM_COMMS_PORT) {
Ok(ti) => ti,
Err(e) => {
eprintln!("Can't connect to satellite: {e}");
Expand Down
15 changes: 7 additions & 8 deletions ex3_obc_fsw/handlers/coms_handler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,17 @@ fn main() {

//Setup interface for comm with UHF transceiver [ground station] (TCP for now)
let mut tcp_interface =
TcpInterface::new_client("127.0.0.1".to_string(), ports::SIM_COMMS_PORT).unwrap();
TcpInterface::new_server("127.0.0.1".to_string(), ports::SIM_COMMS_PORT).unwrap();

//Setup interface for comm with OBC FSW components (IPC), for the purpose of passing messages to and from the GS
let mut ipc_gs_interface;
let ipc_gs_interface_res = IpcClient::new("gs_bulk".to_string());
if ipc_gs_interface_res.is_err() {
warn!(
"Error creating IPC interface: {:?}",
ipc_gs_interface_res.err()
);
return;
if let Err(e) = ipc_gs_interface_res {
warn!("Error creating IPC interface: {e}");
} else {
ipc_gs_interface = ipc_gs_interface_res.unwrap();

}
let mut ipc_gs_interface = ipc_gs_interface_res.unwrap();

//Setup interface for comm with OBC FSW components (IPC), for passing messages to and from the UHF specifically
// TODO - name this to gs_handler once uhf handler and gs handler are broken up from this program.
Expand Down
22 changes: 13 additions & 9 deletions ex3_shared_libs/interfaces/ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use nix::libc;
use nix::sys::socket::{self, accept, bind, listen, socket, Backlog, AddressFamily, SockFlag, SockType, UnixAddr};
use nix::unistd::{read, write};
use std::ffi::CString;
use nix::errno::Errno;
use std::io::Error as IoError;
use std::os::fd::{AsFd, AsRawFd, FromRawFd, OwnedFd, RawFd};
use std::path::Path;
Expand Down Expand Up @@ -46,7 +47,7 @@ impl IpcClient {
Ok(client)
}

fn connect_to_server(&mut self) -> Result<(), IoError> {
fn connect_to_server(&mut self) -> Result<(), Errno> {
let socket_path_c_str = CString::new(self.socket_path.clone()).unwrap();
let addr = UnixAddr::new(socket_path_c_str.as_bytes()).unwrap_or_else(|err| {
eprintln!("Failed to create UnixAddr: {}", err);
Expand All @@ -57,14 +58,17 @@ impl IpcClient {
self.socket_path
);
let fd: RawFd = self.fd.as_raw_fd();
socket::connect(fd, &addr).unwrap_or_else(|err| {
eprintln!("Failed to connect to server socket: {}", err);
process::exit(1)
});
println!("Connected to server socket at: {}", self.socket_path);
self.connected = true;

Ok(())
match socket::connect(fd, &addr) {
Ok(()) => {
println!("Connected to server socket at: {}", self.socket_path);
self.connected = true;
Ok(())
}
Err(e) => {
eprintln!("Failed to connect to server socket: {}", e);
Err(e)
}
}
}

/// Users of this lib can call this to clear the buffer - otherwise the preivous read data will remain
Expand Down

0 comments on commit 0fef3f6

Please sign in to comment.