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

CSE_ModbusRTU_ADU class #3

Open
PedroPiko opened this issue Dec 15, 2023 · 1 comment
Open

CSE_ModbusRTU_ADU class #3

PedroPiko opened this issue Dec 15, 2023 · 1 comment

Comments

@PedroPiko
Copy link

PedroPiko commented Dec 15, 2023

My project is about to control heat recovery ventilation unit in house. I am able to read some 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 then 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 CSE_ModbusRTU_ADU class in some sample code? Thank you. My Mega 2560 board is client and ventilation unit is server.

@vishnumaiea
Copy link
Member

Hi @PedroPiko. Sorry for the delay after our first interaction. I am editing the styling of your comment to make it easy to read.

The class CSE_ModbusRTU_ADU can be used to create standlone ModbusRTU packets. The usage is well explained in the API.md document. In order to read from the ADU, you will need to first write data to it. When the CSE_ModbusRTU_ADU class is used in conjunction with the CSE_ModbusRTU_Server and CSE_ModbusRTU_Client classes, they take care of writing to the ADUs.

So when using the CSE_ModbusRTU_ADU directly, you need to make sure that you add data to the object first.

I also don't understand why you have,

CSE_ModbusRTU_ADU();

in your setup() function. It is unnecessary. Global objects are instantiated where they are declared.

Please let me know if you have gained a better understanding of the library while I was away, and any other suggestions for improving the library and its documentation.

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

2 participants