Skip to content

Commit

Permalink
Update download mode detection (#685)
Browse files Browse the repository at this point in the history
* Update download mode detection

Previously, this failed to detect download mode during this regex match in the following message.

```
ESP-ROM:esp32s3-20210327
    Build:Mar 27 2021
    rst:0x1 (POWERON),boot:0x0 (DOWNLOAD(USB/UART0))
    waiting for download

```

`.*` only matches on any character EXCEPT line breaks,  where as [\s\S]` will match on anything.

* fix fmt

* Update CHANGELOG.md

* Update espflash/src/connection/mod.rs

Co-authored-by: Sergio Gasquez Arcos <[email protected]>

* Update mod.rs

---------

Co-authored-by: Sergio Gasquez Arcos <[email protected]>
Co-authored-by: Jesse Braham <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent 30300c4 commit 7b0c6ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)
- espflash defmt log didn't display timestamp, according to [defmt doc](https://defmt.ferrous-systems.com/timestamps). (#680)
- Fixed pattern matching to detect download mode over multiple lines (#685)

### Changed

Expand Down
3 changes: 2 additions & 1 deletion espflash/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ impl Connection {

let read_slice = String::from_utf8_lossy(&buff[..read_bytes as usize]).into_owned();

let pattern = Regex::new(r"boot:(0x[0-9a-fA-F]+)(.*waiting for download)?").unwrap();
let pattern =
Regex::new(r"boot:(0x[0-9a-fA-F]+)([\s\S]*waiting for download)?").unwrap();

// Search for the pattern in the read data
if let Some(data) = pattern.captures(&read_slice) {
Expand Down

0 comments on commit 7b0c6ac

Please sign in to comment.