public virtual object dapInfo(EDapInfoIDByte id_) { List <byte> cmd = new List <byte> { (byte)EDapCommandByte.DAP_INFO, (byte)id_ }; this.anInterface.write(cmd); List <byte> resp = this.anInterface.read(); if (resp[0] != (byte)EDapCommandByte.DAP_INFO) { // Response is to a different command throw new DeviceError(); } if (resp[1] == 0) { return(null); } // Integer values if (new EDapInfoIDByte[] { EDapInfoIDByte.CAPABILITIES, EDapInfoIDByte.SWO_BUFFER_SIZE, EDapInfoIDByte.MAX_PACKET_COUNT, EDapInfoIDByte.MAX_PACKET_SIZE }.Contains(id_)) { if (resp[1] == 1) { return(resp[2]); } if (resp[1] == 2) { return((UInt16)(resp[3] << 8 | resp[2])); } else { throw new ArgumentOutOfRangeException("EDapInfoID id_"); } } // String values. They are sent as C strings with a terminating null char, so we strip it out. string x = Encoding.ASCII.GetString(resp.GetRange(2, resp[1]).ToArray()); //if (x[-1] == "\x00") //{ // x = x[0:: - 1]; //} return(x); }
public object identify(EDapInfoIDByte item) { //Debug.Assert(item is ID); return(this._protocol.dapInfo(item)); }