In [2]:
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
# TRYING TO ADAPT THE SCRIPT FOR THE MICSIG oscilloscope
# Create ownership rule as /etc/udev/rules.d/99-micsig.rules
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="0303", GROUP="medved", MODE="0666"
class UsbTmcDriver:
def __init__(self, device):
self.device = device
self.FILE = os.open(device, os.O_RDWR)
def write(self, command):
os.write(self.FILE, command);
def read(self, length = 2048):
return os.read(self.FILE, length)
def getName(self):
self.write("*IDN?")
return self.read(300)
def sendReset(self):
self.write("*RST") # Be carefull, this real resets an oscilloscope
# Looking for USBTMC device
def getDeviceList():
dirList=os.listdir("/dev")
result=list()
for fname in dirList:
if(fname.startswith("usbtmc")):
result.append("/dev/" + fname)
return result
# looking for oscilloscope
devices = getDeviceList()
# initiate oscilloscope
osc = UsbTmcDriver(devices[0])
print osc.getName()
osc.write(":STOP")
time.sleep(.2)
osc.write(':WAV:SOUR CHAN1')
time.sleep(.2)
osc.write(':WAV:XINC?')
time.sleep(.2)
data = bytearray(osc.read(500))
print data
osc.write(':WAV:YINC?')
time.sleep(.2)
data = bytearray(osc.read(500))
print data
In [8]:
osc.write("MENU:RUN")
time.sleep(1)
'''
osc.write(':WAV:SOUR CHAN1')
time.sleep(.2)
osc.write(':WAV:MODE NORM')
time.sleep(.2)
osc.write(':WAV:DATA?')
time.sleep(.2)
wave1 = bytearray(osc.read(500))
print wave1
time.sleep(.2)
osc.write("MENU:STOP")
time.sleep(.2)
osc.write(':WAV:SOUR CHAN1')
time.sleep(.2)
osc.write(':WAV:MODE RAW')
time.sleep(.2)
osc.write(':WAV:RESet')
time.sleep(.2)
osc.write(':WAV:BEGin')
time.sleep(.2)
osc.write(':WAV:STATus?')
time.sleep(.2)
wave1 = bytearray(osc.read(500))
print wave1
'''
osc.write("MENU:STOP")
time.sleep(1)
#osc.write(':STORage:SAVECH1,UDISK')
osc.write(':STORage:CAPTure')
In [27]:
osc.write(':WAV:DATA?')
time.sleep(.2)
wave1 = bytearray(osc.read(500))
print wave1
#osc.write(':WAV:END')
#time.sleep(.2)
In [ ]: