cli: open by serial, or default to first board

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