/// <summary>
        /// Creates a new BitField from the specified array of bytes.
        /// </summary>
        /// <param name="data">The array of bytes to create the BitField from.</param>
        /// <returns></returns>
        public new static BitField16 FromBytes(byte[] data)
        {
            var bf = new BitField16();

            Array.Copy(data, bf._field, data.Length);
            return(bf);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private object Read(Type type, int size = 0)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            BinaryReader reader = BinaryReader;

            if (type == typeof(byte)) //U1
            {
                return(reader.ReadByte());
            }
            else if (type == typeof(byte[])) //CH
            {
                return(reader.ReadBytes(size));
            }
            else if (type == typeof(short)) //I2
            {
                return(reader.ReadInt16());
            }
            else if (type == typeof(ushort)) //U2
            {
                return(reader.ReadUInt16());
            }
            else if (type == typeof(long) || type == typeof(int)) //I4
            {
                return(reader.ReadInt32());
            }
            else if (type == typeof(ulong) || type == typeof(uint)) //U4
            {
                return(reader.ReadUInt32());
            }
            else if (type == typeof(float)) //R4
            {
                return(reader.ReadSingle());
            }
            else if (type == typeof(double)) //R8
            {
                return(reader.ReadDouble());
            }
            else if (type == typeof(BitField8)) //X1
            {
                return(BitField8.FromBytes(reader.ReadBytes(1)));
            }
            else if (type == typeof(BitField16)) //X2
            {
                return(BitField16.FromBytes(reader.ReadBytes(2)));
            }
            else if (type == typeof(BitField32)) //X4
            {
                return(BitField32.FromBytes(reader.ReadBytes(4)));
            }
            else
            {
                throw new NotSupportedException(nameof(type));
            }
        }
 /// <summary>
 /// Creates an instance with the specified values
 /// </summary>
 public PortConfiguration()
 {
     PortId       = 0x04; // default to SPI
     TxReady      = new BitField16();
     Mode         = new BitField32();
     Reserved2    = new byte[4];
     InProtoMask  = new BitField16();
     OutProtoMask = new BitField16();
     Flags        = new BitField16();
     Reserved3    = new byte[2];
 }
 /// <summary>
 /// Creates an instance with the specified values
 /// </summary>
 public ResetReceiver()
 {
     BbrMask   = new BitField16();
     ResetMode = ResetMode.SoftwareReset;
 }