[chronojump] chronopicRegister finds COM port on Windows
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] chronopicRegister finds COM port on Windows
- Date: Sat, 1 Oct 2016 09:54:39 +0000 (UTC)
commit ab9544d34fb4685e2aed2dac9bbedd214b9724c0
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Oct 1 11:54:01 2016 +0200
chronopicRegister finds COM port on Windows
src/chronopicRegister.cs | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index 65d930e..dff4bbb 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -359,7 +359,7 @@ public class ChronopicRegisterWindows : ChronopicRegister
LogB.Information(String.Format("Serial Number: " +
ftdiDeviceList[i].SerialNumber.ToString()));
LogB.Information(String.Format("Description: " +
ftdiDeviceList[i].Description.ToString()));
- string port = "????"; //TODO
+ string port = getComPort(ftdiDeviceList[i]);
ChronopicRegisterPort crp = new ChronopicRegisterPort(port);
crp.FTDI = true;
crp.SerialNumber = ftdiDeviceList[i].SerialNumber.ToString();
@@ -369,5 +369,22 @@ public class ChronopicRegisterWindows : ChronopicRegister
}
}
}
+
+ private string getComPort(FTDI.FT_DEVICE_INFO_NODE node)
+ {
+ string comport = "";
+
//http://stackoverflow.com/questions/2279646/finding-usb-serial-ports-from-a-net-application-under-windows-7
+ if (ftdiDeviceWin.OpenByLocation(node.LocId) == FTDI.FT_STATUS.FT_OK)
+ {
+ try {
+ ftdiDeviceWin.GetCOMPort(out comport);
+ }
+ finally {
+ ftdiDeviceWin.Close();
+ }
+ }
+
+ return comport;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]