Skip to content
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

driver/sigrok: Add sigrok driver for DMMs #1141

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

SmithChart
Copy link
Member

@SmithChart SmithChart commented Apr 20, 2023

Description
The SigrokDmmDriver wraps around a single channel DMM controlled by sigrok. It has been tested with Unit-T UT61C and UT61B devices but probably also works with other single chnnel DMMs.

This driver binds to a SigrokUsbDevice.
Make sure to select the correct driver for your DMM there.

Example usage:

resources:
  - SigrokUSBDevice:
      driver: uni-t-ut61c
      match:
        'ID_PATH': pci-0000:07:00.4-usb-0:2:1.0
drivers:
  - SigrokUt61DmmDriver: {}

Args:
bindings (dict): driver to use with sigrok

I'm already using this driver to read values from two DMMs in parallel during hardware testing:

volt_dmm = target.get_driver("SigrokDmmDriver", name="volt_dmm")
curr_dmm = target.get_driver("SigrokDmmDriver", name="curr_dmm")
volt_dmm.start(5)
curr_dmm.start(5)
dmm_volt = dmm_voltage_measure(self.volt_dmm.get_samples())
dmm_curr = dmm_current_measure(self.curr_dmm.get_samples())

Where the helper dmm_*_measure() makes sure the correct physical unit has been returned by the DMM, does averaging, etc.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • Add a section on how to use the feature to doc/usage.rst
  • Add a section on how to use the feature to doc/development.rst
  • PR has been tested
  • Man pages have been regenerated

@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Patch coverage: 31.1% and project coverage change: -0.3 ⚠️

Comparison is base (3dc17a9) 63.0% compared to head (94ffdda) 62.8%.

❗ Current head 94ffdda differs from pull request most recent head e921a4a. Consider uploading reports for the commit e921a4a to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1141     +/-   ##
========================================
- Coverage    63.0%   62.8%   -0.3%     
========================================
  Files         159     159             
  Lines       11668   11795    +127     
========================================
+ Hits         7362    7410     +48     
- Misses       4306    4385     +79     
Impacted Files Coverage Δ
labgrid/driver/sigrokdriver.py 35.8% <29.5%> (-1.4%) ⬇️
labgrid/driver/__init__.py 100.0% <100.0%> (ø)

... and 14 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

labgrid/driver/sigrokdriver.py Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
@SmithChart
Copy link
Member Author

@Bastian-Krause: I've updated my PR, please have another look. (Also fixed some typos here and there while I was on it...)

labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
doc/configuration.rst Outdated Show resolved Hide resolved
time.sleep(0.1)
else:
# process did not finish in time
self.log.info("sigrok-cli did not finish in time, increase timeout?")
Copy link
Member

Choose a reason for hiding this comment

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

Mh, SigrokCommon logs everything as SigrokDriver. That's confusing. We should fix that, not necessarily in this PR, though..

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like the best way would be to have a __attrs_post_init__() in each driver that sets up logging with the correct name.

Copy link
Member

Choose a reason for hiding this comment

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

See #1293.

labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
@SmithChart
Copy link
Member Author

@Bastian-Krause: I've updated my PR, please have another look.

labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
labgrid/driver/sigrokdriver.py Outdated Show resolved Hide resolved
The SigrokDmmDriver wraps around a single channel DMM controlled by sigrok.
It has been tested with Unit-T UT61C and UT61B devices but probably also
works with other single chnnel DMMs.

This driver binds to a SigrokUsbDevice.
Make sure to select the correct driver for your DMM there.

Example usage:
> resources:
>   - SigrokUSBDevice:
>       driver: uni-t-ut61c
>       match:
>         'ID_PATH': pci-0000:07:00.4-usb-0:2:1.0
> drivers:
>   - SigrokDmmDriver: {}

Args:
    bindings (dict): driver to use with sigrok

Signed-off-by: Chris Fiege <[email protected]>
Co-authored-by: Bastian Krause <[email protected]>
Copy link
Member

@Bastian-Krause Bastian-Krause left a comment

Choose a reason for hiding this comment

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

Thanks!

@Bastian-Krause Bastian-Krause removed their assignment Jul 12, 2023
@Bastian-Krause Bastian-Krause merged commit b409e1d into labgrid-project:master Jul 25, 2023
@Bastian-Krause Bastian-Krause mentioned this pull request Jul 31, 2023
1 task
@SmithChart SmithChart deleted the sigrokdmm branch November 13, 2023 09:38
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