8000 How to return a specific slave excpetion? · Issue #207 · NModbus/NModbus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to return a specific slave excpetion? #207

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
Zapnologica opened this issue Mar 29, 2025 · 0 comments
Open

How to return a specific slave excpetion? #207

Zapnologica opened this issue Mar 29, 2025 · 0 comments

Comments

@Zapnologica
Copy link

I have the following in my custom ISlaveDatStote:

    public TPoint[] ReadPoints(ushort id, ushort numberOfPoints)
     {
         _logger.LogDebug($"Received request to read registers with Id {id} and number of points {numberOfPoints}");

         // this is the start of the register you are reading from
         if (!_dataPollingService.DataMappings.TryGetValue(id, out var mapping))
         {
             throw new SlaveException($"register {id} does not exist in the mappings file.");                
         }
     }

How can I throw an exception with the specific error response code in modbus? I want to differentiate between invalid address and invalid data value?

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

1 participant
0