BACnet.Tagging.TagReader.ReadBitString8 C# (CSharp) Method

ReadBitString8() public method

Reads a bitstring tag from the stream
public ReadBitString8 ( byte tag = 255 ) : BitString8
tag byte The tag number of the bitstring tag, or 255 for an application tag
return BACnet.Types.BitString8
        public BitString8 ReadBitString8(byte tag = 255)
        {
            _ensureTag(tag, ApplicationTag.BitString);
            _ensureLength(2, 8);

            byte unused = _reader.ReadByte();
            byte length = (byte)((_length - 1 ) * 8 - unused);

            ulong flags = _reader.ReadByte();
            for(int i = 1; i < _length - 1; i++)
            {
                flags <<= 8;
                flags |= _reader.ReadByte();
            }
            flags >>= (length - 2) * 8;

            return new BitString8(length, (byte)flags);
        }