Just discovered this thread, and thought I aught to just add my discoveries: randomly, I am also worried about this on a mac. In Windows and Linux (in VS and Mono alike) SerialPort.GetPortNames() return a list, with the following rules:
1) Windows returns a list of strings like Com1, Com4, missing out any which don't exist (USB Serial adapters seem to take a COM number based on the plug they are plugged into, consistantly) From my serial port scanner:
Scanning COM1
Scanning COM4
Scanning Complete
2) Linux returns all possibly tty serial ports that the compiler of the linux distro has enabled. This seems to be about 8 ports, which if you try to open, will throw an exception (from my serial port scanner:
Scanning /dev/ttyS0
Scanning /dev/ttyS1 Port FailedSystem.IO.IOException: I/O Error
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
at System.IO.Ports.SerialPort.Open () [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at HSMScanner.Program.Main (System.String[] args) [0x00000]
Scanning /dev/ttyS2 Port FailedSystem.IO.IOException: I/O Error
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
at System.IO.Ports.SerialPort.Open () [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at HSMScanner.Program.Main (System.String[] args) [0x00000]
Scanning /dev/ttyS3 Port FailedSystem.IO.IOException: I/O Error
at System.IO.Ports.SerialPortStream..ctor (System.String portName, Int32 baudRate, Int32 dataBits, Parity parity, StopBits stopBits, Boolean dtrEnable, Boolean rtsEnable, Handshake handshake, Int32 readTimeout, Int32 writeTimeout, Int32 readBufferSize, Int32 writeBufferSize) [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPortStream:.ctor (string,int,int,System.IO.Ports.Parity,System.IO.Ports.StopBits,bool,bool,System.IO.Ports.Handshake,int,int,int,int)
at System.IO.Ports.SerialPort.Open () [0x00000]
at (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:Open ()
at HSMScanner.Program.Main (System.String[] args) [0x00000]
3) Macs...
Oh dear oh dear. Macs (when a usb serial port is plugged in and drivers and everything are ok) don't return anything on the GetPortNames(). Nada. Looking in the /dev/tty, the extra devices appear only when the device is plugged in and has names like /dev/tty.usbserial-A7006Ro7 unfortunatly, using this name as an argument to the program followed by serial.open dosnt seem to have any effect.
Looking more into it.