Exemplo n.º 1
0
        public byte[] Do(byte[] frame)
        {
            DataWriter   dw       = new DataWriter();
            DataReader   dr       = new DataReader(frame);
            FunctionCode funcCode = dr.GetFuncCode();

            byte dispLine = dr.GetByte();

            if (dispLine >= _lcdDispLineArr.Length)
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }

            if (funcCode == FunctionCode.LCDRead)
            {
                dw.Add(funcCode);
                dw.Add(_lcdDispLineArr[dispLine]);
                return(dw.GetBuffer());
            }
            else if (funcCode == FunctionCode.LCDWrite)
            {
                _lcdDispLineArr[dispLine] = dr.GetString();

                ResultFunction rf = new ResultFunction(0);
                return(rf.Do(null));
            }
            else
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }
        }
Exemplo n.º 2
0
        public byte[] Do(byte[] frame)
        {
            DataWriter   dw       = new DataWriter();
            DataReader   dr       = new DataReader(frame);
            FunctionCode funcCode = dr.GetFuncCode();

            byte regAddr = dr.GetByte();

            if (regAddr >= _regiestArr.Length)
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }

            if (funcCode == FunctionCode.RegiestReadShort)
            {
                dw.Add(funcCode);
                dw.Add(_regiestArr[regAddr]);
                return(dw.GetBuffer());
            }
            else if (funcCode == FunctionCode.RegiestWriteShort)
            {
                _regiestArr[regAddr] = dr.GetShort();

                ResultFunction rf = new ResultFunction(0);
                return(rf.Do(null));
            }
            else
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }
        }