Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fc"></param>
        /// <param name="sim"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        static public byte[] MakeDtuCommand(byte fc, string sim, byte[] userData)
        {
            int userDataLen = userData != null ? userData.Length : 0;

            //if ( userData != null )
            //    userDataLen = userData.Length;
            byte[] cmd = new byte[SGDefine.MIN_PA_LEN + userDataLen];
            System.IO.MemoryStream ms = new System.IO.MemoryStream(cmd);
            ms.WriteByte(SGDefine.HEAD_VALUE);
            ms.WriteByte(fc);
            ms.Write(GetDtuLengthBytes(userDataLen + SGDefine.MIN_PA_LEN), 0, 2);

            byte[] simbs = SGDtu.GetSimNumberBytes(sim);
            ms.Write(simbs, 0, simbs.Length);

            if (userData != null && userData.Length > 0)
            {
                ms.Write(userData, 0, userData.Length);
            }
            ms.WriteByte(SGDefine.TAIL_VALUE);

            //return ms.GetBuffer();
            return(ms.ToArray());
            //return (byte[])ms;
        }
Example #2
0
            public byte[] MakeCmd()
            {
                byte[] simBytes = SGDtu.GetSimNumberBytes(_sim);
                byte[] cmd      = new byte[16 + 1];
                cmd[0] = SGDefine.HEAD_VALUE;
                cmd[1] = SGDefine.FC_R_DTU_SETTING;
                cmd[2] = 0x00;  // cmd.length / 0xFF
                cmd[3] = (byte)cmd.Length;
                Array.Copy(simBytes, 0, cmd, 4, simBytes.Length);
                cmd[15] = SGDefine.DtuParamSettingFC.READ_DSC;
                cmd[16] = SGDefine.TAIL_VALUE;

                return(cmd);
            }
Example #3
0
        /// <summary>
        /// 生成读取DTU的数据服务中心设置的命令
        /// </summary>
        /// <param name="simCard">该DTU的Sim卡号码</param>
        /// <returns>byte[]</returns>
        static private byte[] CreateReadDtuDscSettingCmd(string simCard)
        {
            byte[] simbs  = SGDtu.GetSimNumberBytes(simCard);
            int    cmdLen = 0x11;

            byte[] bs = new byte[cmdLen];
            //bs[0] = 0x7B;

            bs[0] = SGDefine.HEAD_VALUE;
            bs[1] = SGDefine.FC_R_DTU_SETTING;
            bs[2] = 0x00;
            bs[3] = (byte)cmdLen;
            Array.Copy(simbs, 0, bs, 4, simbs.Length);
            bs[15] = SGDefine.DtuParamSettingFC.READ_DSC;
            bs[16] = SGDefine.TAIL_VALUE;

            return(bs);
        }