Update SerialPort.Linux.cs (#2009)
authorJohonis <jonas_kuntze@web.de>
Tue, 28 Jan 2020 18:28:04 +0000 (19:28 +0100)
committerStephen Toub <stoub@microsoft.com>
Tue, 28 Jan 2020 18:28:04 +0000 (13:28 -0500)
* Update SerialPort.Linux.cs

add ttyGSX devices to supported devices

* Apply suggestions from code review

Entry can only be ttyGSx. when its not ttySx

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update SerialPort.Linux.cs

ttyGSx creates a file in "/sys/class/tty/ttyGS0" named "dev" - use this file as an additional check

Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.Linux.cs

index 831c250..fa9ba5d 100644 (file)
@@ -33,11 +33,13 @@ namespace System.IO.Ports
                     // checking for that for non-ttyS entries is incorrect as some uart
                     // devices are incorrectly filtered out
                     bool isTtyS = entry.Name.StartsWith("ttyS");
+                    bool isTtyGS = !isTtyS && entry.Name.StartsWith("ttyGS");
                     if ((isTtyS &&
                          (File.Exists(entry.FullName + "/device/id") ||
                           Directory.Exists(entry.FullName + "/device/of_node"))) ||
                         (!isTtyS && Directory.Exists(entry.FullName + "/device/tty")) ||
-                        Directory.Exists(sysUsbDir + entry.Name))
+                        Directory.Exists(sysUsbDir + entry.Name) ||
+                        (isTtyGS && (File.Exists(entry.FullName + "/dev"))))
                     {
                         string deviceName = devDir + entry.Name;
                         if (File.Exists(deviceName))