public void BinarySendTask( ) { byte sequence = 0; while (IsRunning) { if (SendQueue.TryDequeue(out SendDatagram datagram)) { byte [] data = datagram.ToBinary( ); UnderlyingStream.WriteByte(DatagramHeader); UnderlyingStream.WriteByte(sequence); UnderlyingStream.WriteByte(( byte )datagram.Type.BinaryType); UnderlyingStream.WriteByte(data.CaluCrc8( )); UnderlyingStream.WriteByte(Convert.ToByte(data.Length)); UnderlyingStream.Write(data, 0, data.Length); sequence++; } else { Thread.Sleep(20); } } }
/// <summary> /// Writes a 1-byte boolean value to the underlying stream. False is represented by 0, true by 1. /// </summary> public void Write(bool value) { UnderlyingStream.WriteByte((byte)(value ? 1 : 0)); }
/// <summary> /// Writes a 1-byte signed integer value to the underlying stream. /// </summary> public void Write(sbyte value) { UnderlyingStream.WriteByte((byte)value); }