cli: open by serial, or default to first board

parent 3847d66f
......@@ -31,21 +31,20 @@ class OauTest(cmd.Cmd):
self.nchannels = None
def do_open(self, arg):
"""open lun"""
"""open device by serial number"""
try:
lun = int(arg) if arg else 0
serial = arg if arg else c_void_p(0)
except ValueError as e:
print('usage: open lun')
print('usage: open [serial]')
return
fd = self.api.oau_att_open(lun)
fd = self.api.oau_att_open(serial)
if fd < 0:
print('cannot open lun {}'.format(lun))
print('cannot open device {}'.format(serial))
return
self.lun = lun
self.fd = fd
self.nchannels = self.read_nchannels()
print('current device: lun {}, fd {}, {} channels'.format(
lun, fd, self.nchannels))
print('current device: serial {}, fd {}, {} channels'.format(
serial, fd, self.nchannels))
def do_close(self, arg):
"""close connection to current device."""
......
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