Skip to content

Add serial ports config file #777

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Feb 18, 2025

Don't really like the way I solved this as it's basically a bunch of duplicated code, but not sure if there's any better way.

Draft until I do some more testing and/or I find a better solution.

Example espflash_ports.toml file:

[connection]
serial = "/dev/ttyUSB0"

@SergioGasquez SergioGasquez linked an issue Feb 18, 2025 that may be closed by this pull request
@jessebraham
Copy link
Member

Not sure this is the path we want to take to be honest. Had some other ideas I've been meaning to explore, so let's sit on this for awhile please.

@SergioGasquez SergioGasquez force-pushed the feat/connections-file branch from 697ae3d to a31daef Compare March 27, 2025 11:39
@SergioGasquez SergioGasquez force-pushed the feat/connections-file branch from a31daef to 6cc02c4 Compare May 21, 2025 10:28
@SergioGasquez SergioGasquez marked this pull request as ready for review May 21, 2025 13:20
@JurajSadel
Copy link
Contributor

I wonder if we can test this somehow in HIL

@MabezDev
Copy link
Member

It seems to me that we can avoid the code duplication by loading the two things separately then combining them again in code. We just need to be careful when saving the config again to write out the config back to the two separate files. After that, I think this becomes a relatively simple change?

Here is a small snippet to explain what I mean:

// package both together for code locality reasons, but they are seperate configs which are saved seperately
struct Config {
  config: ProjectConfig, // currently this is Config, let's rename it
  port_config: PortConfiguration // user port config
} 

What do you think?

pub connection: Connection,
/// Preferred USB devices
#[serde(default)]
pub usb_device: Vec<UsbDevice>,
/// Path of the file to save the configuration to
#[serde(skip)]
save_path: PathBuf,
Copy link
Member Author

Choose a reason for hiding this comment

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

Only PortConfig requires save_path, as its the only config file that can be saved, save_with is only called here: https://github.com/esp-rs/espflash/blob/main/espflash/src/cli/serial.rs#L53

@SergioGasquez
Copy link
Member Author

What do you think?

Definitely better, thanks for the suggestion @MabezDev, just updated it!

@SergioGasquez SergioGasquez force-pushed the feat/connections-file branch from 951f2e2 to eb5fdac Compare May 23, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

espflash.toml mixes project configuration with environment
4 participants