Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework COM port black list #247

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@
namespace nanoFramework.Tools.Debugger
{
public abstract partial class PortBase : PortMessageBase
{
public static PortBase CreateInstanceForSerial(string displayName, List<string> comPortBlackList = null)
{
public static PortBase CreateInstanceForSerial(string displayName, List<string> portBlackList = null)
{
return new SerialPortManager(null, true, comPortBlackList, 1000);
return new SerialPortManager(null, true, portBlackList);
}

public static PortBase CreateInstanceForSerial(string displayName, bool startDeviceWatchers = true, List<string> portBlackList = null)
{
return new SerialPortManager(null, startDeviceWatchers, portBlackList);
}

public static PortBase CreateInstanceForSerial(string displayName, object callerApp = null, bool startDeviceWatchers = true, int bootTime = 1000)
{
return new SerialPortManager(callerApp, startDeviceWatchers, null, bootTime);
}

public static PortBase CreateInstanceForSerial(string displayName, object callerApp = null, bool startDeviceWatchers = true, List<string> comPortBlackList = null, int bootTime = 1000)
public static PortBase CreateInstanceForSerial(string displayName, object callerApp = null, bool startDeviceWatchers = true, List<string> portBlackList = null, int bootTime = 1000)
{
return new SerialPortManager(callerApp, startDeviceWatchers, comPortBlackList, bootTime);
return new SerialPortManager(callerApp, startDeviceWatchers, portBlackList, bootTime);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
//

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace nanoFramework.Tools.Debugger
{
public abstract partial class PortBase
{
public List<string> PortBlackList { get; set; } = new List<string>();

public override bool Equals(object obj)
{
PortBase pd = obj as PortBase; if (pd == null) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ public partial class SerialPortManager : PortBase

public int BootTime { get; set; }

public List<string> COMPortBlackList => _comPortBlackList;

private readonly List<string> _comPortBlackList = new List<string>();

/// <summary>
/// Creates an Serial debug client
/// </summary>
public SerialPortManager(object callerApp, bool startDeviceWatchers = true, List<string> comPortBlackList = null, int bootTime = 1000)
public SerialPortManager(object callerApp, bool startDeviceWatchers = true, List<string> portBlackList = null, int bootTime = 1000)
{
_mapDeviceWatchersToDeviceSelector = new Dictionary<DeviceWatcher, string>();
NanoFrameworkDevices = new ObservableCollection<NanoDeviceBase>();
Expand All @@ -77,9 +73,9 @@ public SerialPortManager(object callerApp, bool startDeviceWatchers = true, List

BootTime = bootTime;

if(comPortBlackList != null)
if(portBlackList != null)
{
_comPortBlackList = comPortBlackList;
PortBlackList = portBlackList;
}

Task.Factory.StartNew(() => {
Expand Down Expand Up @@ -540,7 +536,7 @@ private async Task<bool> CheckValidNanoFrameworkSerialDeviceAsync(NanoDevice<Nan
if (serialDevice != null)
{
// check against black list
if (_comPortBlackList.Contains(serialDevice.PortName))
if (PortBlackList.Contains(serialDevice.PortName))
{
OnLogMessageAvailable(NanoDevicesEventSource.Log.DroppingBlackListedDevice(device.Device.DeviceInformation.DeviceInformation.Id));
}
Expand Down
2 changes: 1 addition & 1 deletion source/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.17.0-preview.{height}",
"version": "1.18.0-preview.{height}",
"assemblyVersion": {
"precision": "revision"
},
Expand Down