剛剛發現這個線程,並認爲我有啥可只加我的發現:隨機,我也擔心這個在Mac上。在Windows和Linux中(在VS和Mono中)SerialPort。GetPortNames()按照以下規則返回一個列表:
1)Windows返回一個像Com1,Com4這樣的字符串列表,並丟失任何不存在的字符串(USB串行適配器似乎根據塞將其插入,consistantly)從我的串行端口掃描器:
Scanning COM1 Scanning COM4 Scanning Complete
2)Linux的返回所有可能的Linux發行版的編譯器,使TTY串行端口。這似乎是約8端口,如果你試圖打開,將拋出一個異常(從我的串行端口掃描器:
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(當插入USB串行端口和驅動程序並一切正常時)不會在GetPortNames()上返回什麼。納達。在/ dev/tty中,額外的設備只有在插入設備時纔會出現,並且名稱很不幸,例如/dev/tty.usbserial-A7006Ro7,使用該名稱作爲程序的參數,然後是serial.open dosnt似乎有什麼影響。
展望更多。
感謝您的加入。該項目已經停滯,因爲我沒有從想要使用Mac或Linux的用戶那裏得到很多反饋。我曾以爲會有,但到目前爲止,這個項目只是爲了我的好奇心。 – Tim 2009-05-14 18:45:48