Skip to content
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

Update log-format flag and merge monitor methods #499

Merged
merged 2 commits into from
Nov 15, 2023
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
10 changes: 5 additions & 5 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use clap::{Args, CommandFactory, Parser, Subcommand};
use espflash::{
cli::{
self, board_info, completions, config::Config, connect, erase_flash, erase_partitions,
erase_region, flash_elf_image, monitor::monitor_with, parse_partition_table,
partition_table, print_board_info, save_elf_as_image, serial_monitor, CompletionsArgs,
ConnectArgs, EraseFlashArgs, EraseRegionArgs, EspflashProgress, FlashConfigArgs,
MonitorArgs, PartitionTableArgs,
erase_region, flash_elf_image, monitor::monitor, parse_partition_table, partition_table,
print_board_info, save_elf_as_image, serial_monitor, CompletionsArgs, ConnectArgs,
EraseFlashArgs, EraseRegionArgs, EspflashProgress, FlashConfigArgs, MonitorArgs,
PartitionTableArgs,
},
error::Error as EspflashError,
image_format::ImageFormatKind,
Expand Down Expand Up @@ -342,7 +342,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
115_200
};

monitor_with(
monitor(
flasher.into_interface(),
Some(&elf_data),
pid,
Expand Down
4 changes: 2 additions & 2 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::{Args, CommandFactory, Parser, Subcommand};
use espflash::{
cli::{
self, board_info, completions, config::Config, connect, erase_flash, erase_partitions,
erase_region, flash_elf_image, monitor::monitor_with, parse_partition_table, parse_uint32,
erase_region, flash_elf_image, monitor::monitor, parse_partition_table, parse_uint32,
partition_table, print_board_info, save_elf_as_image, serial_monitor, CompletionsArgs,
ConnectArgs, EraseFlashArgs, EraseRegionArgs, EspflashProgress, FlashConfigArgs,
MonitorArgs, PartitionTableArgs,
Expand Down Expand Up @@ -264,7 +264,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
115_200
};

monitor_with(
monitor(
flasher.into_interface(),
Some(&elf_data),
pid,
Expand Down
8 changes: 4 additions & 4 deletions espflash/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use serialport::{SerialPortType, UsbPortInfo};

use self::{
config::Config,
monitor::{monitor_with, LogFormat},
monitor::{monitor, LogFormat},
serial::get_serial_port_info,
};
use crate::{
Expand Down Expand Up @@ -142,7 +142,7 @@ pub struct FlashArgs {
#[arg(long)]
pub ram: bool,
/// Logging format.
#[arg(long, short = 'f', default_value = "serial", requires = "monitor")]
#[arg(long, short = 'L', default_value = "serial", requires = "monitor")]
pub log_format: LogFormat,
}

Expand Down Expand Up @@ -199,7 +199,7 @@ pub struct MonitorArgs {
#[clap(flatten)]
connect_args: ConnectArgs,
/// Logging format.
#[arg(long, short = 'f', default_value = "serial")]
#[arg(long, short = 'L', default_value = "serial")]
pub log_format: LogFormat,
}

Expand Down Expand Up @@ -307,7 +307,7 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> {
115_200
};

monitor_with(
monitor(
flasher.into_interface(),
elf.as_deref(),
pid,
Expand Down
12 changes: 1 addition & 11 deletions espflash/src/cli/monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,8 @@ impl Drop for RawModeGuard {
}
}

/// Open a serial monitor on the given interface
pub fn monitor(
serial: Interface,
elf: Option<&[u8]>,
pid: u16,
baud: u32,
) -> serialport::Result<()> {
monitor_with(serial, elf, pid, baud, LogFormat::Serial)
}

/// Open a serial monitor on the given interface, using the given input parser.
pub fn monitor_with(
pub fn monitor(
mut serial: Interface,
elf: Option<&[u8]>,
pid: u16,
Expand Down