public bool Read(ResponseReader reader) { if (_open) throw new CommandSetException("Attempting to read set before it has been prepared."); var success = false; try { if (_pm3Commands.Count > 0) { // Read the PM3 custom command marker and size if (reader.ReadByte() == (uint)Enums.Csafe.SETUSERCFG1_CMD) // Read the size reader.ReadByte(); // Read PM3 commands foreach (Command cmd in _pm3Commands) cmd.Read(reader); } // Read CSAFE commands foreach (Command cmd in _cSafeCommands) cmd.Read(reader); // Ensure whole response has been read success = (reader.Position == reader.Size); } catch (BufferExceededException e) { Debug.WriteLine(string.Format("[CommandSet.Read] {0}", e.Message)); } return success; }
public void Read(ResponseReader reader) { uint id = reader.ReadByte(); uint size = reader.ReadByte(); if (id == (uint)_id && size == _resonseSize) ReadInternal(reader); else Debug.WriteLine("[Command.Read] id/size mismatch"); }
abstract protected void ReadInternal(ResponseReader reader);