public void open() { if (this._backend_interface == null) { IEnumerable <IBackend> all_interfaces = DapAccessConsts._get_interfaces(); foreach (var anInterface in all_interfaces) { try { string unique_id = DapAccessConsts._get_unique_id(anInterface); if (this._unique_id == unique_id) { // This assert could indicate that two boards // had the same ID Debug.Assert(this._backend_interface == null); this._backend_interface = anInterface; } } catch (Exception) { Trace.TraceError("Failed to get unique id for open"); } } if (this._backend_interface == null) { throw new Exception("Unable to open device", new DeviceError()); } } this._backend_interface.open(); this._protocol = new DebugUnitV2_0_0(this._backend_interface); if (DapSettings.limit_packets) { this._packet_count = 1; Trace.TraceInformation("Limiting packet count to {0}", this._packet_count); } else { object dapInfo = this._protocol.dapInfo(EDapInfoIDByte.MAX_PACKET_COUNT); Debug.Assert(dapInfo != null); this._packet_count = (byte)dapInfo; } this._backend_interface.packet_count = (byte)this._packet_count; { object dapInfo = this._protocol.dapInfo(EDapInfoIDByte.MAX_PACKET_SIZE); Debug.Assert(dapInfo != null); this._packet_size = (UInt16)dapInfo; } this._backend_interface.setPacketSize((UInt16)this._packet_size); this._init_deferred_buffers(); }
// ------------------------------------------- # // Static Functions // ------------------------------------------- # // // Return an array of all mbed boards connected // // [staticmethod] public static List <IDapAccessLink> get_connected_devices() { List <IDapAccessLink> all_daplinks = new List <IDapAccessLink>(); var all_interfaces = DapAccessConsts._get_interfaces(); foreach (var anInterface in all_interfaces) { try { var unique_id = DapAccessConsts._get_unique_id(anInterface); DapAccessLink new_daplink = new DapAccessLink(unique_id); all_daplinks.Add(new_daplink); } catch { //var logger = logging.getLogger(@__name__); Trace.TraceError("Failed to get unique id"); } } return(all_daplinks); }