static public List <String> GetBoardPorts(String supportedBoards, List <String> allowedPorts = null, List <String> deniedPorts = null) { if (supportedBoards == null || supportedBoards == String.Empty) { throw new Exception("ArduinoDeviceManager:Connect no supportedBoards provided"); } //all ports that match supported boards List <String> boardPorts = SerialPorts.Find(supportedBoards.Trim()); bool allowAllPorts = (allowedPorts == null || allowedPorts.Count == 0); bool denySomePorts = (deniedPorts != null && deniedPorts.Count > 0); if (allowAllPorts && !denySomePorts) { return(boardPorts); } else { List <String> ports2return = new List <String>(); foreach (var p in boardPorts) { if (deniedPorts != null && deniedPorts.Contains(p)) { continue; } if (allowedPorts != null && allowedPorts.Contains(p)) { ports2return.Add(p); } } return(ports2return); } }