Skip to content
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

Multiple Slaves? #2

Open
RobWPink opened this issue Dec 8, 2023 · 5 comments
Open

Multiple Slaves? #2

RobWPink opened this issue Dec 8, 2023 · 5 comments

Comments

@RobWPink
Copy link

RobWPink commented Dec 8, 2023

All the examples and explainations are for a single master and slave. Do I need to make multiple Client objects?

@vishnumaiea
Copy link
Member

The CSE_ModbusRTU library supports multiple Servers and Clients running on a single device. You can create as many objects as you want. Just make sure to use unique addresses (and names optionally) to identify them on the bus.

@RobWPink
Copy link
Author

Ok great, Thank you! Last question, it appears this library uses std::vector, which Arduino AVR's standard library doesn't (and can't) include, is there anyway around this? I'm using an Arduino Mega for its multiple Serial ports.

@vishnumaiea
Copy link
Member

I think I overlooked that side of the library. Since Modbus data sizes will be fixed and only set during the instantiation, we can use fixed memory allocation for them. I will soon add a workaround for the problem.

@PedroPiko
Copy link

Hi Vishnu. First of all a would like to appreciate your effort to create this library. I have started to implement it to Mega 2560. I have been facing an issue with std::vector. Finally I have found an solution for that and I put this line to code #include <ArduinoSTL.h>. This library is a port of uClibc++ Arduino library. Also I have some issue to compile code with SoftwareSerial. Finally I have commented out all SoftwareSerial lines in CSE_485.h, nevertheless I am using hardware ports only. My project is about to control heat recovery ventilation unit in house. I am able to read som input registers now (ADU, CRC, send, receive on serial monitor is correct). I am trying to use class CSE_ModbusRTU_ADU. I have defined CSE_ModbusRTU_ADU adu; and than in setup() CSE_ModbusRTU_ADU(); and in the loop () I put this line: unsigned int aduwrd = adu.getLength(); or getByte ..... but I get always 0x00 even though on serial monitor all ADU data is present and correct. Is it possible to explain how to use this in some sample code? Thank you. Mega 2560 board is client and ventilation unit is server.

@vishnumaiea
Copy link
Member

Hi @PedroPiko. Thanks for sharing the workaround for using CSE_ModbusRTU library with Arduino AVR boards. I will try to fix the compatibility issue in the upcoming version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants