[chronojump] chronopicRegister reads SerialNumber on Mac



commit 3ae6cbf7765cd98a47dd1f91d576153739d8827f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Sep 30 10:41:27 2016 +0200

    chronopicRegister reads SerialNumber on Mac

 src/chronopicRegister.cs |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index e45f977..578932f 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -159,16 +159,18 @@ public class ChronopicRegister
        //read all information of one port
        private ChronopicRegisterPort readFTDI(string port) 
        {
-               //if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
-                       return readFTDILinux(port);
-               //else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
-               //else // WINDOWS
+               ChronopicRegisterPort crp = new ChronopicRegisterPort(port);
+
+               if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
+                       return readFTDILinux(crp);
+               else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
+                       return readFTDIMac(crp);
+               else // WINDOWS
+                       return readFTDIWindows(crp);
        }
                
-       private ChronopicRegisterPort readFTDILinux(string port) 
+       private ChronopicRegisterPort readFTDILinux(ChronopicRegisterPort crp) 
        {
-               ChronopicRegisterPort crp = new ChronopicRegisterPort(port);
-
                /*
                 * old:
                 * /bin/udevadm info —name=/dev/ttyUSB0 |grep ID_SERIAL_SHORT|cut -d= -f2
@@ -188,7 +190,7 @@ public class ChronopicRegister
                pinfo.RedirectStandardOutput = true; 
        
                //1) get path   
-               pinfo.Arguments = "info -q path -n " + port;
+               pinfo.Arguments = "info -q path -n " + crp.Port;
                LogB.Information("Arguments:", pinfo.Arguments);
                
                Process p = new Process();
@@ -234,5 +236,24 @@ public class ChronopicRegister
                
                return crp;
        }
+
+       private ChronopicRegisterPort readFTDIMac(ChronopicRegisterPort crp)
+       {
+               //TODO: 1) check if it's FTDI
+               crp.FTDI = true;
+
+               //2) read SerialNumber
+               //eg crp.Port = "/dev/tty.usbserialA123456F";
+               string chunk = "usbserial";
+               int pos = crp.Port.LastIndexOf(chunk) + chunk.Length;
+               crp.SerialNumber = crp.Port.Substring(pos); //eg. A123456F
+
+               return crp;
+       }
+
+       private ChronopicRegisterPort readFTDIWindows(ChronopicRegisterPort crp)
+       {
+               return crp;
+       }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]