I am complete newbie to OpenWRT/LEDE.
My hardware is TP-LINK MR3020 v3.
What I would like to implement:
- Mobile connection backup by attaching two USB 3G/4G modems.
- Implement hardware RS485 interface, to control and query RS485 MODBUS devices attached to MR3020.
Can you suggest, how can I start with my intentions?
What is the roadmap for me to learn/to do?
Which OpenWRT/LEDE build works for TP-LINK MR3020 v3?
Thank you in advance!
Get comfortable with command-line Linux, if you aren't already.
I hate to say this, but "get a different router" as the MR3020 only has 4 MB of flash, is slow, only has one USB port, and the v3, according to that link, isn't supported by OpenWRT/LEDE at this time.
Past that, make sure that your various USB adapters have driver support.
Jeff, thank you for suggestions. I am a sort of computer guy, so I am familiar with command-line Linux, with C/Python programming. But I still need suggestion.
Let me describe:
I want to build cheap mobile-connected(backed-up) remote controller, as a bridge to remote RS485-controlled relays(no realtime reqs).
The controller should maintain connection to remote server via VPN.
The server should be able to send TCP queries to the controller, that translate to Modbus commands/queries to IO relay board.
I guess that fast router is not required for that purpose, right?
Is that possible to(?):
- Utilize USB hub like this: http://4.bp.blogspot.com/-2UKdaEmjLYE/VnDfAeuVh_I/AAAAAAAAKCI/pOW8zM2y_5Q/s1600/2015-11-17%2B16.58.26.jpg
- Attach USB-RS485 USB Dongle
- Use libmodbus to code TCP-modbus bridge.
- Attach 2 USB 3G modems to the USB hub. Then setup mobile connection backup with std OpenWRT settings.
I know that there are quite expensive OpenWRT-based routers(Teltonika) with RS485 support, so this should be possible.
Can you comment on/correct my assumptions in that area?
I think you're OK with your basic assumptions. It's that I think you're in for a world of pain with a router that doesn't have either the flash or the CPU power to do what you want, not to mention that current versions aren't supported.
While I haven't run OpenWRT/LEDE on a Raspberry Pi myself, I understand that it works rather well. If you go for something like a Pi 3 for $35 (my apologies if not your currency) and a nice case like those from C4Labs at about $15, a microSD card for under $10, and that old USB adapter you've got lying around, for well under $75, I think you're going to have a much better development and operational experience.
Jeff, I made a note on your reasonable hardware suggestion.
Regardless of the hardware: is there some known approach with OpenWRT/LEDE community, that allows to configure tcp-modbus bridge via rs485 usb dongle, for one of the supported routers?
Since python3 is available as a set of packages (though venv support has some problems with
pip as I discovered yesterday), you should be able to leverage that on something with enough "disk" -- either the Raspberry Pi, or by using "extroot" on a USB stick for router-class machines.
Jeff, do you mean some specific Python library for Modbus implementation or Python in general?
Which part of OpenWRT software architecture would allow to setup certain interface as tcp-modbus bridge, can you point me to any docs/examples for this or similar approach?
Last I looked, there were some Python libraries for MODBUS. In general, OpenWRT looks a lot like most any other Linux-based OS, with the notable exceptions more around how the system is initialized and managed, and, thankfully (in my opinion), that it hasn't adopted
systemd. If you needed high-performance MODBUS support, you probably could port one of the libraries over and write in C or C++. At least from what I gather, working with a scripting language might meet your performance needs. Python just happens to be my scripting language of choice these days.
I don't know what you've got "on the other end" or what your application is. It could be anything from sending specific commands to known devices and retrieving short responses, where time is not of the essence, or a fully transparent MODBUS bridge.
Has anyone written any modbus code using Python and run it on OpenWrt? Is there any public open source code that you have used as examples?