Skip to content

Commit

Permalink
Update docstrings and tests a little
Browse files Browse the repository at this point in the history
  • Loading branch information
KhazAkar committed Jul 31, 2022
1 parent 7db8a61 commit a66e518
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 3 additions & 2 deletions autorok/autorok.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class Autorok:
They are as follows:
sigrok-cli (Working, WIP)
libsigrok (WIP)
libsigrok (TBD)
libsigrok4DSL (for DreamSourceLabs devices not supported by mainline libsigrok, WIP)
libsigrok4DSL (for DreamSourceLabs devices not supported by mainline libsigrok, TBD)
"""

def __init__(self, iface: SigrokInterface):
Expand All @@ -43,6 +43,7 @@ def show_connected_devices_details(self, driver: str = 'demo'):
return self.driver.show_connected_devices_details(driver)

def get_config_options(self, driver: str = 'demo'):
""" Grabs all available configuration options for selected driver """
return self.driver.get_config_options(driver)

def scan_devices(self):
Expand Down
22 changes: 15 additions & 7 deletions autorok/sigrokcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_config_options(self, driver: str = 'demo'):

def show_connected_devices_details(self, driver: str = 'demo'):
""" Uses subprocess to collect details for connected devices """
return self._get_details(driver)
return self._get_details(driver = driver)

def _cleanup_subprocess_output(self, subprocess_output):
output_split = subprocess_output.stdout.split('\n')
Expand Down Expand Up @@ -106,7 +106,7 @@ def scan_devices(self):

return self._parse_scan_results(sigrok_output)

def select_measurement_device(self, device: Device):
def select_measurement_device(self, device: Device) -> Device:
"""
Selects device from previously scanned list
Expand Down Expand Up @@ -134,7 +134,7 @@ def select_measurement_device(self, device: Device):

def configure_channels(self,
ch_list: typing.List[str],
all_ch: bool = False):
all_ch: bool = False) -> typing.List:
"""
Sets active channels for selected driver/device
Expand Down Expand Up @@ -164,7 +164,7 @@ def configure_measurement(self,
wait_for_trigger: bool = False,
output_to_file: bool = False,
file_type: OutputType = OutputType.CSV,
file_path: pathlib.Path = ...):
file_path: pathlib.Path = ...) -> None:
"""
Configures additional stuff to the measurement. Persits between measurements.
Expand All @@ -188,7 +188,7 @@ def configure_measurement(self,
for elem in self.measurement_cfg:
self._sigrok_meas_args.append(elem)

def start_sampled_measurement(self, samples: int, decode: bool = False):
def start_sampled_measurement(self, samples: int, decode: bool = False) -> subprocess.CompletedProcess:
"""
Starts measurement based on number of samples to gather from device
Expand All @@ -215,8 +215,16 @@ def start_sampled_measurement(self, samples: int, decode: bool = False):
self._sigrok_meas_args = self._sigrok_meas_args[:-2]
return result

def start_framed_measurement(self, frames: int, decode: bool = False):
def start_framed_measurement(self, frames: int, decode: bool = False) -> subprocess.CompletedProcess:
"""
Starts measurement, counted in frames
Parameters
----------
frames: int
How many frames do you want to collect
decode: bool
Do you want to get decoded values or raw ones? False by default
"""
for elem in ["--frames", str(frames)]:
self._sigrok_meas_args.append(elem)
Expand All @@ -227,7 +235,7 @@ def start_framed_measurement(self, frames: int, decode: bool = False):
self._sigrok_meas_args = self._sigrok_meas_args[:-2]
return result

def start_timed_measurement(self, sampling_time: int, decode: bool = False):
def start_timed_measurement(self, sampling_time: int, decode: bool = False) -> subprocess.CompletedProcess:
"""
"""
for elem in ["--time", str(sampling_time)]:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_sigrokcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,4 @@ def test_should_show_available_config_options(sigrok):
device_list = sigrok.scan_devices()
sigrok.select_measurement_device(device_list[0])
config_options = sigrok.get_config_options()
assert config_options is not None

assert config_options.get('samplerate', None) is not None

0 comments on commit a66e518

Please sign in to comment.