Esempio n. 1
0
        //获取上下行标识及报文长度
        //分两个字节,代表数据长度 19-20位
        public int DataLength(int position)
        {
            byte[] length = new byte[2];

            Array.Copy(Data, position, length, 0, 2);

            string lengthStr = BCDUtil.ConvertToHex(length);

            return(Convert.ToInt32(lengthStr.Substring(1), 16));
        }
Esempio n. 2
0
        public static int GetDataLength(byte[] data, out int headLength)
        {
            headLength = GetStartPosition(data);

            if (data.Length < headLength + 19)
            {
                return(headLength + 43);
            }

            byte[] length = new byte[2];

            Array.Copy(data, headLength + 18, length, 0, 2);

            string lengthStr = BCDUtil.ConvertToHex(length);

            return(Convert.ToInt32(lengthStr.Substring(1), 16) + 24);
        }
Esempio n. 3
0
 /// <summary>
 /// 08H	N(2) 08H
 /// 主从机地址,1字节(其中地址FF表示主机)
 /// 示例:08 08 FF
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static string Code(byte[] data)
 {
     return(BCDUtil.ConvertToHex(data[2]));
 }