-
Notifications
You must be signed in to change notification settings - Fork 184
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
Micropython/patch1 #212
Micropython/patch1 #212
Conversation
…vice.get_vendor(vendorID) to work in Micropython
FYI: there is a new Python source file under pylogix/ named lgx_uvendors.py. I did not convert that to a .mpy file under upylogix/; the corresponding lgx_uvendors.mpy file under upylogix/ is empty and is intended as a placeholder only. package.json has been modified to put the contents of upylogix/vendors.txt into a file named upylogix/lgx_uvendors.py.txt, which I hope will make finding that file easier when the open(".../lgx_uvendors.py.txt") call is made. |
I like the approach followed here, so my first question would be has any of this been tested on a device? A few comments on this PR:
|
For the purposes of micropython which has limited modules, please test as follow before submitting PR:
|
__file__ is not part of os; every python module has __file__ and __name__ variables, at least in the non-microcontroller (e.g. WSL/Ubuntu) micropython environments. Whether that works on a microcontroller will have to wait until I actually have one. |
no, I don't have one; I have run it in the micropython repl under WSL2, which I had hoped was close to what the environment would be under a device. Can you recommend a device? |
where do I find mpy-cross? Update: never mind, got it. |
I like the esp32 with the wifi module, also the raspberry pi pico. |
Either way, the .keys() should be dropped from vendorID in vendors.keys() in lgx_device.Device.get_vendor as it is both slow (possibly O(N) vs O(logN)) and unnecessary. |
Refactor currently moot approach to dict pylogix.lgx_device.vendors for Micropython
Goal is minimal changes to existing code
What is the change?
An alternate approach to performing vendorID=>vendorNAME lookup for Micropython.
What does it fix/add?
Remove unnecessary mess of code in pylogix/lgx_device.Device.get_vendor(vendorID) method.
Test Configuration