Example #1
0
        public JT808Header Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int         offset      = 0;
            JT808Header jT808Header = new JT808Header();

            // 1.消息ID
            jT808Header.MsgId = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            // 2.消息体属性
            jT808Header.MessageBodyProperty = JT808FormatterExtensions.GetFormatter <JT808HeaderMessageBodyProperty>().Deserialize(bytes.Slice(offset), out readSize);
            offset += readSize;
            // 3.终端手机号 (写死大陆手机号码)
            jT808Header.TerminalPhoneNo = JT808BinaryExtensions.ReadBCDLittle(bytes, ref offset, 12);
            // 4.消息流水号
            jT808Header.MsgNum = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            readSize           = offset;
            return(jT808Header);
        }
Example #2
0
        public JT808_0x0107 Deserialize(ReadOnlySpan <byte> bytes, out int readSize)
        {
            int          offset       = 0;
            JT808_0x0107 jT808_0X0107 = new JT808_0x0107();

            jT808_0X0107.TerminalType       = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset);
            jT808_0X0107.MakerId            = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 5);
            jT808_0X0107.TerminalModel      = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 20);
            jT808_0X0107.TerminalId         = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 7);
            jT808_0X0107.Terminal_SIM_ICCID = JT808BinaryExtensions.ReadBCDLittle(bytes, ref offset, 10);
            jT808_0X0107.Terminal_Hardware_Version_Length = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808_0X0107.Terminal_Hardware_Version_Num    = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X0107.Terminal_Hardware_Version_Length);
            jT808_0X0107.Terminal_Firmware_Version_Length = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808_0X0107.Terminal_Firmware_Version_Num    = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X0107.Terminal_Firmware_Version_Length);
            jT808_0X0107.GNSSModule          = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            jT808_0X0107.CommunicationModule = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset);
            readSize = offset;
            return(jT808_0X0107);
        }