8000 How to tell slave to not send data until data is save to send? · Issue #174 · NModbus/NModbus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to tell slave to not send data until data is save to send? #174

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

Open
CodeMarc42 opened this issue Feb 8, 2024 · 2 comments
Open

How to tell slave to not send data until data is save to send? #174

CodeMarc42 opened this issue Feb 8, 2024 · 2 comments

Comments

@CodeMarc42
Copy link

Hi, i have a slave that i have to write in them coils and registers, then i do it first writing coils, and then writing the registers.

But what will happend if a master request me data, if i dont had writted all? My idea was to try to implement a event when a request to the slave arribe, to then in there make it wait until some flag tells the program that the new data is fully writed and updated....

But reading and searching for info about this i m not lucky and not found a tip yet on how to do it.

Any idea, example ot method that i m missing and that can help me in that issue? Thanks

@CodeMarc42
Copy link
Author

After searching more and keep doing test:

    SlaveDataStore dataStore = new NModbus.Data.SlaveDataStore();
    dataStore.CoilDiscretes.BeforeRead += OnBeforeRead;
    this.slave = factory.CreateSlave(1, dataStore);

You think that something like this will do the trick? Placing in OnBeforeRead a flag or mutex to know when the data that can i be writing updated?

1 WriteCoils,
2 ReadCoils (check updating flag or mutex, cause i m yet updating data i make the read to wait)
3 WriteREgisters
4 Setup flag or mutex, updating data to false
5 Previos ReadCoils continue and end the read and send data to requester

@Magniveo
Copy link
Magniveo commented Feb 9, 2024

I might be wrong, you can make it via functionService, look in the sample.
StartModbusSerialRtuSlaveWithCustomMessage

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
0