-
Notifications
You must be signed in to change notification settings - Fork 49
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
Great work! Do you have uasyncio/non-blocking feature in the roadmap? #5
Comments
I'm not sure about async support, but I have managed to get good success in my fork by using My version is primarily intended for Pycopy, not Micropython, so additional libraries like |
Hello! I read a bit about the That I am curious. Why do you use pycopy instead Micropython? Any new/different feature, or your project already running old application with pycopy, or what? Thank you so much. |
I'm not sure. Initially I tried using socket with a 0 timeout but I would never be able to read any messages despite sending them to the server, so I switched to
You're most likely correct, I don't use Modbus RTU and But now when writing multiple registers, I'm facing an issue where the transaction IDs don't match. I wonder if it'll be worth it to switch over to asyncio or not, but I have really no clue.
I mainly work with the UNIX port (my usecase is running hundreds of Modbus clients and servers at the same time, which would have taken ~10GB of memory using CPython+pymodbus, whereas it would probably take <2GB using Pycopy/Micropython), so I didn't work with Modbus RTU, as Pycopy didn't have In fact, that's one of the reasons I moved the TCP server to tcp.py in my fork - because I couldn't even import umodbus.modbus without running into ImportErrors, due to the Serial server which I didn't use anyway. |
Understood. Well, I read a bit more about select and it is not works like as non blocking. It just multiplexing I/O for modern OS, like as freertos, and so on. That shows that is non blocking, but it still blocking. Change the timeout can help, but will not solve. You need to create the socket as non blocking I think the best way is to use uasyncio, for three reasons:
Uasyncio is really the best and easy way for non blocking solution for Modbus. Other way for non blocking is to use thread. But uasyncio is in my opinion is better. EDIT: As a reference, this project is an unfinished project of modbus RTU and TCP (Slave and Master) using uasyncio : |
Interesting, I didn't know how select works. Thanks, I will look into it more.
I agree, async support is ideal. Unfortunately I'm rather hard pressed for time at the moment and so I don't know if I can dedicate much time to implementing async support in the library. Perhaps the maintainer of this repo might be able to, or I might be able to later when I am more free.
Interesting, I will take a look at this later. Perhaps it may be simpler to add async support than I had initially assumed, but I haven't worked enough with async in python to say. |
Hello @GimmickNG
Yes, I think it is simpler than you already done with For the ModBus RTU (UART) I think that you need just to use the For the ModBus TCP you need use
Here is a complete e detailed tutorial to use uasyncio with MicroPython. There has many examples. I hope that can help you a bit! Thank you! |
@beyonlo Sorry for the huge delay, was sidetracked on my research and so I didn't have the time to update my fork earlier. However, I have now added asyncio support for the TCP client and server, with some attempt at pulling changes from the newest branch of this repository. Maybe it might be worth checking to see if it meets your needs. I've also added partial async support for the RTU client, but there is no polling mechanism being used right now for the server like with TCP. Since I am not familiar with UART, this part is left open. Perhaps with some changes it could become fully functional as well. I am not sure whether to make a pull request or not, since there are quite a few incompatibilities because my fork is aimed at Pycopy instead of Micropython. The first thing to change would be the typing module, there are probably some other things as well that may require changing that I am not aware of. |
Hello @GimmickNG
That's a great news, to have Currently @brainelectronics are doing a excellent work fixing the bugs on this
I think that even you are using Thank you very much! |
@GimmickNG thank you so much for your contribution. I've created a milestone to implement and add your changes to this lib |
Thank you. I apologise for making several changes (regarding the naming of the classes and other parts of the package) that would make it more difficult to integrate them, but I can answer any questions that you may have when doing so. Perhaps over the next week or two I might create a new branch in my repo which is solely for compatibility with this library, which would make merging a lot easier, provided I find the time to do so. |
Hi, I talked to you in the past on this issue mcauser/awesome-micropython#38
Do you think do support the uasyncio/non-blocking on the Slave and Master?
Thank you in advance!
The text was updated successfully, but these errors were encountered: