From 48efdef1719037332037ee27af6e7d41503caca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20=27Morty=27=20Str=C3=BCbe?= Date: Thu, 3 May 2018 11:51:13 +0200 Subject: [PATCH 1/2] Convert all files to Unix LF-style --- MPSSELight/Properties/AssemblyInfo.cs | 2 +- MPSSELight/devices/FT2232D.cs | 2 +- MPSSELight/devices/FT2232H.cs | 2 +- MPSSELight/devices/FT232H.cs | 2 +- MPSSELight/devices/FT4232H.cs | 2 +- MPSSELight/ftdi/FtdiDevice.cs | 2 +- MPSSELight/ftdi/FtdiException.cs | 2 +- MPSSELight/ftdi/FtdiInventory.cs | 2 +- MPSSELight/ftdi/FtdiPin.cs | 2 +- MPSSELight/mpsse/ArrayExtensions.cs | 2 +- MPSSELight/mpsse/MpsseCommand.cs | 2 +- MPSSELight/mpsse/MpsseDevice.cs | 2 +- MPSSELight/mpsse/MpsseDeviceExtendedA.cs | 2 +- MPSSELight/mpsse/MpsseDeviceExtendedB.cs | 2 +- MPSSELight/protocol/SpiDevice.cs | 2 +- MPSSELightTest/Properties/AssemblyInfo.cs | 2 +- MPSSELightTest/SpiTest.cs | 2 +- SpiLight/Options.cs | 2 +- SpiLight/Program.cs | 2 +- SpiLight/Properties/AssemblyInfo.cs | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/MPSSELight/Properties/AssemblyInfo.cs b/MPSSELight/Properties/AssemblyInfo.cs index 41dc267..0c773bf 100644 --- a/MPSSELight/Properties/AssemblyInfo.cs +++ b/MPSSELight/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/MPSSELight/devices/FT2232D.cs b/MPSSELight/devices/FT2232D.cs index eff313b..d7cdb7a 100644 --- a/MPSSELight/devices/FT2232D.cs +++ b/MPSSELight/devices/FT2232D.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/devices/FT2232H.cs b/MPSSELight/devices/FT2232H.cs index 7efa999..079e044 100644 --- a/MPSSELight/devices/FT2232H.cs +++ b/MPSSELight/devices/FT2232H.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/devices/FT232H.cs b/MPSSELight/devices/FT232H.cs index d1a4c0e..ce9bc5c 100644 --- a/MPSSELight/devices/FT232H.cs +++ b/MPSSELight/devices/FT232H.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/devices/FT4232H.cs b/MPSSELight/devices/FT4232H.cs index 6c3407c..50c6a9e 100644 --- a/MPSSELight/devices/FT4232H.cs +++ b/MPSSELight/devices/FT4232H.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/ftdi/FtdiDevice.cs b/MPSSELight/ftdi/FtdiDevice.cs index 6c99e44..62725e0 100644 --- a/MPSSELight/ftdi/FtdiDevice.cs +++ b/MPSSELight/ftdi/FtdiDevice.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/ftdi/FtdiException.cs b/MPSSELight/ftdi/FtdiException.cs index 145ceee..d3cd9dd 100644 --- a/MPSSELight/ftdi/FtdiException.cs +++ b/MPSSELight/ftdi/FtdiException.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/ftdi/FtdiInventory.cs b/MPSSELight/ftdi/FtdiInventory.cs index a48fc3b..0e9e167 100644 --- a/MPSSELight/ftdi/FtdiInventory.cs +++ b/MPSSELight/ftdi/FtdiInventory.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/ftdi/FtdiPin.cs b/MPSSELight/ftdi/FtdiPin.cs index 7b51ece..b82ea0a 100644 --- a/MPSSELight/ftdi/FtdiPin.cs +++ b/MPSSELight/ftdi/FtdiPin.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/mpsse/ArrayExtensions.cs b/MPSSELight/mpsse/ArrayExtensions.cs index 62facd1..e6cdf68 100644 --- a/MPSSELight/mpsse/ArrayExtensions.cs +++ b/MPSSELight/mpsse/ArrayExtensions.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/mpsse/MpsseCommand.cs b/MPSSELight/mpsse/MpsseCommand.cs index 63d3d42..aee4ec2 100644 --- a/MPSSELight/mpsse/MpsseCommand.cs +++ b/MPSSELight/mpsse/MpsseCommand.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/mpsse/MpsseDevice.cs b/MPSSELight/mpsse/MpsseDevice.cs index 47dcf7d..206a7c2 100644 --- a/MPSSELight/mpsse/MpsseDevice.cs +++ b/MPSSELight/mpsse/MpsseDevice.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/mpsse/MpsseDeviceExtendedA.cs b/MPSSELight/mpsse/MpsseDeviceExtendedA.cs index 64ccea1..a881602 100644 --- a/MPSSELight/mpsse/MpsseDeviceExtendedA.cs +++ b/MPSSELight/mpsse/MpsseDeviceExtendedA.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/mpsse/MpsseDeviceExtendedB.cs b/MPSSELight/mpsse/MpsseDeviceExtendedB.cs index 4b2b4f9..4963efc 100644 --- a/MPSSELight/mpsse/MpsseDeviceExtendedB.cs +++ b/MPSSELight/mpsse/MpsseDeviceExtendedB.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELight/protocol/SpiDevice.cs b/MPSSELight/protocol/SpiDevice.cs index 0a54bb5..1a37f3b 100644 --- a/MPSSELight/protocol/SpiDevice.cs +++ b/MPSSELight/protocol/SpiDevice.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/MPSSELightTest/Properties/AssemblyInfo.cs b/MPSSELightTest/Properties/AssemblyInfo.cs index c632365..e9e2fcf 100644 --- a/MPSSELightTest/Properties/AssemblyInfo.cs +++ b/MPSSELightTest/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/MPSSELightTest/SpiTest.cs b/MPSSELightTest/SpiTest.cs index bb26737..7c7733d 100644 --- a/MPSSELightTest/SpiTest.cs +++ b/MPSSELightTest/SpiTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using MPSSELight; using System.Linq; diff --git a/SpiLight/Options.cs b/SpiLight/Options.cs index 97d3ab9..67300f0 100644 --- a/SpiLight/Options.cs +++ b/SpiLight/Options.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/SpiLight/Program.cs b/SpiLight/Program.cs index 6160f69..e96b09f 100644 --- a/SpiLight/Program.cs +++ b/SpiLight/Program.cs @@ -1,4 +1,4 @@ -/* The MIT License (MIT) +/* The MIT License (MIT) Copyright(c) 2016 Stanislav Zhelnio diff --git a/SpiLight/Properties/AssemblyInfo.cs b/SpiLight/Properties/AssemblyInfo.cs index e047690..7faf88c 100644 --- a/SpiLight/Properties/AssemblyInfo.cs +++ b/SpiLight/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; From f29a61bf11aecbd7213c9a23c72d4cde8a793a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20=27Morty=27=20Str=C3=BCbe?= Date: Thu, 3 May 2018 11:41:18 +0200 Subject: [PATCH 2/2] Add support to open FtdiDevice using the location id instead of serial --- MPSSELight/ftdi/FtdiDevice.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MPSSELight/ftdi/FtdiDevice.cs b/MPSSELight/ftdi/FtdiDevice.cs index 62725e0..799a60c 100644 --- a/MPSSELight/ftdi/FtdiDevice.cs +++ b/MPSSELight/ftdi/FtdiDevice.cs @@ -43,7 +43,18 @@ private void open(string serialNumber) if (ftStatus == FTDI.FT_STATUS.FT_OK) return; - String errMsg = "Failed to open device (error " + ftStatus.ToString() + ")"; + String errMsg = "Failed to open device using serial " + serialNumber + "(error " + ftStatus.ToString() + ")"; + throw new FtdiException(errMsg); + } + } + + private void open(uint locId) { + lock (_lock) { + FTDI.FT_STATUS ftStatus = ftdi.OpenByLocation(locId); + if (ftStatus == FTDI.FT_STATUS.FT_OK) + return; + + String errMsg = "Failed to open device using index " + locId + "(error " + ftStatus.ToString() + ")"; throw new FtdiException(errMsg); } } @@ -138,6 +149,11 @@ public FtdiDevice(string serialNumber) open(serialNumber); } + public FtdiDevice(uint locId) { + ftdi = new FTDI(); + open(locId); + } + public void Dispose() { if (ftdi.IsOpen)