pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
282 stars 120 forks source link

Add TCPIP instrument discovery #326

Closed eosti closed 2 years ago

eosti commented 2 years ago

Continues the work done in #297 by broadcasting on all interfaces. Tweaks the RPC library to add methods for only sending and only receiving broadcasts, so that the timeout period can be shared across all interfaces.

Adds optional dependency psutil, which is needed to discover instruments on all interfaces. Otherwise, the only instruments on the default interface will be discovered.

codecov-commenter commented 2 years ago

Codecov Report

Merging #326 (5a72ad2) into main (f8a79ed) will decrease coverage by 0.28%. The diff coverage is 14.45%.

@@            Coverage Diff             @@
##             main     #326      +/-   ##
==========================================
- Coverage   22.02%   21.73%   -0.29%     
==========================================
  Files          20       20              
  Lines        2602     2682      +80     
  Branches      396      415      +19     
==========================================
+ Hits          573      583      +10     
- Misses       2016     2082      +66     
- Partials       13       17       +4     
Flag Coverage Δ
unittests 21.70% <14.45%> (-0.29%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyvisa_py/protocols/rpc.py 22.05% <9.09%> (-0.90%) :arrow_down:
pyvisa_py/tcpip.py 17.81% <15.15%> (-0.25%) :arrow_down:
...e/keysight_assisted_tests/test_resource_manager.py 80.00% <50.00%> (-20.00%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f8a79ed...5a72ad2. Read the comment docs.

MatthieuDartiailh commented 2 years ago

I will do my best to review and test with the keysight tools hopefully Monday.

MatthieuDartiailh commented 2 years ago

Sorry I got no time to look at this last week. I will do it ASAP but I am quite busy ATM.

MatthieuDartiailh commented 2 years ago

I will try to come back to that next week. Sorry for the delay.

MatthieuDartiailh commented 2 years ago

Sorry for the very very long delay. I finally took some time to play with your code both with and without psutil installed. For my stupid fake instrument case I get many hits with psutil including 127.0.0.1 (which is the address I expect). Those addresses do not all match loopback as defined in the IPv4 standard. There are all valid so there is no meaningful way to filter them.

This is contrived case and the fact you code gives a slightly unexpected answer should not all back your work. I want to apologize again for the long delay and thank you for your contribution.