-
Notifications
You must be signed in to change notification settings - Fork 145
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
Silent period not working for multiple devices #100
Comments
It would be really interesting to see the real waveform on the bus e.g. from the logic analyzer. From my experience, this happens to me when the device does not respect the spec.
If you can't fix the device, you will probably end up with the sleep approach. You can derive a serial port class and override read and/or write functions to add some delay there so you don't need to add them everywhere in the code (see example implementation of manual handling of DE in RS485 https://github.com/pyserial/pyserial/blob/master/serial/rs485.py) |
What a great reply, thanks @j123b567 . The device is 250 miles away. Next time I go there, I will capture the signals. I understood the problem and somehow the idea of fixing it. Device B is not respecting silent period, thus I need to wait more time so it can recognize that I'm talking to him. minimalmodbus/minimalmodbus.py Line 1421 in 185afff
Something like instrument.serial._alternate_rs485_settings.delay_before_tx = 2.005 Also, this approach does have a problem. It will add another delay when M make a second request to A in sequence. M -> A (ok, wait 2.005ms) The great challenge is how to identify that I've changed between devices, since it it handled by python async itself? |
I'm using minimalmodbus to read multiple drivers in a roll.
When there is only one device, I have no problem.
When I use two units, I start to get unresponsiveness. After debugging, I noticed that this arise due to silent period not being respected. Same problem as stated here.
To fix it, I just added a
time.sleep(.0031)
before each minimalmodbus call.Now comes the issue. I'm using async to improve the code performance and avoid blocking it. During those 3,1ms that I'm blocking my code, I could be doing something else. Is there a way to put this silent period inside the minimalmodbus function?
When I call
self.instrument.read_registers(49, 1)
, it should block it self for another writing. I'm kind lost how to fix it.The text was updated successfully, but these errors were encountered: