I'm using pyvisa and pyusb to download screen captures from my oscilloscope.
Code: Select all
import visa
import datetime
import time
import re
import csv
from math import floor, log10
class rigol_ds1054z:
# Constructor
def __init__(self, debug=False):
resources = visa.ResourceManager('@py')
# insert your device here
# resources.list_resources() will show you the USB resource to put below
self.oscilloscope = resources.open_resource('USB0::6833::1230::DS1ZA192107675::0::INSTR')
self.debug = debug
if (debug):
visa.log_to_screen()
def print_info(self):
self.oscilloscope.write('*IDN?')
fullreading = self.oscilloscope.read_raw()
readinglines = fullreading.splitlines()
print("Scope information: " + readinglines[0])
time.sleep(2)
def write_screen_capture(self, filename=''):
self.oscilloscope.write(':DISP:DATA? ON,OFF,PNG')
raw_data = self.oscilloscope.read_raw()[11:] # strip off first 11 bytes
# save image file
if (filename == ''):
filename = "rigol_" + datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") +".png"
fid = open(filename, 'wb')
fid.write(raw_data)
fid.close()
print ("Wrote screen capture to filename " + '\"' + filename + '\"')
time.sleep(5)
Code: Select all
from rigol_ds1054z import rigol_ds1054z
scope = rigol_ds1054z(debug=True)
scope.print_info()
scope.write_screen_capture()
This works perfectly on my RPi2 and RPi3, but RPi4 only saves 41bytes out of 30kbytes. I enabled pyusb to create a logfile to compare the RPi3 and RPi4 activity and saw that the only difference in the logfile was:
RPi3:
Code: Select all
2019-09-09 23:09:40,097 DEBUG:usb.backend.libusb1:_LibUSB.is_kernel_driver_active(<usb.backend.libusb1._DeviceHandle object at 0x74a47210>, 0)
2019-09-09 23:09:40,098 DEBUG:usb.backend.libusb1:_LibUSB.detach_kernel_driver(<usb.backend.libusb1._DeviceHandle object at 0x74a47210>, 0)
RPi4:
Code: Select all
2019-09-09 23:05:24,728 DEBUG:usb.backend.libusb1:_LibUSB.is_kernel_driver_active(<usb.backend.libusb1._DeviceHandle object at 0xb49d2170>, 0)
RPi3 and RPi2 detects that the kernel driver is active and detaches, while the RPi4 does not detect that the driver is active. I don't know if this is the root cause of my issue, but I am just trying to understand how RPi3 and RPi4 could have different data traffic when I am using the same python scripts and SD card.