public async Task Receive_LaEQ() { ArraySegment <byte> receivedBytes = new ArraySegment <byte>(new byte[128]); WebSocketReceiveResult receiveResult = await ws.ReceiveAsync(receivedBytes, CancellationToken.None); // Create a kaitati stream KaitaiStream kaistream = new KaitaiStream(receivedBytes.Array); // This will check if the package contains magic field WebxiHeader webxiHeader = new WebxiHeader(kaistream); if (webxiHeader.MessageType == WebxiHeader.EMessageType.ESequenceData) { // Get the sequence from the sequence WebxiStream.SequenceData sequenceData = new WebxiStream.SequenceData(kaistream); dynamic Seqblck = sequenceData.SequenceBlocks[0]; // Convert and and scale the value byte[] bytear = { Seqblck.Values[0], Seqblck.Values[1] }; Int16 Value = BitConverter.ToInt16(bytear); float ScaledVal = (float)Value / 100; Console.WriteLine("LaEQ {0} dB", ScaledVal); } }
public WebxiHeader(KaitaiStream p__io, KaitaiStruct p__parent = null, WebxiHeader p__root = null) : base(p__io) { m_parent = p__parent; m_root = p__root ?? this; _read(); }