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

Serial Monitor : Data is sent both for key press and release events #660

Closed
LelouBil opened this issue Aug 2, 2024 · 0 comments · Fixed by #661
Closed

Serial Monitor : Data is sent both for key press and release events #660

LelouBil opened this issue Aug 2, 2024 · 0 comments · Fixed by #661

Comments

@LelouBil
Copy link
Contributor

LelouBil commented Aug 2, 2024

When trying out a simple serial echo with my new esp32, I found out it received twice the letters I typed when using espflash monitor.
However, when using PuTTY, it only received them once.

Using the original windows console allowed me to pinpoint the issue, keys are sent for press and for release event.
Adding a simple dbg!(key) here

if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? {
if let Event::Key(key) = read().into_diagnostic()? {
if key.modifiers.contains(KeyModifiers::CONTROL) {
match key.code {
KeyCode::Char('c') => break,
KeyCode::Char('r') => {
reset_after_flash(&mut serial, pid).into_diagnostic()?;
continue;
showed me this (the "Read" are my echo program running on the esp)

[espflash\src\cli\monitor\mod.rs:119:5] &key = KeyEvent {
    code: Char(
        's',
    ),
    modifiers: KeyModifiers(
        0x0,
    ),
    kind: Press,
    state: KeyEventState(
        0x0,
    ),
}
Read: 's'
[espflash\src\cli\monitor\mod.rs:119:5] &key = KeyEvent {
    code: Char(
        's',
    ),
    modifiers: KeyModifiers(
        0x0,
    ),
    kind: Release,
    state: KeyEventState(
        0x0,
    ),
}
Read: 's'

I am not sure if this is intended, this can be fixed simply by checking if it is a key press or a key release.

I also want to add that this was difficult to find because inside some terminals, like the RustRover terminal or the new windows terminal, key presses were sending press and release instantaneously, even if the key was not yet released. The old windows terminal however correctly waited for me to release the key before sending the release event. Maybe this is due to a bug in an upstream library ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant