summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-11-06 15:53:59 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-11-06 15:53:59 +0100
commit289de4a42565ff2dd30c0458613e7d4f45beaf24 (patch)
tree7b775b2ba148909f36267c05cd4851e2de5cf71d /bin
parent1ba3ea765442754decfec0c6e6182e1eaeb83bd8 (diff)
use the highest feasible sample rate
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kaxxxxp-viewer12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/kaxxxxp-viewer b/bin/kaxxxxp-viewer
index 84357f6..dac5520 100755
--- a/bin/kaxxxxp-viewer
+++ b/bin/kaxxxxp-viewer
@@ -67,12 +67,14 @@ def running_mean(x: np.ndarray, N: int) -> np.ndarray:
class SerialReader(serial.threaded.Protocol):
def __init__(self):
self.remaining_chars = 0
+ self.read_complete = False
self.recv_buf = ""
self.lines = []
def expect(self, num_chars):
self.recv_buf = ""
self.remaining_chars = num_chars
+ self.read_complete = False
def __call__(self):
return self
@@ -88,6 +90,7 @@ class SerialReader(serial.threaded.Protocol):
if self.remaining_chars <= 0:
self.lines.append(self.recv_buf)
+ self.read_complete = True
def get_expected_line(self):
if len(self.lines):
@@ -129,7 +132,10 @@ class KA320:
def rw(self, cmd, num_chars, exact=False):
self.reader.expect(num_chars)
self.ser.write(cmd)
- time.sleep(0.1)
+ timeout = 10
+ while not self.reader.read_complete and not timeout == 0:
+ time.sleep(0.02)
+ timeout -= 1
if exact:
return self.reader.get_expected_line()
return self.reader.get_line()
@@ -140,14 +146,14 @@ class KA320:
return self.rw(b"*IDN?", 16)
def get_max_voltage(self):
- return float(self.rw(f"VSET{self.channel:d}?".encode(), 5))
+ return float(self.rw(f"VSET{self.channel:d}?".encode(), 5, True))
def get_max_current(self):
return float(self.rw(f"ISET{self.channel:d}?".encode(), 5, True))
def get_voltage(self):
try:
- return float(self.rw(f"VOUT{self.channel:d}?".encode(), 5))
+ return float(self.rw(f"VOUT{self.channel:d}?".encode(), 5, True))
except TypeError:
return None