-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rowan/feature/make nix work with dispatcher #47
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
6687044
Cmd_dispatcher initial checkin
rcunrau d005c45
Rebase
rcunrau 46c83db
tentative changes to ex3_shared_libs
rcunrau 91e9a11
Fix warnings and errors
rcunrau 1c2779c
Fixes to jump table and nix::write
rcunrau 3b8438a
Work in progress. Trying to make tall thin work with new dispatcher
rrasmuss4200 2fc0560
Work in progress. Plan to get rid of buffer field in IpcServer to mak…
rrasmuss4200 2fef474
commit before rebase
rrasmuss4200 2c2ccb0
cmd_disp, cli_gs and coms_hand all compile and work with new nix. yaya
rrasmuss4200 abc79b1
Added debugging statements and changed order of coms bootup
rrasmuss4200 a77e072
TMP test changes to try and get whole pipeline setup
rrasmuss4200 3c38c9f
For some reason, COMS pipeline only accepts in coms_hand after TCP co…
rrasmuss4200 f904def
Fixed index err in cmd_disp.
rrasmuss4200 49ce9b3
rebase cleanup
rrasmuss4200 af83657
Able to pass data from GS to cmd_disp
rrasmuss4200 3b851e6
Fixed buffer it's reading from
rrasmuss4200 dd660a9
Cmd disp can receive and read dest_id. Now need to incorporate handlers
rrasmuss4200 f3379c0
Took accept out of server initialization in coms_handler
rrasmuss4200 8067b7c
restructure bulk disp to be purely a server
rrasmuss4200 299c365
CAN SEND STUFFFFFF
rrasmuss4200 9bf8e53
cleanup
rrasmuss4200 798d424
Can only uplink w/ BulkMsgDisp
rrasmuss4200 7686b23
UPLINK TO DFGM :))))
rrasmuss4200 2e6dde7
TMP changed script to work. will include iris when working
rrasmuss4200 61533dc
Downlink works but continues indefinitly.
rrasmuss4200 b4bd587
Attempt at fixing downlink. Swapping to making all compile
rrasmuss4200 c0ca7dd
make dev tools compile
rrasmuss4200 d24fc00
Iris compiles
rrasmuss4200 1e646e6
shell compile
rrasmuss4200 22769c9
rm warnings
rrasmuss4200 0076adc
fix component casting test
rrasmuss4200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "cmd_dispatcher" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
strum = { version = "0.26", features = ["derive"] } | ||
strum_macros = "0.26" | ||
nix = { version = "0.29.0", features = ["socket"] } | ||
ipc = { path = "../../ex3_shared_libs/interfaces/ipc" } | ||
common = {path = "../../ex3_shared_libs/common"} | ||
message_structure = { path = "../../ex3_shared_libs/message_structure" } | ||
logging = { path = "../../ex3_shared_libs/logging" } | ||
log = "0.4.22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
use nix::unistd::{write, close}; | ||
use nix::Error; | ||
use strum::IntoEnumIterator; | ||
use std::os::fd::{AsFd, AsRawFd}; | ||
|
||
use ipc::{poll_ipc_clients, IpcClient, IPC_BUFFER_SIZE}; | ||
use common::component_ids::ComponentIds; | ||
use message_structure::MsgHeader; | ||
|
||
fn main() { | ||
let component_streams: Vec<Option<IpcClient>> = | ||
ComponentIds::iter().enumerate().map(|(i,c)| { | ||
println!("{i}"); | ||
match IpcClient::new(format!("{c}")) { | ||
Ok(client) => { | ||
Some(client) | ||
} | ||
Err(e) => { | ||
eprintln!("msg dispatcher couldn't connect to {}: {}", c, e); | ||
None | ||
}, | ||
} | ||
}).collect(); | ||
|
||
for x in 0..ComponentIds::LAST as usize { | ||
let payload = match ComponentIds::try_from(x as u8) { | ||
Ok(p) => { | ||
eprintln!("x {} yields {}", x, p); | ||
p | ||
}, | ||
Err(()) => { | ||
eprintln!("x {} didn't convert", x); | ||
continue; | ||
} | ||
}; | ||
match component_streams.get(x) { | ||
Some(element) => match element { | ||
Some(_e) => { | ||
println!("{} connected", payload); | ||
} | ||
None => { | ||
println!("{} not connected!", payload); | ||
} | ||
}, | ||
None => println!("bad index {}", x), | ||
}; | ||
} | ||
|
||
let mut cmd_client = match IpcClient::new("cmd_dispatcher".to_string()) { | ||
Ok(s) => Some(s), | ||
Err(e) => { | ||
eprintln!("Server connection error: {}", e); | ||
return; // Should fix it and retry | ||
} | ||
}; | ||
|
||
loop { | ||
let mut clients = vec![&mut cmd_client]; | ||
let (_s,_bytes) = match poll_ipc_clients(&mut clients) { | ||
Ok((bytes, sock)) => (bytes,sock), | ||
Err(e) => { | ||
eprintln!("read error: {}", e); | ||
let _ = close(cmd_client.as_ref().unwrap().fd.as_raw_fd()); | ||
continue; // try again | ||
} | ||
}; | ||
if cmd_client.as_ref().unwrap().buffer != [0u8; IPC_BUFFER_SIZE] { | ||
println!("Got cmd: {:?}", cmd_client.as_ref().unwrap().buffer); | ||
let dest = cmd_client.as_ref().unwrap().buffer[MsgHeader::DEST_INDEX]; | ||
let res = match ComponentIds::try_from(dest) { | ||
Ok(payload) => { | ||
match &component_streams[dest as usize] { | ||
Some(client) => { | ||
println!("Writing buffer {:?}", cmd_client.as_ref().unwrap().buffer); | ||
write(client.fd.as_fd(), &cmd_client.as_ref().unwrap().buffer) | ||
}, | ||
None => { | ||
eprintln!("No payload: {payload}!"); | ||
Err(Error::EPIPE) | ||
} | ||
} | ||
}, | ||
Err(_) => { | ||
eprintln!("Invalid payload: {dest}"); | ||
Err(Error::EINVAL) | ||
} | ||
}; | ||
|
||
if res.is_err() { | ||
eprintln!("Dispatch failed: NACKing"); | ||
// Should actually NACK | ||
} | ||
cmd_client.as_mut().unwrap().clear_buffer(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "SIM"?