diff options
-rw-r--r-- | qolab/hardware/scope/rigolds1054z.py | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/qolab/hardware/scope/rigolds1054z.py b/qolab/hardware/scope/rigolds1054z.py index a9ff9cb..c0bc114 100644 --- a/qolab/hardware/scope/rigolds1054z.py +++ b/qolab/hardware/scope/rigolds1054z.py @@ -160,36 +160,41 @@ class RigolDS1054z(ScopeSCPI): print(preamble) Npnts = int(preamble[2]) wfRaw = np.zeros(Npnts, dtype=np.int8) - maxreadable = 200000 # 250000 is the maximum number of bytes readable in one go + maxreadable = 250000 # the maximum number of bytes readable in one go + chunk_size = maxreadable + errCnt = 0 strt = 1 - stp = min(maxreadable,Npnts) + stp = min(maxreadable, Npnts) while (strt <= Npnts): - import time - stp = strt - 1 + maxreadable + stp = strt - 1 + chunk_size stp = min(stp, Npnts) - print(f"{strt=} {stp=}") - # reading requested number of points in chunks of maxreadable - print("strt cnt") + # reading requested number of points in chunks self.write(f":WAVeform:STARt {strt}") - print(f"{self.wait_until_finished()}") - time.sleep(.1) - print("stop cnt") self.write(f":WAVeform:STOP {stp}") - print(f"{self.wait_until_finished()}") - time.sleep(.1) qstr = ":WAVeform:DATA?" - wfRawChunk = self.query_binary_values( - qstr, - datatype="b", - header_fmt="ieee", - container=np.array, - chunk_size=(maxreadable + 100), - ) - print(f"{self.wait_until_finished()}") - wfRaw[strt-1:stp] = wfRawChunk - strt += maxreadable - print("waiting") - time.sleep(1) + try: + wfRawChunk = self.query_binary_values( + qstr, + datatype="b", + header_fmt="ieee", + container=np.array, + chunk_size=(chunk_size + 100), + ) + if len(wfRawChunk) == 0: + continue # we need to repeat chunk read + wfRaw[strt-1:stp] = wfRawChunk + chunk_size = min(maxreadable, int(chunk_size*1.2)) + strt += chunk_size + except VisaIOError: + errCnt += 1 + print(f"ERROR count is {errCnt} while reading raw chunk the scope") + print(f"Current pointers are {strt=} {stp=} with {chunk_size=}") + chunk_size = max(1, int(np.ceil(chunk_size/2))) + print(f"new {chunk_size=}") + pass # we repeat this loop iteration again + + + print(f"final {chunk_size=}") if True: return wfRaw |