31
31
32
32
import can
33
33
from can import __version__
34
- from .logger import _create_bus , _parse_filters , _append_filter_argument
34
+ from .logger import (
35
+ _create_bus ,
36
+ _parse_filters ,
37
+ _append_filter_argument ,
38
+ _create_base_argument_parser ,
39
+ )
35
40
36
41
37
42
logger = logging .getLogger ("can.serial" )
@@ -282,7 +287,7 @@ def draw_can_bus_message(self, msg, sorting=False):
282
287
previous_byte_values [i ] = b
283
288
else :
284
289
data_color = color
285
- text = "{ :02X}". format ( b )
290
+ text = f" { b :02X} "
286
291
self .draw_line (self .ids [key ]["row" ], col , text , data_color )
287
292
288
293
if self .data_structs :
@@ -402,6 +407,10 @@ def parse_args(args):
402
407
allow_abbrev = False ,
403
408
)
404
409
410
+ # Generate the standard arguments:
411
+ # Channel, bitrate, data_bitrate, interface, app_name, CAN-FD support
412
+ _create_base_argument_parser (parser )
413
+
405
414
optional = parser .add_argument_group ("Optional arguments" )
406
415
407
416
optional .add_argument (
@@ -415,31 +424,6 @@ def parse_args(args):
415
424
version = "%(prog)s (version {version})" .format (version = __version__ ),
416
425
)
417
426
418
- # Copied from: can/logger.py
419
- optional .add_argument (
420
- "-b" ,
421
- "--bitrate" ,
422
- type = int ,
423
- help = """Bitrate to use for the given CAN interface""" ,
424
- )
425
-
426
- optional .add_argument ("--fd" , help = "Activate CAN-FD support" , action = "store_true" )
427
-
428
- optional .add_argument (
429
- "--data_bitrate" ,
430
- type = int ,
431
- help = "Bitrate to use for the data phase in case of CAN-FD." ,
432
- )
433
-
434
- optional .add_argument (
435
- "-c" ,
436
- "--channel" ,
437
- help = """Most backend interfaces require some sort of channel.
438
- For example with the serial interface the channel might be a rfcomm device: "/dev/rfcomm0"
439
- with the socketcan interfaces valid channel examples include: "can0", "vcan0".
440
- (default: use default for the specified interface)""" ,
441
- )
442
-
443
427
optional .add_argument (
444
428
"-d" ,
445
429
"--decode" ,
@@ -484,14 +468,6 @@ def parse_args(args):
484
468
485
469
_append_filter_argument (optional , "-f" )
486
470
487
- optional .add_argument (
488
- "-i" ,
489
- "--interface" ,
490
- dest = "interface" ,
491
- help = "R|Specify the backend CAN interface to use." ,
492
- choices = sorted (can .VALID_INTERFACES ),
493
- )
494
-
495
471
optional .add_argument (
496
472
"-v" ,
497
473
action = "count" ,
@@ -501,14 +477,6 @@ def parse_args(args):
501
477
default = 2 ,
502
478
)
503
479
504
- # suppressed as the user doesn't need to change it
505
- optional .add_argument (
506
- "--app_name" ,
507
- dest = "app_name" ,
508
- help = argparse .SUPPRESS ,
509
- default = "python-can-viewer" ,
510
- )
511
-
512
480
# Print help message when no arguments are given
513
481
if not args :
514
482
parser .print_help (sys .stderr )
0 commit comments