ppannuto / python-saleae

Python library to control a Saleae Logic Analyzer
Apache License 2.0
124 stars 55 forks source link

Added digital I/O threshold voltage querying and setting methods. #40

Closed jkesanen closed 6 years ago

jkesanen commented 6 years ago

Needed to configure digital I/O threshold voltage, but it wasn't implemented. The functionality was available in SaleaeSocketAPI. Added methods for querying available and current voltages, and setting the voltage.

Tested with Python versions 2.7.14 and 3.6.4.

Tested with Saleae Logic 16 and Saleae Logic Pro 16.

Python 3.6.4 (default, Jan 23 2018, 13:17:37)  [GCC 7.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import saleae
>>> s = saleae.Saleae('localhost', 10429)
>>> s.get_digital_voltage_options()
[(0, '1.8V to 3.6V', <DigitalVoltageFlags.Selected: 1>), (1, '3.6V to 5.0V', <DigitalVoltageFlags.NotSelected: 0>)]
>>> s.set_digital_voltage_option(1)
>>> s.get_digital_voltage_options()
[(0, '1.8V to 3.6V', <DigitalVoltageFlags.NotSelected: 0>), (1, '3.6V to 5.0V', <DigitalVoltageFlags.Selected: 1>)]
>>>
ppannuto commented 6 years ago

Looks good! Thanks for the addition.

As this only works with some of the devices, could you add a runtime check that the method is being called for a valid Saleae, and give a nice warning otherwise? Check out set_active_channels as an example. You can also add the #doctest:+SKIP from that, as test infrastructure doesn't have a great way to handle having the "right" soft Saleae active currently.

jkesanen commented 6 years ago

Thanks for feedback!

I did the changes you suggested and tested them with real Logic Pro 16 and the virtual Logic 4.

jkesanen commented 6 years ago

Thanks for merging in. And thanks for the project. Been very helpful for me,