Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ jobs:
${{ runner.os }}-

- name: Set up python builder
shell: bash
run: |
cargo make setup-builder
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Backend Benchmarks (Windows)
env:
Expand Down Expand Up @@ -156,8 +159,11 @@ jobs:
${{ runner.os }}-

- name: Set up python builder
shell: bash
run: |
cargo make setup-builder
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Checks
run: |
Expand Down Expand Up @@ -262,8 +268,11 @@ jobs:
${{ runner.os }}-

- name: Set up python builder
shell: bash
run: |
cargo make setup-builder
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build ${{ runner.os }} Binaries.
env:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

26 changes: 23 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ Get-ChildItem .\console_backend -Recurse -Include @("*.egg-info", "*.dist-info")
command = "${PYTHON}"
args = ["-m", "swiftnav_console.main", "${@}"]

[tasks.start-console-gdb]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How I've been debugging. Not sure if anyone has a better incantation but seems useful to have a command in the makefile for debugging

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could get python-pretty print for Rust using "rust-gdb".

command = "rust-gdb"
args = [
"-ex",
"run",
"--args",
"${PYTHON}",
"-m",
"swiftnav_console.main",
"${@}",
]

[tasks.qml-run]
dependencies = ["generate-resources"]
run_task = "start-console"
Expand All @@ -161,6 +173,16 @@ dependencies = [
]
run_task = "start-console"

[tasks.gdb-run]
dependencies = [
"copy-capnp",
"generate-resources",
"remove-egg-dist",
"store-version",
"install-backend",
]
run_task = "start-console-gdb"

[tasks.prod-run]
dependencies = [
"copy-capnp",
Expand Down Expand Up @@ -214,7 +236,6 @@ command = "${PYTHON}"
args = ["setup.py", "bdist_wheel"]

[tasks.get-get-pip]
condition = { files_not_exist = ["${WORKSPACE}/get-pip.py"] }
script_runner = "@duckscript"
script = '''
wget -O ./get-pip.py https://bootstrap.pypa.io/get-pip.py
Expand Down Expand Up @@ -248,7 +269,6 @@ cm_run_task generate-resources
'''

[tasks.prep-dist]
dependencies = ["get-standalone-py"]
script_runner = "@duckscript"
script = '''
cm_run_task copy-capnp
Expand Down Expand Up @@ -502,7 +522,7 @@ args = ["clippy", "--all-targets", "--", "--deny", "warnings"]
dependencies = ["store-version", "copy-capnp"]
command = "cargo"
cwd = "console_backend"
args = ["test", "--features", "tests", "--", "--nocapture"]
args = ["test", "--features", "tests", "${@}", "--", "--nocapture"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can run cargo make test <testname> to filter what tests to run


[tasks.rust-type-check]
dependencies = ["store-version", "copy-capnp"]
Expand Down
4 changes: 2 additions & 2 deletions console_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ minreq = { version = "2.4.2", features = ["https"] }
regex = { version = "1.5.4" }
semver = { version = "1" }
rust-ini = "0.17.0"
sbp = { version = "4.0", features = ["json", "link", "swiftnav"] }
sbp-settings = "0.1"
sbp = { version = "4.0.2", features = ["json", "link", "swiftnav"] }
sbp-settings = "0.2"
env_logger = { version = "0.9", optional = true }
mimalloc = { version = "0.1", default-features = false }

Expand Down
12 changes: 6 additions & 6 deletions console_backend/benches/cpu_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use std::{

extern crate console_backend;
use console_backend::{
connection::Connection,
common_constants::ConnectionState,
connection::{Connection, ConnectionManager},
process_messages,
shared_state::SharedState,
types::{ClientSender, RealtimeDelay},
Expand Down Expand Up @@ -51,23 +52,22 @@ fn run_process_messages(file_in_name: &str, failure: bool) {
assert!(iter_count > 0);
});
{
let (client_send_, client_recv) = channel::unbounded::<Vec<u8>>();
let (client_send, client_recv) = channel::unbounded::<Vec<u8>>();
let client_send = ClientSender::new(client_send);
client_recv_tx
.send(client_recv)
.expect("sending client recv handle should succeed");
if failure {
thread::sleep(time::Duration::from_millis(FAILURE_CASE_SLEEP_MILLIS));
}
let shared_state = SharedState::new();
let client_send = ClientSender::new(client_send_);
shared_state.set_running(true, client_send.clone());
shared_state.set_debug(true);
let conn = Connection::file(
let conn_manager = ConnectionManager::new(client_send, shared_state);
conn_manager.connect_to_file(
file_in_name.into(),
RealtimeDelay::Off,
/*close_when_done=*/ true,
);
process_messages::process_messages(conn, shared_state, client_send).unwrap();
}
recv_thread.join().expect("join should succeed");
}
Expand Down
8 changes: 4 additions & 4 deletions console_backend/src/bin/headless-console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use chrono::prelude::*;
use console_backend::{
cli_options::{handle_cli, CliOptions},
connection::ConnectionState,
connection::ConnectionManager,
log_panel::setup_logging,
server_recv_thread::server_recv_thread,
shared_state::SharedState,
Expand Down Expand Up @@ -30,11 +30,11 @@ Usage:
let client_send = ClientSender::new(client_send_);
setup_logging(client_send.clone(), true);
let shared_state = SharedState::new();
let connection_state = ConnectionState::new(client_send.clone(), shared_state.clone());
handle_cli(opt, &connection_state, shared_state.clone());
let conn_manager = ConnectionManager::new(client_send.clone(), shared_state.clone());
handle_cli(opt, &conn_manager, shared_state.clone());
refresh_navbar(&mut client_send.clone(), shared_state.clone());
refresh_loggingbar(&mut client_send.clone(), shared_state.clone());
server_recv_thread(connection_state, client_send, server_recv, shared_state);
server_recv_thread(conn_manager, client_send, server_recv, shared_state);

let mut msg_count: usize = 0;
while client_recv.recv().is_ok() {
Expand Down
12 changes: 6 additions & 6 deletions console_backend/src/cli_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::shared_state::SharedState;
use crate::types::{FlowControl, RealtimeDelay};
use crate::{
common_constants::{SbpLogging, Tabs},
connection::{Connection, ConnectionState},
connection::{Connection, ConnectionManager},
};

#[derive(Debug)]
Expand Down Expand Up @@ -262,26 +262,26 @@ fn is_baudrate(br: &str) -> Result<(), String> {
///
/// # Parameters
/// - `opt`: CLI Options to start specific connection type.
/// - `connection_state`: The Server state to start a specific connection.
/// - `conn_manager`: The Server state to start a specific connection.
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `shared_state`: The shared state for validating another connection is not already running.
pub fn handle_cli(opt: CliOptions, connection_state: &ConnectionState, shared_state: SharedState) {
pub fn handle_cli(opt: CliOptions, conn_manager: &ConnectionManager, shared_state: SharedState) {
if let Some(opt_input) = opt.input {
match opt_input {
Input::Tcp { host, port } => {
connection_state.connect_to_host(host, port);
conn_manager.connect_to_host(host, port);
}
Input::File { file_in } => {
let filename = file_in.display().to_string();
connection_state.connect_to_file(filename, RealtimeDelay::On, opt.exit_after);
conn_manager.connect_to_file(filename, RealtimeDelay::On, opt.exit_after);
}
Input::Serial {
serialport,
baudrate,
flow_control,
} => {
let serialport = serialport.display().to_string();
connection_state.connect_to_serial(serialport, baudrate, flow_control);
conn_manager.connect_to_serial(serialport, baudrate, flow_control);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions console_backend/src/common_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ pub enum Keys {
PREVIOUS_PORTS,
#[strum(serialize = "PREVIOUS_FILES")]
PREVIOUS_FILES,
#[strum(serialize = "CONNECTED")]
CONNECTED,
#[strum(serialize = "CONNECTION_STATE")]
CONNECTION_STATE,
#[strum(serialize = "PORT")]
PORT,
#[strum(serialize = "POS")]
Expand Down Expand Up @@ -282,9 +282,9 @@ pub enum Keys {
}

#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]
pub enum ApplicationStates {
#[strum(serialize = "CLOSE")]
CLOSE,
pub enum ConnectionState {
#[strum(serialize = "CLOSED")]
CLOSED,
#[strum(serialize = "CONNECTED")]
CONNECTED,
#[strum(serialize = "DISCONNECTED")]
Expand Down
Loading