docs: Reorder sections of Debugging.md

Reorder the sections to put most useful information at the top.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-08-02 12:49:48 -04:00
parent 4d5c619b8e
commit c3ab8fee90
1 changed files with 82 additions and 84 deletions

View File

@ -2,6 +2,44 @@
This document describes some of the Klipper debugging tools.
## Running the regression tests
The main Klipper GitHub repository uses "github actions" to run a
series of regression tests. It can be useful to run some of these
tests locally.
The source code "whitespace check" can be run with:
```
./scripts/check_whitespace.sh
```
The Klippy regression test suite requires "data dictionaries" from
many platforms. The easiest way to obtain them is to
[download them from github](https://github.com/KevinOConnor/klipper/issues/1438).
Once the data dictionaries are downloaded, use the following to run
the regression suite:
```
tar xfz klipper-dict-20??????.tar.gz
~/klippy-env/bin/python ~/klipper/scripts/test_klippy.py -d dict/ ~/klipper/test/klippy/*.test
```
## Manually sending commands to the micro-controller
Normally, the host klippy.py process would be used to translate gcode
commands to Klipper micro-controller commands. However, it's also
possible to manually send these MCU commands (functions marked with
the DECL_COMMAND() macro in the Klipper source code). To do so, run:
```
~/klippy-env/bin/python ./klippy/console.py /tmp/pseudoserial
```
See the "HELP" command within the tool for more information on its
functionality.
Some command-line options are available. For more information run:
`~/klippy-env/bin/python ./klippy/console.py --help`
## Translating gcode files to micro-controller commands
The Klippy host code can run in a batch mode to produce the low-level
@ -44,6 +82,50 @@ actual commands and the above output. The generated data is useful for
testing and inspection; it is not useful for sending to a real
micro-controller.
## Generating load graphs
The Klippy log file (/tmp/klippy.log) stores statistics on bandwidth,
micro-controller load, and host buffer load. It can be useful to graph
these statistics after a print.
To generate a graph, a one time step is necessary to install the
"matplotlib" package:
```
sudo apt-get update
sudo apt-get install python-matplotlib
```
Then graphs can be produced with:
```
~/klipper/scripts/graphstats.py /tmp/klippy.log -o loadgraph.png
```
One can then view the resulting **loadgraph.png** file.
Different graphs can be produced. For more information run:
`~/klipper/scripts/graphstats.py --help`
## Extracting information from the klippy.log file
The Klippy log file (/tmp/klippy.log) also contains debugging
information. There is a logextract.py script that may be useful when
analyzing a micro-controller shutdown or similar problem. It is
typically run with something like:
```
mkdir work_directory
cd work_directory
cp /tmp/klippy.log .
~/klipper/scripts/logextract.py ./klippy.log
```
The script will extract the printer config file and will extract MCU
shutdown information. The information dumps from an MCU shutdown (if
present) will be reordered by timestamp to assist in diagnosing cause
and effect scenarios.
## Testing with simulavr
The [simulavr](http://www.nongnu.org/simulavr/) tool enables one to
@ -96,7 +178,6 @@ python virtual environment):
### Using simulavr with gtkwave
One useful feature of simulavr is its ability to create signal wave
generation files with the exact timing of events. To do this, follow
the directions above, but run avrsim.py with a command-line like the
@ -113,86 +194,3 @@ using gtkwave with:
```
gtkwave avrsim.vcd
```
## Manually sending commands to the micro-controller
Normally, the host klippy.py process would be used to translate gcode
commands to Klipper micro-controller commands. However, it's also
possible to manually send these MCU commands (functions marked with
the DECL_COMMAND() macro in the Klipper source code). To do so, run:
```
~/klippy-env/bin/python ./klippy/console.py /tmp/pseudoserial
```
See the "HELP" command within the tool for more information on its
functionality.
Some command-line options are available. For more information run:
`~/klippy-env/bin/python ./klippy/console.py --help`
## Generating load graphs
The Klippy log file (/tmp/klippy.log) stores statistics on bandwidth,
micro-controller load, and host buffer load. It can be useful to graph
these statistics after a print.
To generate a graph, a one time step is necessary to install the
"matplotlib" package:
```
sudo apt-get update
sudo apt-get install python-matplotlib
```
Then graphs can be produced with:
```
~/klipper/scripts/graphstats.py /tmp/klippy.log -o loadgraph.png
```
One can then view the resulting **loadgraph.png** file.
Different graphs can be produced. For more information run:
`~/klipper/scripts/graphstats.py --help`
## Extracting information from the klippy.log file
The Klippy log file (/tmp/klippy.log) also contains debugging
information. There is a logextract.py script that may be useful when
analyzing a micro-controller shutdown or similar problem. It is
typically run with something like:
```
mkdir work_directory
cd work_directory
cp /tmp/klippy.log .
~/klipper/scripts/logextract.py ./klippy.log
```
The script will extract the printer config file and will extract MCU
shutdown information. The information dumps from an MCU shutdown (if
present) will be reordered by timestamp to assist in diagnosing cause
and effect scenarios.
## Running the regression tests
The main Klipper GitHub repository uses "github actions" to run a
series of regression tests. It can be useful to run some of these
tests locally.
The source code "whitespace check" can be run with:
```
./scripts/check_whitespace.sh
```
The Klippy regression test suite requires "data dictionaries" from
many platforms. The easiest way to obtain them is to
[download them from github](https://github.com/KevinOConnor/klipper/issues/1438).
Once the data dictionaries are downloaded, use the following to run
the regression suite:
```
tar xfz klipper-dict-20??????.tar.gz
~/klippy-env/bin/python ~/klipper/scripts/test_klippy.py -d dict/ ~/klipper/test/klippy/*.test
```