Skip to content

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 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
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

One minor comment but overall LGTM, thanks! Feel free to just merge as-is.

@SergioGasquez SergioGasquez force-pushed the feat/connections-file branch from 76ff901 to 81cce41 Compare May 27, 2025 08:34
@JurajSadel JurajSadel enabled auto-merge May 27, 2025 08:37
@JurajSadel JurajSadel added this pull request to the merge queue May 27, 2025
Merged via the queue into esp-rs:main with commit 818a730 May 27, 2025
25 checks passed
@SergioGasquez SergioGasquez deleted the feat/connections-file branch May 27, 2025 09:09
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