コード例 #1
0
        protected ReadE2Info HandleReadE2Frame(byte[] frame)
        {
            ReadE2Info    info       = new ReadE2Info(frame);
            ReturnMessage returnCode = CheckFrame(info);

            if (returnCode != ReturnMessage.Success)
            {
                info.ReturnValue = returnCode;
                return(info);
            }
            if (frame[0] > 4)
            {
                Array.Copy(frame, 3, info.E2Data, 0, info.E2Data.Length); //拷贝返回的 EEPROM 中的数据
            }
            info.ReturnValue = ReturnMessage.Success;
            return(info);
        }
コード例 #2
0
        /// <summary>
        /// 将指定地址开始的读写器内部EEPROM的数据读出。该起始地址必须
        /// 小于0x80。从0x80地址开始是读写器密钥存储区,内容不能被读出。
        /// </summary>
        /// <param name="start">读操作的起始地址,必须小于0x80</param>
        /// <param name="len">被读的数据长度(小于20个字节)</param>
        /// <returns></returns>
        public async Task <ReadE2Info> ReadE2Async(byte start, byte len)
        {
            byte[] frame = CreateReadE2Frame(start, len);
            CommunicationReturnInfo cri = await com.SendAsync(frame);

            if (cri.ReturnValue != ReturnMessage.Success)
            {
                ReadE2Info rei = new ReadE2Info();
                rei.SendByte         = frame;
                rei.ReturnValue      = cri.ReturnValue;
                rei.ExceptionMessage = cri.ExceptionMessage;
                return(rei);
            }

            ReadE2Info info = HandleReadE2Frame(cri.RecvByte);

            info.SendByte = frame;
            return(info);
        }