-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to list connected Glasgow boards #208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a lot more complicated than it needs to be.
- The class method on
GlasgowHardwareDevice
should return the list of serials, since that's what you feed back to the constructor. - Definitely no libusb calls should be involved in the caller--we don't want to be tied to USB forever, and also with WinUSB it's easy to "lock yourself out" of a device because handles have exclusive access there.
- The revision is included in the serial--in fact that's how the firmware knows the revision in first place.
- I find it hard to imagine many cases when the USB topology is helpful--if you lost a device it'd be nice to have a "blink a LED" functionality instead of requiring you to remember port numbers on hubs.
- Once you get rid of those, ditch the table header (when not printing to a TTY) and you don't need JSON;
head
works just fine for simple CLI usage. Anything more complicated than that can be scripted through Python, which is why (1) and (2) are important.
Thanks for the feedback.
I think the only contentious point is #4, so I'll think about putting it in a separate patch, and we can drop it if you don't like the idea. |
I'm not sure if this is the UI I want to have. For simple cases, like (host-local) USB and (segment-local) Ethernet, the serial number alone is sufficient (USB can be enumerated, and IPv6 IID can be a part of the serial or you could use broadcasts). For more complex cases, if I bother to use something more meaningful and persistent than serials, I try to refer to boards by aliases (denoting their functions), which generally stays the same, rather than their geographical or network address, which generally changes for benign reasons (DHCP allocated a new IP, hub plugged in a different port, etc). Here's my writeup on setting up udev to assign aliases to USB-serial converters that can only be distinguished geographically. So I'm thinking that this kind of advanced setup (many Glasgow boards and abstraction over specific hardware means you're dropping hundreds of dollars on hardware alone, and quite a bit of time on top of that) could use something like a |
What is the use case of filtering connected boards by their revision? Would it be better served by something like |
No problem, I'm happy to drop this request!
Thanks very much for the link - a good idea for sure. After thinking about it, it's trivial to retrieve the serial number by other means (e.g: sysfs /
Honestly I didn't have a use case in mind for that. A plain list of serials it is! |
752b51e
to
6ff8fbf
Compare
software/glasgow/cli.py
Outdated
@@ -325,6 +325,10 @@ def factory_serial(arg): | |||
default=datetime.now().strftime("%Y%m%dT%H%M%SZ"), | |||
help="serial number in ISO 8601 format (if not specified: %(default)s)") | |||
|
|||
p_list = subparsers.add_parser( | |||
"list", formatter_class=TextHelpFormatter, | |||
help="list glasgows connected to the system") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="list glasgows connected to the system") | |
help="list devices connected to the system") |
This patchset addresses #206.
I have broken
GlasgowHardwareDevice.__init__()
in half, to better support acquiring a list of Glasgow boards, and maintaining the existing firmware loading and filtering of USB devices.The output of
glasgow list
defaults to a text-based table - I've implemented a very simplistic table using onlystr.format()
to avoid adding any dependencies.If the user wishes,
glasgow list -j
can be used to get output as JSON instead, which can then in turn be paired with tools likejq
to perform more complex filtering.Examples: