Small rewrite minor changes

master
Torwag 2014-02-11 07:33:44 -08:00
rodzic 973c0dd668
commit 3b44c1205e
1 zmienionych plików z 11 dodań i 11 usunięć

@ -1,23 +1,24 @@
## Task:
During development, one might want to restart a python program over and over again and keep the source code in an editor to perform quick changes. This is useful to test new features and to achieve a quick debug cycle.
During development, one might want to restart a python program over and over again and keep the source code in an editor to perform quick changes. This is an useful scenario to test new features and to achieve a quick debug cycle.
## Problem:
Pressing the reset button will disconnect the board (confirmed on the STM Discovery boards) from the system and reattach it. This includes loosing connection to the mass storage device which keeps the main.py file for execution. Mount points on Linux systems will be not longer valid and you have remount (or use an automounter) and reenter the mounted folder.
This tends to confuse text editors including the loss of data.
Pressing the reset button will disconnect the board (confirmed on the STM Discovery boards) from the system and reattach it. This includes loosing connection to the mass storage device which keeps the python files for execution. Mount points on Linux systems will be not longer valid and you have to remount (or use an automounter) and reenter the mounted folder.
This tends to confuse text editors up to the possible loss of (unsaved) data.
## Solution:
To avoid this problem, one can perform a soft reset. This restarts python and the main.py file without physically disconnection of the mass storage device.
To perform a softreset, create a connection to the board via a serial console program e.g..
To avoid this problem, one can perform a soft reset. This restarts micropython and the start-up python files (e.g. main.py) without a disconnect reconnect cylce of the mass storage device.
To perform a soft-reset, a connection to the board via a serial console program is required e.g.,
`screen /dev/ttyACM0`.
Since micropython executes the main.py file, there will be no prompt.
Pressing `Ctrl-D` will interrupt the execution of the main file and drop back into the interactive micropython shell.
Note, since micropython executes the start-up files (e.g. main.py) there will be no micropython prompt.
Pressing `Ctrl-C` will terminate the interactive shell and soft reset the controller to restart the main.py file.
Pressing `Ctrl-D` will interrupt the micropython execution and drops back into an interactive micropython shell.
Pressing `Ctrl-C` will terminate the interactive micropython shell and soft-reset the controller to restart the start-up files.
### Further improvements
One can echo those commands into the serial connection of the board to achieve the same goal (make sure you have write permissions).
One can send those commands to the serial connection of the board to achieve the same result (make sure you have write permissions).
`echo "\x03\x04" > /dev/ttyACM0`
### Integrate into IDE/Editor
@ -25,7 +26,6 @@ Several IDEs and Editors allow to customize shortkeys to execute arbitrary code.
#### Emacs
Add this somewhere in your emacs init (e.g. ~/.emacs.d/init.el). Adapt the serial device name if necessary. Now press `Ctrl-F5` within Emacs whenever you wish to soft-reset the controller.
```
(defun restart_micropython ()
@ -36,4 +36,4 @@ Add this somewhere in your emacs init (e.g. ~/.emacs.d/init.el). Adapt the seria
)
;; Set a global key to initiate soft reset (customize as desired)
(global-set-key (kbd "C-<f5>") 'restart_micropython)
```
```