/// <summary> /// Connects the debugger to the device /// </summary> /// <param name="comPort">COM-Port name</param> /// <returns>true if connected successfully</returns> public bool Connect(string comPort) { if (_portBase == null) { _portBase = PortBase.CreateInstanceForSerial(""); } // wait until all devices are found while (!_portBase.IsDevicesEnumerationComplete) { Thread.Sleep(100); } // get the NanoFramework device list IList nanoFrameworkDevices = _portBase.NanoFrameworkDevices; if (nanoFrameworkDevices.Count == 0) { return(false); } // iterate through the NanoFramework device list NanoDeviceBase nanoFrameworkDeviceForConnection = null; foreach (NanoDeviceBase nanoFrameworkDevice in nanoFrameworkDevices) { // does the description contains the delivered port name? if (nanoFrameworkDevice.Description.ToUpperInvariant().Contains(comPort.ToUpperInvariant())) { // device found nanoFrameworkDeviceForConnection = nanoFrameworkDevice; break; } } // device not found? if (nanoFrameworkDeviceForConnection == null) { return(false); } // get the DebugEngine _engine = nanoFrameworkDeviceForConnection.DebugEngine; // if null create the DebugEngine get the DebugEngine again if (_engine == null) { nanoFrameworkDeviceForConnection.CreateDebugEngine(); _engine = nanoFrameworkDeviceForConnection.DebugEngine; } if (_engine == null) { return(false); } // connect the nanoFramework debugger to the device bool result = _engine.ConnectAsync(5000).Result; // connected? if (result) { // add the OnMessage event handler and store the device instance for later use _engine.OnMessage += OnMessage; _connectedDevice = nanoFrameworkDeviceForConnection; } return(result); }
public async Task <bool> ConnectDeviceAsync(NanoDeviceBase device) { return(await ConnectUsbDeviceAsync((device as NanoDevice <NanoUsbDevice>).Device.DeviceInformation as UsbDeviceInformation)); }
public string GetDeviceName(NanoDeviceBase device) { return(device.Description); }
public DebugPortSupplierPrivate() : base(true) { NanoDeviceBase device = NanoFrameworkPackage.NanoDeviceCommService.DebugClient.NanoFrameworkDevices[0]; _ports.Add(new DebugPort(device, this)); }