Commit e0bc7fa4 authored by Dimitris Lampridis's avatar Dimitris Lampridis

cli: avoid hard-coding CERN VID and PID

parent ed89ad4c
......@@ -28,6 +28,9 @@ class DevArray(Structure):
class OattnUsbTest(cmd.Cmd):
VENDOR_ID = 0x1556 # CERN USB Vendor ID
DEVICE_ID = 0x0443 # oau USB Device ID
attn_values = {
'-40dB' : 0,
'-20dB' : 1,
......@@ -50,7 +53,7 @@ class OattnUsbTest(cmd.Cmd):
self.nchannels = None
self.load_solib()
self.fill_devarray()
self.devices = self.fill_devarray(self.VENDOR_ID, self.DEVICE_ID)
def load_solib(self):
"""try to load attn dyn library from script dir or ../lib."""
......@@ -71,15 +74,15 @@ class OattnUsbTest(cmd.Cmd):
exit()
def fill_devarray(self):
def fill_devarray(self, vid, pid):
self.api.oattnusb_get_devarray.restype = POINTER(DevArray)
self.devarray = self.api.oattnusb_get_devarray(0x1556, 0x0443)
self.devarray = self.api.oattnusb_get_devarray(vid, pid)
ndevs = self.devarray.contents.ndevs
devs = self.devarray.contents.devs
self.devices = []
devices = []
for i in range(ndevs):
dev = devs[i]
self.devices.append({
devices.append({
'lun' : dev.lun,
'busnum' : str(dev.busnum, 'utf8'),
'devnum' : str(dev.devnum, 'utf8'),
......@@ -88,6 +91,7 @@ class OattnUsbTest(cmd.Cmd):
'devno' : str(dev.devno, 'utf8'),
'serial' : str(dev.serial, 'utf8'),
'path' : str(dev.path , 'utf8')})
return devices
def do_list(self, arg):
"""list devices and their access methods."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment