Skip to content

Commit

Permalink
feat: Merge monitor and monitor_with methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Nov 6, 2023
1 parent 6d6ca3d commit ef4c821
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
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
4 changes: 2 additions & 2 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 @@ -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

0 comments on commit ef4c821

Please sign in to comment.