-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Addig support for using a pre-defined GPIO port for RTU RTS. #156
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
base: master
Are you sure you want to change the base?
Conversation
Please check 'doc/modbus_rtu_set_rts_gpio.txt' for details.
I don't like this. It's too limited. I thought I had a pull request outstanding for my version of this, but I can't find it anywhere public, so I'm going to resurrect it and show an alternate way using custom callbacks for the rts toggling. |
Please have a look at etactica@306e7ab It's too hacky in it's current form to be merged as is, (it needs to be a little better behaved with the existing ioctls, if available, and the timing is rather hardcoded) However, it allows use on old platforms that don't use sysfs for gpios (older linuxes use gpiodev instead, which your proposal doesn't work for), it just gives complete control to the user of how to handle the RTS toggling. I'm extremely sorry I never had this proposed in a RFC/Pull to libmodbus earlier, it's been sitting in a patch here for almost two years :( |
Oh, I otherwise wholeheartedly agree with this functionality :) We actually stopped using this patch as it was simply too slow for certain modbus slave devices we had to deal with, and we ended up modifying the kernel serial driver to handle it properly, but this certainly worked well for us for some devices |
That's right, my mod is totaly specific, and has no support for older kernels. Your custom callback support has much less bottleneck, i think it's fine that you shared with us! What were your experiences when using the unmodded kernel serial driver? What was the highest baud rate with stable operation? |
serial baud was not relevant, it was how quickly certain modbus devices would try to send the reply. With some devices, trying to toggle the RTS line in userspace was simply too slow, and we hadn't dropped the RTS line before the reply came in, resulting in truncated/corrupted modbus replies. We were only working at 19200 at the time anyway. |
is this a working library? I have made the changes suggested by you. or there are some other better library that supports gpio for rts485 pins. Thanks. |
Yes mate, "I could test it successfully on BeagleBone Black, using LTC485 IC to communicate with a Dixell XR40CX thermostat." Where are you stuck in? |
@aronpapp I have timing issues. I not not able to adjust timing properly right now. I am missing sending frames. I need to adjust delays I think. I am using Jetson TK1. |
Hi Stephane,
this extension can be useful on small ARM boards like Raspberry PI, Olinuxino, BeagleBones and so on. These boards usually have many GPIO ports to use as digital input/output, but not eventually having support for controlling RTS through ioctl calls or just the RTS pin overlaps with another port, reserved for some reasons. By specifying the directory where the dedicated GPIO port was mapped to the filesystem, libmodbus can use this port to controll the RS-485 IC's DE/RE pins.
Please feedback to me, if there are things to fix. I could test it successfully on BeagleBone Black, using LTC485 IC to communicate with a Dixell XR40CX thermostat.
Best regards, and thank you for this great library!
Aron Papp