Skip to content

Commit e7ff9a8

Browse files
committed
Extract viewer command line help
1 parent 4e41220 commit e7ff9a8

File tree

1 file changed

+8
-77
lines changed

1 file changed

+8
-77
lines changed

doc/scripts.rst

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -25,86 +25,17 @@ can.viewer
2525

2626
A screenshot of the application can be seen below:
2727

28+
.. image:: ../images/viewer.png
29+
:width: 100%
2830

2931
The first column is the number of times a frame with the particular ID that has been received, next is the timestamp of the frame relative to the first received message. The third column is the time between the current frame relative to the previous one. Next is the length of the frame, the data and then the decoded data converted according to the ``-d`` argument. The top red row indicates an error frame.
3032

3133
Command line arguments
3234
^^^^^^^^^^^^^^^^^^^^^^
3335

34-
By default it will be using the :doc:`/interfaces/socketcan` interface. All interfaces supported are supported and can be specified using the ``-i`` argument.
35-
36-
The full usage page can be seen below::
37-
38-
Usage: python -m can.viewer [-h] [--version] [-b BITRATE] [-c CHANNEL]
39-
[-d {<id>:<format>,<id>:<format>:<scaling1>:...:<scalingN>,file.txt}]
40-
[-f {<can_id>:<can_mask>,<can_id>~<can_mask>}]
41-
[-i {iscan,ixxat,kvaser,neovi,nican,pcan,serial,slcan,socketcan,socketcan_ctypes,socketcan_native,usb2can,vector,virtual}]
42-
43-
A simple CAN viewer terminal application written in Python
44-
45-
Optional arguments:
46-
-h, --help Show this help message and exit
47-
--version Show program's version number and exit
48-
-b, --bitrate BITRATE
49-
Bitrate to use for the given CAN interface
50-
-c, --channel CHANNEL
51-
Most backend interfaces require some sort of channel.
52-
For example with the serial interface the channel
53-
might be a rfcomm device: "/dev/rfcomm0" with the
54-
socketcan interfaces valid channel examples include:
55-
"can0", "vcan0". (default: use default for the
56-
specified interface)
57-
-d, --decode {<id>:<format>,<id>:<format>:<scaling1>:...:<scalingN>,file.txt}
58-
Specify how to convert the raw bytes into real values.
59-
The ID of the frame is given as the first argument and the format as the second.
60-
The Python struct package is used to unpack the received data
61-
where the format characters have the following meaning:
62-
< = little-endian, > = big-endian
63-
x = pad byte
64-
c = char
65-
? = bool
66-
b = int8_t, B = uint8_t
67-
h = int16, H = uint16
68-
l = int32_t, L = uint32_t
69-
q = int64_t, Q = uint64_t
70-
f = float (32-bits), d = double (64-bits)
71-
Fx to convert six bytes with ID 0x100 into uint8_t, uint16 and uint32_t:
72-
$ python -m can.viewer -d "100:<BHL"
73-
Note that the IDs are always interpreted as hex values.
74-
An optional conversion from integers to real units can be given
75-
as additional arguments. In order to convert from raw integer
76-
values the values are multiplied with the corresponding scaling value,
77-
similarly the values are divided by the scaling value in order
78-
to convert from real units to raw integer values.
79-
Fx lets say the uint8_t needs no conversion, but the uint16 and the uint32_t
80-
needs to be divided by 10 and 100 respectively:
81-
$ python -m can.viewer -d "101:<BHL:1:10.0:100.0"
82-
Be aware that integer division is performed if the scaling value is an integer.
83-
Multiple arguments are separated by spaces:
84-
$ python -m can.viewer -d "100:<BHL" "101:<BHL:1:10.0:100.0"
85-
Alternatively a file containing the conversion strings separated by new lines
86-
can be given as input:
87-
$ cat file.txt
88-
100:<BHL
89-
101:<BHL:1:10.0:100.0
90-
$ python -m can.viewer -d file.txt
91-
-f, --filter {<can_id>:<can_mask>,<can_id>~<can_mask>}
92-
Comma separated CAN filters for the given CAN interface:
93-
<can_id>:<can_mask> (matches when <received_can_id> & mask == can_id & mask)
94-
<can_id>~<can_mask> (matches when <received_can_id> & mask != can_id & mask)
95-
Fx to show only frames with ID 0x100 to 0x103:
96-
python -m can.viewer -f 100:7FC
97-
Note that the ID and mask are alway interpreted as hex values
98-
-i, --interface {iscan,ixxat,kvaser,neovi,nican,pcan,serial,slcan,socketcan,socketcan_ctypes,socketcan_native,usb2can,vector,virtual}
99-
Specify the backend CAN interface to use.
100-
101-
Shortcuts:
102-
+---------+-------------------------+
103-
| Key | Description |
104-
+---------+-------------------------+
105-
| ESQ/q | Exit the viewer |
106-
| c | Clear the stored frames |
107-
| s | Sort the stored frames |
108-
| SPACE | Pause the viewer |
109-
| UP/DOWN | Scroll the viewer |
110-
+---------+-------------------------+
36+
By default the ``can.viewer`` uses the :doc:`/interfaces/socketcan` interface. All interfaces are supported and can be specified using the ``-i`` argument or configured following :doc:`/configuration`.
37+
38+
The full usage page can be seen below:
39+
40+
.. command-output:: python -m can.viewer -h
41+

0 commit comments

Comments
 (0)