protected override async Task WriteFrame(MBusFrame frame) { OpenConnection(); var data = frame.ToByteFrame(); Logger.LogHexOut(data); await _udpClient.SendAsync(data.Span.ToArray(), data.Length); }
protected override async Task WriteFrame(MBusFrame frame) { try { _stream.DiscardOutBuffer(); var buffer = frame.ToByteFrame(); Logger.LogHexOut(buffer); await _stream.WriteAsync(buffer); } catch (Exception e) { Logger.LogError($"Could not write frame {e}", e); } }
public virtual async Task <MBusFrame> ResetDevice(int deviceId) { try { Open(); MBusFrame readFrame = MBusFrame.CreateShortFrame(MBus.ControlMaskSndUd, (byte)deviceId); Console.WriteLine(ByteArrayToString(readFrame.ToByteFrame())); await WriteFrame(readFrame); return(await ReadFrame()); } catch { Close(); throw; } }