Replies: 11 comments 23 replies
-
In the current implementation, I have 3 methods running as threads: 2 from UDPTranceiver: https://framagit.org/fma38/pKNyX/-/blob/master/pknyx/stack/transceiver/udpTransceiver.py?ref_type=heads Then, I start apscheduler BackgroundScheduler (I suppose it runs in a thread too). Finally, I just loop forever (this loop can be overwritten if needed, to handle user specific things). The UDPTransceiver threaded methods _receiverLoop() and _transmitterLoop() manage the multicast sockets (in and out). |
Beta Was this translation helpful? Give feedback.
-
I started to migrate the threads to coroutines, and in the way, I needed to changed some internal things, like queues. I'm trying to use Peter's implementation, from 'primitives' package, but I have errors I don't understand. The first one is:
How do I 'await' the get() method? The other error (maybe related) is:
Any help welcome. PS: for now, I run my tests under CPython, as there are a lot of other things to change in order to use Micropython... |
Beta Was this translation helpful? Give feedback.
-
So, next move is to 'async' the multicast sockets, so they don't block while waiting for data: https://framagit.org/fma38/pKNyX/-/blob/master/pknyx/stack/multicastSocket.py?ref_type=heads#L120 Ho do I do that? |
Beta Was this translation helpful? Give feedback.
-
It's may be related to the fact I'm using CPython, but in
adding the 'async' keyword, or I got:
|
Beta Was this translation helpful? Give feedback.
-
Ok, I have a working version :o) But not perfect... I still have an issue with sockets. I'm using the In this code: I had to add a await asyncio.sleep(1) (line 169) in order to let the framework handle the incoming frame after it has been received (line 141). Without it, the loop quickly returns to the socket receive, and blocks everything. Any idea why? |
Beta Was this translation helpful? Give feedback.
-
The strange thing is I also set a timeout! |
Beta Was this translation helpful? Give feedback.
-
Arf, I just
It works! With a short timeout (0.1s), it is ok. I will try to remove the |
Beta Was this translation helpful? Give feedback.
-
Ok, I'm now moving to Micropython :o) Usually, to test my code without installing it, I set PYTHONPATH env dir while executing a script. For example:
The problem is unlike PYTHONPATH with CPython, MICROPYPATH value given on command line replaces the entire content of
And it does not expand the current dir, like PYTHONPATH does... Is there a way to avoid giving the complete paths with Micropython?
|
Beta Was this translation helpful? Give feedback.
-
Another question: Micropython
|
Beta Was this translation helpful? Give feedback.
-
Could it be an IP6 address? The size of 128 bit matches. |
Beta Was this translation helpful? Give feedback.
-
Ok, I tried to deploy upKNyX on a RPi Pico W, and I have a few problems:
For the second point, does Micropython load docstrings in memory? Should I remove them to save memory? |
Beta Was this translation helpful? Give feedback.
-
Hi!
A few years ago, I developped a KNX framwork to create virtual devices more or less the same way real devices work:
https://framagit.org/fma38/pKNyX
I have a few devices running for years on an old router (with OpenWRT firmware), and they work great 24 hours a day.
I just ported pKNyX to python3 (still bugs to fix), and I now have new goals:
For point 1. I guess I will have to remove/simplify things, but I don't really know how to start! Do you have some advices? For example, how to replace threads by asyncio? I never did that...
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions