-
Notifications
You must be signed in to change notification settings - Fork 129
Make RS485Class a constructor arg to ModbusRTUClientClass and ModbusRTUServerClass #14
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
Make RS485Class a constructor arg to ModbusRTUClientClass and ModbusRTUServerClass #14
Conversation
What about going even further and calling it "transport" rather than "rs485"? I myself would very much like to have a RS232 transport as well. |
@nud that's a good suggestion! I didn't know RTU also supported RS232. Have you tested this pull request? Would you be update for adding RS232 support? Let me know, we can merge this one and you can submit another pull request for it. |
Have you had success getting this to work? I have a use case for specifying the hardware serial port I want to use, trying to get the Sparkfun AST-CAN485 running as a ModbusRTU slave. The RS-485 chip is hard wired to Serial1. |
I'd also like to see the interface abstracted from the protocol. For use with RS232 and also the native USB Serial Port (which is typically only used for debugging with "Serial Monitor"). |
I like this idea... Realistically the best option would be to have each layer of the OSI model as a separate modular bit of code. |
@sandeepmistry, I've tested your code with the KitchenSink's example, ModbusRTUServerKitchenSink and ModbusRTUClientKitchenSink. Steps:
[...] some code before here
RS485Class _RS485(Serial2, txPin, dePin, rePin);
void setup() {
ModbusRTUClient = ModbusRTUClientClass(_RS485);
[...] some code after here
Results:
If I turn the Server off, I get all the results as I've also changed SugestionWould be really good to have this option in the |
@sandeepmistry, please let me know if there are any other tests that you would like me to run. |
|
This branch is working like a charm.
Solves the problem that the RS485 class is hardcoded in the ArduinoModbus. |
Can be changed by either the constructor or begin() Ports and replaces #14
This is an alternative to pull request #11
Instead of having a parameter to
begin(...)
a newModbusRTUClientClass
orModbusRTUServerClass
instance can be declared with an alternativeRS485Class
instance.