summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lennart/SigrokAPIInterface.py9
-rw-r--r--lib/lennart/SigrokCLIInterface.py36
-rw-r--r--lib/lennart/SigrokInterface.py6
-rw-r--r--lib/runner.py4
4 files changed, 26 insertions, 29 deletions
diff --git a/lib/lennart/SigrokAPIInterface.py b/lib/lennart/SigrokAPIInterface.py
index a8765ba..a2c087a 100644
--- a/lib/lennart/SigrokAPIInterface.py
+++ b/lib/lennart/SigrokAPIInterface.py
@@ -51,7 +51,6 @@ class SigrokAPIInterface(SigrokInterface):
self,
driver="fx2lafw",
sample_rate=100_000,
- sample_count=1_000_000,
debug_output=False,
used_datafeed=datafeed_changes,
fake=False,
@@ -60,12 +59,11 @@ class SigrokAPIInterface(SigrokInterface):
:param driver: Driver that should be used
:param sample_rate: The sample rate of the Logic analyzer
- :param sample_count: The sample count of the Logic analyzer
:param debug_output: Should be true if output should be displayed to user
:param used_datafeed: one of the datafeeds above, user later as callback.
:param fake:
"""
- super(SigrokAPIInterface, self).__init__(sample_rate, sample_count)
+ super(SigrokAPIInterface, self).__init__(sample_rate)
if fake:
raise NotImplementedError("Not implemented!")
self.used_datafeed = used_datafeed
@@ -98,7 +96,6 @@ class SigrokAPIInterface(SigrokInterface):
)
sigrokDevice.open()
- sigrokDevice.config_set(ConfigKey.LIMIT_SAMPLES, self.sample_count)
sigrokDevice.config_set(ConfigKey.SAMPLERATE, self.sample_rate)
enabled_channels = ["D1"]
@@ -124,9 +121,7 @@ class SigrokAPIInterface(SigrokInterface):
print(
"Used time: ",
total_time * 1_000_000,
- "µs | sample/s: ",
- self.sample_count / (total_time),
- "Hz ",
+ "µs",
)
self.session.stop()
diff --git a/lib/lennart/SigrokCLIInterface.py b/lib/lennart/SigrokCLIInterface.py
index 873b226..d7347ca 100644
--- a/lib/lennart/SigrokCLIInterface.py
+++ b/lib/lennart/SigrokCLIInterface.py
@@ -9,7 +9,6 @@ class SigrokCLIInterface(SigrokInterface):
self,
bin_temp_file="temp/out.bin",
sample_rate=100_000,
- sample_count=1_000_000,
fake=False,
):
"""
@@ -17,10 +16,9 @@ class SigrokCLIInterface(SigrokInterface):
:param bin_temp_file: temporary file for binary output
:param sample_rate: The sample rate of the Logic analyzer
- :param sample_count: The sample count of the Logic analyzer
:param fake: if it should use existing data
"""
- super(SigrokCLIInterface, self).__init__(sample_rate, sample_count)
+ super(SigrokCLIInterface, self).__init__(sample_rate)
self.fake = fake
self.bin_temp_file = bin_temp_file
self.sigrok_cli_thread = None
@@ -30,13 +28,15 @@ class SigrokCLIInterface(SigrokInterface):
Force stopping measure, sometimes needs pkill for killing definitly
:return: None
"""
- self.sigrok_cli_thread.send_signal(subprocess.signal.SIGKILL)
- stdout, stderr = self.sigrok_cli_thread.communicate(timeout=15)
- time.sleep(5)
- # TODO not nice solution, make better
- import os
+ self.sigrok_cli_thread.terminate()
- os.system("pkill -f sigrok")
+ try:
+ self.sigrok_cli_thread.wait(timeout=10)
+ except subprocess.TimeoutExpired:
+ logger.warning("sigrok-cli has not stopped. Killing it.")
+ self.sigrok_cli_thread.kill()
+
+ self.sigrok_cli_thread.communicate()
self.runOpenAnalyze()
def runMeasure(self):
@@ -51,11 +51,19 @@ class SigrokCLIInterface(SigrokInterface):
"""
starts the measurement, not waiting for done
"""
- shellcommand = (
- 'sigrok-cli --output-file %s --output-format binary --samples %s -d %s --config "samplerate=%s Hz"'
- % (self.bin_temp_file, self.sample_count, self.driver, self.sample_rate)
- )
- self.sigrok_cli_thread = subprocess.Popen(shellcommand, shell=True)
+ shellcommand = [
+ "sigrok-cli",
+ "--output-file",
+ self.bin_temp_file,
+ "--output-format",
+ "binary",
+ "--continuous",
+ "-d",
+ self.driver,
+ "--config",
+ f"samplerate={self.sample_rate} Hz",
+ ]
+ self.sigrok_cli_thread = subprocess.Popen(shellcommand)
def waitForAsynchronousMeasure(self):
"""
diff --git a/lib/lennart/SigrokInterface.py b/lib/lennart/SigrokInterface.py
index 555a25f..a5eaffc 100644
--- a/lib/lennart/SigrokInterface.py
+++ b/lib/lennart/SigrokInterface.py
@@ -103,18 +103,14 @@ class SigrokResult:
class SigrokInterface(DataInterface):
- def __init__(
- self, sample_rate, sample_count, driver="fx2lafw", filename="temp/sigrok.log"
- ):
+ def __init__(self, sample_rate, driver="fx2lafw", filename="temp/sigrok.log"):
"""
:param sample_rate: Samplerate of the Logic Analyzer
- :param sample_count: Count of samples
:param driver: for many Logic Analyzer from Saleae the "fx2lafw" should be working
:param filename: temporary file name
"""
# options
- self.sample_count = sample_count
self.sample_rate = sample_rate
self.file = open(filename, "w+")
self.driver = driver
diff --git a/lib/runner.py b/lib/runner.py
index 0f44e97..72d222d 100644
--- a/lib/runner.py
+++ b/lib/runner.py
@@ -189,14 +189,12 @@ class EnergyTraceLogicAnalyzerMonitor(EnergyTraceMonitor):
def __init__(self, port: str, baud: int, callback=None, voltage=3.3):
super().__init__(port=port, baud=baud, callback=callback, voltage=voltage)
- # TODO Max length
- options = {"length": 90, "fake": False, "sample_rate": 1_000_000}
+ options = {"fake": False, "sample_rate": 1_000_000}
self.log_file = "logic_output_log_%s.json" % (time.strftime("%Y%m%d-%H%M%S"))
# Initialization of Interfaces
self.sig = SigrokCLIInterface(
sample_rate=options["sample_rate"],
- sample_count=options["length"] * options["sample_rate"],
fake=options["fake"],
)