Skip to content

How to return a specific slave excpetion? #207

Description

@Zapnologica

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions