diff options
author | Miguel de Icaza <miguel@gnome.org> | 2006-03-15 21:23:15 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2006-03-15 21:23:15 +0300 |
commit | 9b9d82ebce2547ef22c62de03ad41c49798daf57 (patch) | |
tree | b1b994c59b94a585838235a1f55d0d6c385b9527 /mcs/class/System/System.IO.Ports/SerialPort.cs | |
parent | c4b35a549481f9960bbea55588617ce8b410175d (diff) |
2006-03-15 Miguel de Icaza <miguel@gnome.org>
* SerialPort.cs: We will do detection of systems differently as we
discussed over email. Drop malloc/free/uname calls.
svn path=/trunk/mcs/; revision=58031
Diffstat (limited to 'mcs/class/System/System.IO.Ports/SerialPort.cs')
-rw-r--r-- | mcs/class/System/System.IO.Ports/SerialPort.cs | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/mcs/class/System/System.IO.Ports/SerialPort.cs b/mcs/class/System/System.IO.Ports/SerialPort.cs index fb0d3ff6ad5..1e0bdefcc4e 100644 --- a/mcs/class/System/System.IO.Ports/SerialPort.cs +++ b/mcs/class/System/System.IO.Ports/SerialPort.cs @@ -37,7 +37,7 @@ namespace System.IO.Ports byte [] readBuffer; //byte [] writeBuffer; - static string default_port_name; + static string default_port_name = "ttyS0"; public SerialPort () { @@ -85,40 +85,8 @@ namespace System.IO.Ports this.stopBits = stopBits; } - [DllImport ("libc")] - static extern IntPtr malloc (int length); - - [DllImport ("libc")] - static extern void free (IntPtr buffer); - - [DllImport ("libc")] - static extern int uname (IntPtr buffer); - string GetDefaultPortName () { - if (default_port_name != null) - return default_port_name; - - int p = (int) Environment.OSVersion.Platform; - if (p != 4 && p != 128) // Are we on Windows platform? - return default_port_name = "COM1"; - - IntPtr buffer = malloc (1024); - if (uname (buffer) == -1) { - free (buffer); - throw new NotSupportedException ("Detection of default port is not supported for this platform."); - } - - string osname = Marshal.PtrToStringAnsi (buffer); - free (buffer); - switch (osname) { - case "Linux": - default_port_name = "/dev/ttyS0"; - break; - default: - throw new NotImplementedException ("Detection of default port is not implemented for this platform yet."); - } - return default_port_name; } |