示例#1
0
        public static bool Parse(byte[] command, out TegamServiceCode_t serviceCode, out byte[] data)
        {
            serviceCode = TegamServiceCode_t.TEGAM_BASE;
            data        = new byte[0];

            int dataSize;

            if (command[0] != CMD_MARK_START)
            {
                return(false);
            }

            if (((command[2] << 8) + command[1]) != CMD_MARK_HEADER)
            {
                return(false);
            }

            if (((command[4] << 8) + command[3]) != CMD_VERSION_CODE)
            {
                return(false);
            }

            serviceCode = (TegamServiceCode_t)((command[6] << 8) + command[5]);

            dataSize = (command[8] << 8) + command[7];
            data     = new byte[dataSize];

            for (int i = 0; i < dataSize; i++)
            {
                data[i] = command[9 + i];
            }

            return(true);
        }
示例#2
0
        private static bool ValidateACK(byte[] command, TegamServiceCode_t serviceCode)
        {
            if (command[0] != CMD_MARK_START)
            {
                return(false);
            }

            if (((command[2] << 8) + command[1]) != CMD_MARK_HEADER)
            {
                return(false);
            }

            if (((command[4] << 8) + command[3]) != CMD_VERSION_CODE)
            {
                return(false);
            }

            if (((command[6] << 8) + command[5]) != (ushort)serviceCode)
            {
                return(false);
            }

            if (((command[8] << 8) + command[7]) != 0)
            {
                return(false);
            }

            if (command[9] != CMD_MARK_END)
            {
                return(false);
            }

            return(true);
        }