internal int RequestBytesToRead(byte[] frameStart) { byte functionCode = frameStart[1]; IModbusFunctionService service = _modbusFactory.GetFunctionService(functionCode); if (service == null) { string msg = $"Function code {functionCode} not supported."; Logger.Warning(msg); throw new NotImplementedException(msg); } return(service.GetRtuRequestBytesToRead(frameStart)); }
public static IModbusMessage CreateModbusRequest(this IModbusFactory factory, byte[] frame) { if (frame.Length < MinRequestFrameLength) { string msg = $"Argument 'frame' must have a length of at least {MinRequestFrameLength} bytes."; throw new FormatException(msg); } byte functionCode = frame[1]; var functionService = factory.GetFunctionService(functionCode); return(functionService.CreateRequest(frame)); }
public static IModbusFunctionService GetFunctionServiceOrThrow(this IModbusFactory factory, byte functionCode) { IModbusFunctionService service = factory.GetFunctionService(functionCode); if (service == null) { string msg = $"Function code {functionCode} not supported."; factory.Logger.Warning(msg); throw new NotImplementedException(msg); } return(service); }