Beispiel #1
0
 public static string GetPortById(string contains)
 {
     try
     {
         if (!Handy.IsLinux)
         {
             return(contains);
         }
         //this will get the serial ports listed in /dev/serial/by-id/
         if (Directory.Exists(serialpath))
         {
             var files = Directory.GetFiles(serialpath).ToList();
             var port  = files.Where(i => i.Contains(contains)).FirstOrDefault();
             if (port != null)
             {
                 //get the link address
                 return(GetAlias.GetSymLink(port));
             }
         }
     }
     catch (Exception ex)
     {
         Logging.E("GetSerialPortNames:GetPortById " + ex.ToString());
     }
     return(null);
 }