Closed poesel closed 4 years ago
Dear @poesel,
thanks for your heads up.
It looks like we have been too quick adding CPython support without taking enough care about MicroPython.
MicroPython does not offer the flush()
method on socket streams. So, let's use the buffering=False
parameter on the makefile()
method instead.
We updated this by [1] and [2]. Please purge your local dist-packages
folder and re-run make setup
.
With kind regards, Andreas.
[1] https://github.com/daq-tools/pycopy-lib/commit/bbd1b27028e6747b2321fa16cbce7b3d85fc56d8 [2] https://github.com/daq-tools/pycopy-lib/commit/22149dcec3209110bda4585e0a294e8e79961d71
Fixed it but now we have:
Traceback (most recent call last):
File "/lib/terkin/telemetry.py", line 684, in connect
File "/dist-packages/umqtt.py", line 65, in connect
TypeError: function doesn't take keyword arguments
Can you try to remove the keyword identifiers from
self.stream = self.sock.makefile(mode="rwb", buffering=False)
like
self.stream = self.sock.makefile("rwb", False)
Otherwise, just try to say
self.stream = self.sock.makefile("rwb")
That does the trick:
if platform_info.vendor == platform_info.MICROPYTHON.Pycom:
self.stream = self.sock.makefile(mode="rwb", buffering=False)
elif platform_info.vendor == platform_info.MICROPYTHON.Vanilla:
self.stream = self.sock.makefile('rwb', 0)
Despite what the documentation at [1] is saying, you will have to use positional arguments and pass False
as 0
(zero) to make things work.
[1] https://docs.micropython.org/en/latest/library/usocket.html#usocket.socket.makefile
Now, that is in umqtt.py
which is in dist-packages
. Where do we get that from?
Dear @poesel,
thanks for confirming how it would work! I've fixed the umqtt
library through https://github.com/daq-tools/pycopy-lib/commit/b898366f. The CPython-based tests are still succeeding and I hope it will now also work on MicroPython again.
Please just invoke make setup
in order to pull the most recent versions into your dist-packages
folder.
With kind regards, Andreas.
P.S.: I've also reported your findings upstream through https://github.com/micropython/micropython/issues/5915.
I could of course just comment this out for ESP32 but I'm not sure what it exactly does and if its important.