Пример #1
0
        public int ParseInt16()
        {
            var buffer = HexEncoding.HexStringToByteArray(ReadCharacters(4));

            Array.Reverse(buffer); // LSB -> MSB stuff
            return(BitConverter.ToInt16(buffer, 0));
        }
Пример #2
0
        public ulong ParseUInt32()
        {
            var buffer = HexEncoding.HexStringToByteArray(ReadCharacters(8));

            Array.Reverse(buffer);
            return((ulong)BitConverter.ToUInt32(buffer, 0));
        }
Пример #3
0
        public DateTime ParseTime()
        {
            Log.LogTrace("Enter");
            var buffer = HexEncoding.HexStringToByteArray(ReadCharacters(8));

            Array.Reverse(buffer); // MSB -> LSB stuff
            var seconds = BitConverter.ToInt32(buffer, 0);
            var result  = new DateTime(2007, 1, 1).AddSeconds(seconds);

            Log.LogTrace("Return - {result}", result);
            return(result);
        }
Пример #4
0
        public ulong Read24bits(string value)
        {
            Log.LogTrace("Enter - value: {value}", value);

            if (string.IsNullOrEmpty(value))
            {
                return(UInt64.MaxValue);
            }

            var buffer = HexEncoding.HexStringToByteArray(value + "0000000000"); // todo: fix this quick fix... array length not sufficient for ulong

            //Array.Reverse(buffer);
            return(BitConverter.ToUInt64(buffer, 0));
        }
Пример #5
0
        public byte ParseByte()
        {
            var buffer = HexEncoding.HexStringToByteArray(ReadCharacters(2));

            return(buffer[0]);
        }