Closed drbitboy closed 1 year ago
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 lgxuvendors.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:
__file__
so lgx_uvendors will definitely fail on look upFor the purposes of micropython which has limited modules, please test as follow before submitting PR:
* os module on micropython has no `__file__` so lgx_uvendors will definitely fail on look up
__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.
I like the approach followed here, so my first question would be has any of this been tested on a device?
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?
run build_mpy.sh (might need to make another bat file for windows)
where do I find mpy-cross?
Update: never mind, got it.
Can you recommend a device?
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