Skip to content

Commit ac814cb

Browse files
authored
Merge pull request #43 from firefly-zero/logs
WIP Add logs command
2 parents 21646f3 + afe9848 commit ac814cb

File tree

10 files changed

+381
-51
lines changed

10 files changed

+381
-51
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ jobs:
8585
cargo -V
8686
rustc -V
8787
88-
- name: Build
89-
shell: bash
88+
- run: sudo apt install -qq -y libudev-dev
89+
- shell: bash
9090
run: $BUILD_CMD build --release --target=${{ matrix.job.target }}
9191

9292
- name: Set binary name & path

.github/workflows/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- uses: arduino/setup-task@v1
2323
with:
2424
repo-token: ${{ github.token }}
25+
- run: sudo apt install -qq -y libudev-dev
2526
- run: task test
2627

2728
lint:
@@ -34,6 +35,7 @@ jobs:
3435
- uses: arduino/setup-task@v1
3536
with:
3637
repo-token: ${{ github.token }}
38+
- run: sudo apt install -qq -y libudev-dev
3739
- run: task lint
3840

3941
markdownlint-cli:

Cargo.lock

+126-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ anyhow = "1.0.95"
2424
chrono = { version = "0.4.39", default-features = false, features = ["clock"] }
2525
# Framework for parsing CLI args
2626
clap = { version = "4.5.29", features = ["derive"] }
27+
# Detect message boundaries in serial port output from device
28+
cobs = "0.3.0"
2729
# TUI for the "monitor" command, colored terminal output
2830
crossterm = "0.28.1"
2931
# Convert binary hash into hex
3032
data-encoding = "2.8.0"
3133
# Find the best place to sotre the VFS
3234
directories = "6.0.0"
3335
# Serialize app config into meta file in the ROM
34-
firefly-types = { version = "0.5.0" }
36+
firefly-types = { version = "0.5.1" }
3537
# Decode wav files
3638
hound = "3.5.1"
3739
# Parse PNG images
@@ -52,6 +54,7 @@ rustyline = "15.0.0"
5254
serde = { version = "1.0.217", features = ["serde_derive", "derive"] }
5355
# Deserialize JSON API responses from the firefly catalog.
5456
serde_json = "1.0.138"
57+
serialport = "4.7.0"
5558
# Calculate file checksum
5659
sha2 = "0.10.8"
5760
# Deserialize firefly.toml

src/args.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ pub enum Commands {
5757
/// Show runtime stats for a running device (or emulator).
5858
Monitor(MonitorArgs),
5959

60+
/// Show live runtime logs from a running device.
61+
Logs(LogsArgs),
62+
6063
/// Inspect contents of the ROM: files, metadata, wasm binary.
6164
Inspect(InspectArgs),
6265

@@ -244,7 +247,22 @@ pub struct EmulatorArgs {
244247
}
245248

246249
#[derive(Debug, Parser)]
247-
pub struct MonitorArgs {}
250+
pub struct MonitorArgs {
251+
#[arg(long, default_value = None)]
252+
pub port: Option<String>,
253+
254+
#[arg(long, default_value_t = 115_200)]
255+
pub baud_rate: u32,
256+
}
257+
258+
#[derive(Debug, Parser)]
259+
pub struct LogsArgs {
260+
#[arg(long)]
261+
pub port: String,
262+
263+
#[arg(long, default_value_t = 115_200)]
264+
pub baud_rate: u32,
265+
}
248266

249267
#[derive(Debug, Parser)]
250268
pub struct InspectArgs {

src/cli.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub fn run_command(vfs: PathBuf, command: &Commands) -> anyhow::Result<()> {
1414
Commands::Boards(args) => cmd_boards(&vfs, args),
1515
Commands::Cheat(args) => cmd_cheat(args),
1616
Commands::Monitor(args) => cmd_monitor(&vfs, args),
17+
Commands::Logs(args) => cmd_logs(args),
1718
Commands::Inspect(args) => cmd_inspect(&vfs, args),
1819
Commands::Repl(args) => cmd_repl(&vfs, args),
1920
Commands::Key(KeyCommands::New(args)) => cmd_key_new(&vfs, args),

src/commands/build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::path::{Path, PathBuf};
3030
static TIPS: &[&str] = &[
3131
"keep an eye on the binary size: bigger binary often means slower code",
3232
"if the app hits `unreachable`, use `log_debug` to find out where",
33-
"you can use build_args option in firefly.toml to customize the build command",
33+
"you can use `build_args` option in `firefly.toml` to customize the build command",
3434
"if your game has multiple levels/scenes, use a separate sprite file for each",
3535
"prefer using 32 bit float over 64 bit float",
3636
"using shapes instead of sprites might save memory and improve performance",
@@ -46,6 +46,7 @@ static TIPS: &[&str] = &[
4646
"you can customize TinyGo build with a custom target.json in the project root",
4747
"make sure to test your game with multiplayer",
4848
"images using 4 or less colors are twice smaller",
49+
"when debugging an app, call `set_seed` in `boot` to make the randomness predictable",
4950
// covering CLI subcommands
5051
"you can use `wasm2wat` and `firefly_cli inspect` to inspect the app binary",
5152
"use `firefly_cli export` to share the app with your friends",

0 commit comments

Comments
 (0)