Skip to content

Add changed byte highlighting to viewer.py #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 16, 2021
Merged

Add changed byte highlighting to viewer.py #1159

merged 13 commits into from
Nov 16, 2021

Conversation

MattWoodhead
Copy link
Contributor

I have been using python-can for message sniffing on a Tractor control bus, and a feature I had seen in some other message viewers was highlighting bytes when their value changes.
I have added this functionality (toggleable - off by default) to viewer.py, and found it useful for what I was trying to achieve so thought I would share it here.

viewer

viewer_changed_bytes_highlighting

I hope sending a PR like this out of the blue is OK, if not please reject :)

Added optional byte highlighting that can be toggled using the shortcut key 'h'
Fix for the following error since the introduction of #1151 / #1142

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/python-can/can/viewer.py", line 582, in <module>
    main()
  File "/home/pi/python-can/can/viewer.py", line 573, in main
    bus = _create_bus(parsed_args, **additional_config, app_name="python-can viewer")
  File "/home/pi/python-can/can/logger.py", line 105, in _create_bus
    if parsed_args.app_name:
AttributeError: 'Namespace' object has no attribute 'app_name'
update viewer documentations
arrange keyboard shortcuts into bulleted list
@mergify mergify bot requested a review from hardbyte October 30, 2021 10:55
@codecov
Copy link

codecov bot commented Oct 31, 2021

Codecov Report

Merging #1159 (7081ec9) into develop (270224c) will increase coverage by 0.02%.
The diff coverage is 92.85%.

@@             Coverage Diff             @@
##           develop    #1159      +/-   ##
===========================================
+ Coverage    70.81%   70.83%   +0.02%     
===========================================
  Files           79       79              
  Lines         7737     7757      +20     
===========================================
+ Hits          5479     5495      +16     
- Misses        2258     2262       +4     

Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool feature! Thanks for the contribution!

MattWoodhead and others added 3 commits November 10, 2021 19:31
Co-authored-by: Felix Divo <[email protected]>
Add extra length to other lines in the help text so the border lines up.
Add test coverage for some of the new byte highlighting functions.
Change standard arguments definition to be defined using logger._create_base_argument_parser instead of manually defining them in this module.
Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@felixdivo felixdivo added this to the 4.0.0 Release milestone Nov 12, 2021
@hardbyte hardbyte merged commit 4ac9008 into hardbyte:develop Nov 16, 2021
cowo78 pushed a commit to cowo78/python-can that referenced this pull request Dec 9, 2021
* Added optional byte highlighting to viewer

Added optional byte highlighting that can be toggled using the shortcut key 'h'

* Some black formatting changes

* Final black formatting

* Fixed viewer bug

Fix for the following error since the introduction of hardbyte#1151 / hardbyte#1142

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/python-can/can/viewer.py", line 582, in <module>
    main()
  File "/home/pi/python-can/can/viewer.py", line 573, in main
    bus = _create_bus(parsed_args, **additional_config, app_name="python-can viewer")
  File "/home/pi/python-can/can/logger.py", line 105, in _create_bus
    if parsed_args.app_name:
AttributeError: 'Namespace' object has no attribute 'app_name'

* Update scripts.rst

update viewer documentations

* Update scripts.rst

* Update scripts.rst

arrange keyboard shortcuts into bulleted list

* Update scripts.rst

* Update can/viewer.py

Co-authored-by: Felix Divo <[email protected]>

* Better description.

Add extra length to other lines in the help text so the border lines up.

* Update test_viewer.py

Add test coverage for some of the new byte highlighting functions.

* Use _create_base_argument_parser  in viewer.py

Change standard arguments definition to be defined using logger._create_base_argument_parser instead of manually defining them in this module.

Co-authored-by: Felix Divo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants