-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Refactoring of write methods, adding device selection #48
base: master
Are you sure you want to change the base?
Refactoring of write methods, adding device selection #48
Conversation
On some systems using libusb it was not possible to call the program (write to the device) a second time without detaching the device. Dispose_resources + reset should solve this problem.
So, multiple devices can be connected at the same time and one can get a list and choose via command line parameter.
…oring-of-write-methods # Conflicts: # README.md # lednamebadge.py
4e662b1
to
aba522f
Compare
To be backwards compatible, using Windows with hidapi is not forbidden. But now, you have to select it explicitly.
method = libusb.get_name() | ||
print("Preferring method %s over %s with Python 2.x" % (libusb.get_name(), hidapi.get_name())) | ||
print("because of https://github.com/jnweiger/led-badge-ls32/issues/9") | ||
elif sys.platform.startswith('darwin'): |
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.
Hello @s-light, Jürgen gave me the info, that you might be able to test this new version with MacOs? That would be great!
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.
oh sorry - not really..
i have no led-badge myself - and the macos devices are owned by my mother & brother - currently not living near by...
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.
Ok, thanks and sorry for bothering...
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.
all fine :-)
With this refactoring the handling of different write methods (up to now libusb and hidapi) has moved to an own class and its sub classes. This is a preparation to smoothly add bluetooth as a third write method in future and to be able to implement the following.
Additionally, there is the possibility list the connected devices and choose the one to be programmed. This way multiple devices may be connected to one computer and be programmed individually. With this change the endpoint number is not hardcoded anymore and the newer types of the name badge (with other USB chips) are found and programmed.
See command line options -M and -H / LedNameBadge.write(), LedNameBadge.get_available_methods(), LedNameBadge.get_available_device_ids() / class WriteMethod and its two sub classes.
All (ok, most) the decisions, validations and messages on choosing write mehtods and device ids are now concentrated in LedNameBadge._find_write_method().
It should still run on Windows (tested with pPython 3), MacOs (untested) and Python 2 (tested with Ubuntu linux)
Draft: some method documentation is still missing.