aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-05-28 15:51:58 +0200
committerChristoph Muellner <christoph.muellner@theobroma-systems.com>2019-05-28 23:48:22 +0200
commit78ad800aea2a78a131597b89584a0ee21c45fb61 (patch)
treea6606b87cb3f91644b47d352d05c572f7b84cc40
parentf61164c0e98f32904e6a2552290786d43e4e402e (diff)
haikou.py: Add option to disable product string matcher.
On some base boards we don't have a matching product string, therefore the product string matching code fails and the tool does not find the base board. This patch adds the flag '-i' to ignore the product string. Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
-rwxr-xr-xusb-control/haikou.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/usb-control/haikou.py b/usb-control/haikou.py
index bccc1e7..808c8a3 100755
--- a/usb-control/haikou.py
+++ b/usb-control/haikou.py
@@ -45,6 +45,8 @@ subparser = parser.add_subparsers(title='subcommands', dest='subcommand', \
help='call with -h for additional parameters')
parser_list = subparser.add_parser('list', help='lists serial numbers of \
attached Haikou Baseboards')
+parser_list.add_argument('--ignore-product-string','-i',action='store_true', \
+ dest='ignore_product_string', help='ignore product string')
parser_power = subparser.add_parser('power', help='control the power state')
parser_power.add_argument('power_cmd', choices=['on','off','reset','status'], \
help='set or get the power status of the baseboard')
@@ -59,8 +61,18 @@ args = parser.parse_args()
if args.subcommand == 'list':
try:
- dev = list(usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID, \
- product=PRODUCT_STRING, find_all=True))
+ kwargs = dict()
+ kwargs['idVendor'] = VENDOR_ID
+ kwargs['idProduct'] = PRODUCT_ID
+ if args.ignore_product_string != True:
+ kwargs['product'] = PRODUCT_STRING
+ kwargs['find_all'] = True
+
+ # Find the devices matching the specified requirements
+ dev_it = usb.core.find(**kwargs)
+
+ # Convert iterator to list
+ dev = list(dev_it)
except ValueError, e:
if 'langid' in e.message: