[riot-commits] [RIOT-OS/RIOT] 40da80: pyterm: move char reading and reconnect to their o...

Martine Lenders noreply at github.com
Tue Feb 9 20:34:55 CET 2021


  Branch: refs/heads/master
  Home:   https://github.com/RIOT-OS/RIOT
  Commit: 40da80085e69ee5687f3bed2ba3828ae66cf0afa
      https://github.com/RIOT-OS/RIOT/commit/40da80085e69ee5687f3bed2ba3828ae66cf0afa
  Author: Martine Lenders <m.lenders at fu-berlin.de>
  Date:   2021-02-09 (Tue, 09 Feb 2021)

  Changed paths:
    M dist/tools/pyterm/pyterm

  Log Message:
  -----------
  pyterm: move char reading and reconnect to their own private functions


  Commit: 271d1ae3a2c687b7857af1a5cf430807b789b331
      https://github.com/RIOT-OS/RIOT/commit/271d1ae3a2c687b7857af1a5cf430807b789b331
  Author: Martine Lenders <m.lenders at fu-berlin.de>
  Date:   2021-02-09 (Tue, 09 Feb 2021)

  Changed paths:
    M dist/tools/pyterm/pyterm

  Log Message:
  -----------
  pyterm: read space after prompt into prompt

Currently, when the prompt is read in `pyterm` the space after it is
ignored for the prompt and the output command just adds its own prompt.
This leads to the next output always having a leading space, see e.g.
this output from `tests/shell` using `RIOT_TERMINAL=pyterm`:

```
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT2/tests/shell'
/home/mlenders/Repositories/RIOT-OS/RIOT2/dist/tools/pyterm/pyterm -p "/dev/ttyUSB1" -b "500000"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2021-02-09 14:47:15,071 # Connect to serial port /dev/ttyUSB1
Welcome to pyterm!
Type '/exit' to exit.
bufsize
2021-02-09 14:47:19,712 # bufsize
2021-02-09 14:47:19,712 # 128
> bufsize
2021-02-09 14:47:21,535 #  bufsize
2021-02-09 14:47:21,536 # 128
>
```

While this isn't necessarily a problem in most cases, it becomes a
problem when the prompt is expected and the output of a command is
empty. In that case, the space is added to the empty output, making it
" ", so the prompt output command is never triggered and the prompt is
added to the next command in the log output. To demonstrate I added a
command `empty` to `tests/shell` that just does nothing and deactivated
the command echoing using `CFLAGS=-DCONFIG_SHELL_NO_ECHO=1`:

```
empty
> empty
empty
bufsize
2021-02-09 14:54:33,753 #  > > 128
>
```

This fixes that problem by also reading the assumed space (we already
assume the prompt, so I don't see no harm in that) and if it is not a
space to skip the reading of the next char in the next iteration of the
reader loop.


  Commit: bd96e4b4005a0a742e73d619f700bb38a0577e2e
      https://github.com/RIOT-OS/RIOT/commit/bd96e4b4005a0a742e73d619f700bb38a0577e2e
  Author: Martine Lenders <m.lenders at fu-berlin.de>
  Date:   2021-02-09 (Tue, 09 Feb 2021)

  Changed paths:
    M tests/shell/main.c

  Log Message:
  -----------
  tests/shell: add command with empty output


  Commit: 7bb706356a6e2e50275ffa2fbc5fc3e52624bb56
      https://github.com/RIOT-OS/RIOT/commit/7bb706356a6e2e50275ffa2fbc5fc3e52624bb56
  Author: Martine Lenders <m.lenders at fu-berlin.de>
  Date:   2021-02-09 (Tue, 09 Feb 2021)

  Changed paths:
    M dist/tools/pyterm/pyterm
    M tests/shell/main.c

  Log Message:
  -----------
  Merge pull request #15962 from miri64/pyterm/fix/space-after-prompt

pyterm: read space after prompt into prompt


Compare: https://github.com/RIOT-OS/RIOT/compare/6929577c7619...7bb706356a6e


More information about the commits mailing list