public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1502 value, IJT809Config config)
        {
            writer.WriteByte((byte)value.PhotoRspFlag);
            writer.WriteByte((byte)value.VehiclePosition.Encrypt);
            writer.WriteByte(value.VehiclePosition.Day);
            writer.WriteByte(value.VehiclePosition.Month);
            writer.WriteUInt16(value.VehiclePosition.Year);
            writer.WriteByte(value.VehiclePosition.Hour);
            writer.WriteByte(value.VehiclePosition.Minute);
            writer.WriteByte(value.VehiclePosition.Second);
            writer.WriteUInt32(value.VehiclePosition.Lon);
            writer.WriteUInt32(value.VehiclePosition.Lat);
            writer.WriteUInt16(value.VehiclePosition.Vec1);
            writer.WriteUInt16(value.VehiclePosition.Vec2);
            writer.WriteUInt32(value.VehiclePosition.Vec3);
            writer.WriteUInt16(value.VehiclePosition.Direction);
            writer.WriteUInt16(value.VehiclePosition.Altitude);
            writer.WriteUInt32(value.VehiclePosition.State);
            writer.WriteUInt32(value.VehiclePosition.Alarm);
            writer.WriteByte(value.LensID);
            bool isPhoto = (value.Photo != null && value.Photo.Length > 0);

            writer.WriteUInt32(isPhoto ? (uint)value.Photo.Length : 0);
            writer.WriteByte(value.SizeType);
            writer.WriteByte(value.Type);
            if (isPhoto)
            {
                writer.WriteArray(value.Photo);
            }
        }
Example #2
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1202 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2011)
     {
         writer.WriteByte((byte)value.VehiclePosition.Encrypt);
         writer.WriteByte(value.VehiclePosition.Day);
         writer.WriteByte(value.VehiclePosition.Month);
         writer.WriteUInt16(value.VehiclePosition.Year);
         writer.WriteByte(value.VehiclePosition.Hour);
         writer.WriteByte(value.VehiclePosition.Minute);
         writer.WriteByte(value.VehiclePosition.Second);
         writer.WriteUInt32(value.VehiclePosition.Lon);
         writer.WriteUInt32(value.VehiclePosition.Lat);
         writer.WriteUInt16(value.VehiclePosition.Vec1);
         writer.WriteUInt16(value.VehiclePosition.Vec2);
         writer.WriteUInt32(value.VehiclePosition.Vec3);
         writer.WriteUInt16(value.VehiclePosition.Direction);
         writer.WriteUInt16(value.VehiclePosition.Altitude);
         writer.WriteUInt32(value.VehiclePosition.State);
         writer.WriteUInt32(value.VehiclePosition.Alarm);
     }
     else
     {
         writer.WriteByte((byte)value.GNSSData.Encrypt);
         writer.Skip(4, out int position);
         writer.WriteArray(value.GNSSData.GnssData);
         writer.WriteUInt32Return((uint)(writer.GetCurrentPosition() - position - 4), position);
         writer.WriteStringPadRight(value.GNSSData.PlatformId1, 11);
         writer.WriteUInt32(value.GNSSData.Alarm1);
         writer.WriteStringPadRight(value.GNSSData.PlatformId2, 11);
         writer.WriteUInt32(value.GNSSData.Alarm2);
         writer.WriteStringPadRight(value.GNSSData.PlatformId3, 11);
         writer.WriteUInt32(value.GNSSData.Alarm3);
     }
 }
 public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B02 value, IJT809Config config)
 {
     writer.WriteByte((byte)value.Result);
     writer.WriteUInt16(value.SessionId);
     writer.WriteStringPadLeft(value.ServerIp, 32);
     writer.WriteUInt16(value.TcpPort);
     writer.WriteStringPadLeft(value.UserName, 49);
     writer.WriteStringPadLeft(value.Password, 22);
     writer.WriteStringPadLeft(value.FilePath, 200);
 }
Example #4
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9505 value, IJT809Config config)
 {
     writer.WriteBCD(value.AuthenticationCode, 20);
     writer.WriteStringPadRight(value.AccessPointName, 20);
     writer.WriteStringPadRight(value.UserName, 49);
     writer.WriteStringPadRight(value.Password, 22);
     writer.WriteStringPadRight(value.ServerIP, 32);
     writer.WriteUInt16(value.TcpPort);
     writer.WriteUInt16(value.UdpPort);
     writer.WriteUTCDateTime(value.EndTime);
 }
Example #5
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9103 value, IJT809Config config)
 {
     writer.WriteUInt16(value.SubBusinessType);
     // 先写入内容,然后在根据内容反写内容长度
     writer.Skip(4, out int subContentLengthPosition);
     writer.WriteByte((byte)value.ManageMsgSNInform.Count);
     foreach (var item in value.ManageMsgSNInform)
     {
         writer.WriteUInt16(item.SubBusinessType);
         writer.WriteUInt32(item.MsgSN);
         writer.WriteUTCDateTime(item.Time);
     }
     writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition);
 }
Example #6
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1402 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2011)
     {
         writer.WriteByte((byte)value.WarnSrc);
     }
     else
     {
         writer.WriteStringPadRight(value.SourcePlatformId, 11);
     }
     writer.WriteUInt16((ushort)value.WarnType);
     writer.WriteUTCDateTime(value.WarnTime);
     if (config.Version == JT809Version.JTT2011)
     {
         writer.WriteUInt32(value.InfoID);
     }
     else
     {
         writer.WriteUTCDateTime(value.StartTime);
         writer.WriteUTCDateTime(value.EndTime);
         writer.WriteStringPadRight(value.VehicleNo, 21);
         writer.WriteByte((byte)value.VehicleColor);
         writer.WriteStringPadRight(value.DestinationPlatformId, 11);
         writer.WriteUInt32(value.DRVLineId);
     }
     // 先计算内容长度(汉字为两个字节)
     writer.Skip(4, out int lengthPosition);
     writer.WriteString(value.InfoContent);
     writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition);
 }
Example #7
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9600 value, IJT809Config config)
 {
     writer.WriteStringPadRight(value.VehicleNo, 21);
     writer.WriteByte((byte)value.VehicleColor);
     writer.WriteUInt16(value.SubBusinessType);
     try
     {
         // 先写入内容,然后在根据内容反写内容长度
         writer.Skip(4, out int subContentLengthPosition);
         if (value.SubBodies != null)
         {
             if (!value.SubBodies.SkipSerialization)
             {
                 JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize(
                     value.SubBodies,
                     ref writer, value.SubBodies,
                     config);
             }
         }
         writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition);
     }
     catch
     {
         throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
     }
 }
Example #8
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1001 value, IJT809Config config)
 {
     writer.WriteUInt32(value.UserId);
     writer.WriteStringPadRight(value.Password, 8);
     writer.WriteStringPadRight(value.DownLinkIP, 32);
     writer.WriteUInt16(value.DownLinkPort);
 }
        public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9504 value, IJT809Config config)
        {
            writer.WriteByte((byte)value.Command);
            switch (value.Command)
            {
            case JT809CommandType.记录仪标准版本:
            case JT809CommandType.当前驾驶人信息:
            case JT809CommandType.记录仪时间:
            case JT809CommandType.记录仪累计行驶里程:
            case JT809CommandType.记录仪脉冲系数:
            case JT809CommandType.车辆信息:
            case JT809CommandType.记录仪状态信号配置信息:
            case JT809CommandType.记录仪唯一性编号:
                break;

            case JT809CommandType.采集记录仪行驶记录:
            case JT809CommandType.采集记录仪位置信息记录:
            case JT809CommandType.采集记录仪事故疑点记录:
            case JT809CommandType.采集记录仪超时驾驶记录:
            case JT809CommandType.采集记录仪驾驶人身份记录:
            case JT809CommandType.采集记录仪外部供电记录:
            case JT809CommandType.采集记录仪参数修改记录:
            case JT809CommandType.采集记录仪速度状态日志:
                writer.WriteDateTime6(value.StartTime);
                writer.WriteDateTime6(value.EndTime);
                writer.WriteUInt16(value.Max);
                break;
            }
        }
Example #10
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1206 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSN);
         writer.WriteUInt32(value.DataLength);
     }
 }
Example #11
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9209 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     writer.WriteByte((byte)value.Result);
 }
Example #12
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9102 value, IJT809Config config)
 {
     writer.WriteUInt16(value.SubBusinessType);
     writer.Skip(4, out int subContentLengthPosition);
     writer.WriteStringPadRight(value.PlateformId, 11);
     writer.WriteUTCDateTime(value.StartTime);
     writer.WriteUTCDateTime(value.EndTime);
     writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition);
 }
Example #13
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1600_0x1601 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     writer.WriteString(value.CarInfo);
 }
Example #14
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120B value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     writer.WriteUInt32((uint)value.EwaybillInfo.Length);
     writer.WriteString(value.EwaybillInfo);
 }
Example #15
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9403 value, IJT809Config config)
 {
     writer.WriteByte((byte)value.WarnSrc);
     writer.WriteUInt16((ushort)value.WarnType);
     writer.WriteUTCDateTime(value.WarnTime);
     // 先计算内容长度(汉字为两个字节)
     writer.Skip(4, out int lengthPosition);
     writer.WriteString(value.WarnContent);
     writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition);
 }
Example #16
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809Header value, IJT809Config config)
 {
     writer.WriteUInt32(value.MsgLength);
     writer.WriteUInt32(value.MsgSN);
     writer.WriteUInt16(value.BusinessType);
     writer.WriteUInt32(value.MsgGNSSCENTERID);
     writer.WriteArray(value.Version.Buffer);
     writer.WriteByte((byte)value.EncryptFlag);
     writer.WriteUInt32(value.EncryptKey);
 }
 public void Serialize(ref JT809MessagePackWriter writer, JT809VehiclePositionProperties value, IJT809Config config)
 {
     writer.WriteByte((byte)value.Encrypt);
     writer.WriteByte(value.Day);
     writer.WriteByte(value.Month);
     writer.WriteUInt16(value.Year);
     writer.WriteByte(value.Hour);
     writer.WriteByte(value.Minute);
     writer.WriteByte(value.Second);
     writer.WriteUInt32(value.Lon);
     writer.WriteUInt32(value.Lat);
     writer.WriteUInt16(value.Vec1);
     writer.WriteUInt16(value.Vec2);
     writer.WriteUInt32(value.Vec3);
     writer.WriteUInt16(value.Direction);
     writer.WriteUInt16(value.Altitude);
     writer.WriteUInt32(value.State);
     writer.WriteUInt32(value.Alarm);
 }
Example #18
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1102 value, IJT809Config config)
 {
     writer.WriteUInt16(value.SubBusinessType);
     writer.WriteUInt32(value.DataLength);
     writer.WriteStringPadRight(value.PlateformId, 11);
     writer.WriteUTCDateTime(value.StartTime);
     writer.WriteUTCDateTime(value.EndTime);
     writer.WriteUInt32(value.LoseDymamicSum);
     writer.WriteByte(value.DisconnectNum);
     writer.WriteUInt32(value.DisconnectTime);
 }
Example #19
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1001 value, IJT809Config config)
 {
     writer.WriteUInt32(value.UserId);
     writer.WriteStringPadRight(value.Password, 8);
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt32(value.MsgGNSSCENTERID);
     }
     writer.WriteStringPadRight(value.DownLinkIP, 32);
     writer.WriteUInt16(value.DownLinkPort);
 }
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9401 value, IJT809Config config)
 {
     writer.WriteByte((byte)value.WarnSrc);
     writer.WriteUInt16((ushort)value.WarnType);
     writer.WriteUTCDateTime(value.WarnTime);
     writer.WriteHex(value.SupervisionID, 4);
     writer.WriteUTCDateTime(value.SupervisionEndTime);
     writer.WriteByte(value.SupervisionLevel);
     writer.WriteStringPadRight(value.Supervisor, 16);
     writer.WriteStringPadRight(value.SupervisorTel, 20);
     writer.WriteStringPadRight(value.SupervisorEmail, 32);
 }
Example #21
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1302 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     else
     {
         writer.WriteUInt32(value.InfoID);
     }
 }
Example #22
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1413 value, IJT809Config config)
 {
     writer.WriteBigNumber(value.SourcePlatformId, 11);
     writer.WriteUTCDateTime(value.WarnTime);
     writer.WriteUInt16(value.SourceDataType);
     writer.WriteUInt32(value.SourceMsgSn);
     writer.WriteUTCDateTime(value.SupervisionEndTime);
     writer.WriteByte((byte)value.SupervisionLevel);
     writer.WriteStringPadRight(value.Supervisor, 16);
     writer.WriteStringPadRight(value.SupervisorTel, 20);
     writer.WriteStringPadRight(value.SupervisorEmail, 32);
 }
Example #23
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1504 value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
         writer.WriteByte((byte)value.CommandType);
     }
     // 先计算内容长度(汉字为两个字节)
     writer.Skip(4, out int lengthPosition);
     writer.WriteArray(value.TraveldataInfo);
     writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition);
 }
Example #24
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1303 value, IJT809Config config)
 {
     if (value.EndMessageNumber - value.BeginMessageNumber >= byte.MaxValue)
     {
         throw new JT809Exception(JT809ErrorCode.IllegalArgument, "序列号间隔不能大于255");
     }
     value.SerialCount = (byte)(value.EndMessageNumber - value.BeginMessageNumber + 1);
     writer.WriteUInt16(RetranDataType);
     writer.WriteByte(value.SerialCount);
     writer.WriteUInt32(value.BeginMessageNumber);
     writer.WriteUInt32(value.EndMessageNumber);
     writer.WriteUTCDateTime(value.Time);
 }
Example #25
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120A value, IJT809Config config)
 {
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     writer.WriteStringPadRight(value.DriverName, 16);
     writer.WriteStringPadRight(value.DriverID, 20);
     writer.WriteStringPadRight(value.Licence, 40);
     writer.WriteStringPadRight(value.OrgName, 200);
     if (config.Version == JT809Version.JTT2019)
     {
         writer.WriteUTCDateTime(value.ValidDate);
     }
 }
Example #26
0
 public void Serialize(ref JT809MessagePackWriter writer, JT808_JT1078_0x1700 value, IJT809Config config)
 {
     try
     {
         writer.WriteUInt16(value.SubBusinessType);
         if (value.SubBodies != null)
         {
             JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize(
                 config.GetMessagePackFormatterByType(value.SubBodies.GetType()),
                 ref writer, value.SubBodies,
                 config);
         }
     }
     catch
     {
         throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
     }
 }
Example #27
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1301 value, IJT809Config config)
 {
     writer.WriteByte((byte)value.ObjectType);
     if (config.Version == JT809Version.JTT2011)
     {
         writer.WriteStringPadRight(value.ObjectID, 12);
         writer.WriteUInt32(value.InfoID);
     }
     else
     {
         writer.WriteStringPadRight(value.Responder, 16);
         writer.WriteStringPadRight(value.ResponderTel, 20);
         writer.WriteStringPadRight(value.ObjectID, 20);
         writer.WriteUInt16(value.SourceDataType);
         writer.WriteUInt32(value.SourceMsgSn);
     }
     // 先计算内容长度(汉字为两个字节)
     writer.Skip(4, out int lengthPosition);
     writer.WriteString(value.InfoContent);
     writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition);
 }
Example #28
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300 value, IJT809Config config)
 {
     writer.WriteUInt16(value.SubBusinessType);
     //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性
     try
     {
         // 先写入内容,然后在根据内容反写内容长度
         writer.Skip(4, out int subContentLengthPosition);
         if (value.SubBodies != null)
         {
             JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize(
                 config.GetMessagePackFormatterByType(value.SubBodies.GetType()),
                 ref writer, value.SubBodies,
                 config);
         }
         writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition);
     }
     catch
     {
         throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
     }
 }
Example #29
0
 public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200 value, IJT809Config config)
 {
     //1078qq群808432702:大兄弟提供的
     //由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过
     if (config.Version == JT809Version.JTT2019)
     {
         if (value.SubBusinessType != JT809SubBusinessType.车辆注册信息应答消息.ToUInt16Value())
         {
             writer.WriteStringPadRight(value.VehicleNo, 21);
             writer.WriteByte((byte)value.VehicleColor);
         }
     }
     else
     {
         writer.WriteStringPadRight(value.VehicleNo, 21);
         writer.WriteByte((byte)value.VehicleColor);
     }
     writer.WriteUInt16(value.SubBusinessType);
     try
     {
         // 先写入内容,然后在根据内容反写内容长度
         writer.Skip(4, out int subContentLengthPosition);
         if (value.SubBodies != null)
         {
             if (!value.SubBodies.SkipSerialization)
             {
                 JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize(
                     value.SubBodies,
                     ref writer, value.SubBodies,
                     config);
             }
         }
         writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition);
     }
     catch
     {
         throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
     }
 }
Example #30
0
        public void Serialize(ref JT809MessagePackWriter writer, JT809Package value, IJT809Config config)
        {
            // -----------开始组包----------
            // 1.起始符
            writer.WriteByte(value.BeginFlag);
            // 2.写入头部数据
            //  2.1.跳过数据长度的写入
            writer.Skip(4, out int lengthPosition);
            //  2.2.报文序列号
            value.Header.MsgSN = value.Header.MsgSN > 0 ? value.Header.MsgSN : config.MsgSNDistributed.Increment();
            writer.WriteUInt32(value.Header.MsgSN);
            //  2.3.业务数据类型
            writer.WriteUInt16(value.Header.BusinessType);
            //  2.4.下级平台接入码
            writer.WriteUInt32(value.Header.MsgGNSSCENTERID);
            //  2.5.版本号
            writer.WriteArray(value.Header.Version.Buffer);
            //  2.6.报文加密
            writer.WriteByte((byte)value.Header.EncryptFlag);
            //  2.7.数据加密密钥
            writer.WriteUInt32(value.Header.EncryptKey);
            // 3.写入数据体
            //  3.1.记录当前开始位置
            int startIndex = writer.GetCurrentPosition();

            //  3.2.写入数据对应数据体
            if (value.Bodies != null)
            {
                JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize(
                    config.GetMessagePackFormatterByType(value.Bodies.GetType()),
                    ref writer, value.Bodies,
                    config);
            }
            //  3.3.记录当前结束位置
            int endIndex      = writer.GetCurrentPosition();
            int contentLength = endIndex - startIndex;

            if (contentLength > 0)
            {
                // 3.4. 数据加密
                switch (value.Header.EncryptFlag)
                {
                case JT809Header_Encrypt.None:
                    break;

                case JT809Header_Encrypt.Common:
                    // 3.5. 提取数据体并进行加密处理
                    byte[] messageBodyDatEncrypted = config.Encrypt.Encrypt(writer.Extract(startIndex), config.EncryptOptions, value.Header.EncryptKey);
                    int    flagLength = messageBodyDatEncrypted.Length - contentLength;
                    if (flagLength == 0)
                    {
                        // 相等复制
                        writer.CopyTo(messageBodyDatEncrypted, startIndex);
                    }
                    else if (flagLength > 0)
                    {
                        // 扩容
                        writer.Skip(flagLength, out _);
                        writer.CopyTo(messageBodyDatEncrypted, startIndex);
                    }
                    else
                    {
                        // 缩减
                        writer.CopyTo(messageBodyDatEncrypted, startIndex);
                        writer.Shrink(-flagLength);
                    }
                    break;
                }
            }
            // 4.计算内容的总长度(校验码2+终止符1=3)
            writer.WriteInt32Return(writer.GetCurrentPosition() + 3, lengthPosition);
            // 5.校验码
            writer.WriteCRC16();
            // 6.终止符
            writer.WriteByte(value.EndFlag);
            // 7.转义
            writer.WriteEncode();
            // -----------组包完成----------
        }