When opening a serial port in the dotnet 2.0, using stopbits.none causes an ArgumentOutOfRange Exception. Otherwise this feature works great. Here is a code example-
Imports
System.IO.PortsImports
System.ComponentModelImports
System.Windows.FormsPublic
Class frmComm Dim comport As New SerialPort() Public Sub portHandle() If comport.IsOpen Thencomport.Close()
End Ifcomport.DataBits = 8
comport.StopBits = StopBits.None
comport.Parity = Parity.None
comport.BaudRate = 9600
comport.PortName =
"COM1"comport.Open()
End SubEnd
Class
SerialPort error
JensLundberg
Marcin Obel
I'm not sure about hyperterm, but if you pass StopBits.One to the SerialPort, the value that gets put in the DCB is zero (which is what you'd expect)
Check out http://msdn.microsoft.com/library/default.asp url=/library/en-us/devio/base/dcb_str.asp for more information on the DCB structure...
I believe the confusion here is caused by the fact that the numerical value in the API is different from what the name of the enumeration sounds like, which in turn is different from what will actually be set in the LCR:
Enum Numerical .NET FX LCR Bit 2 StopBits
value
Danz.
Kade
I just read up on this Johan. "Zero stop bits" means one stop bit in RS-232.
Zakary
I'm not a serial port expert, but is zero stop bits really a valid value From what I can recall, you could use 1, 1.5 or 2 stop bits, but that there were some restrictions on when you could use 1.5 and 2 respectively.
I'm not sure if the StopBits.None should really be exposed here...
I would recommend that you open an issue on the MSDN product feedback center. I'm sure that the team that owns the SerialPort class can explain this better than I can...
Best regards,
Johan Stenberg
Cristiano Muzi
ReneeC,
I'm sorry if my answer wasn't clear - I also have the impression that you can't have 0 stop bits, which is why I'm not sure that StopBits.None (the row in red in the table in my previous post) should be exposed by the framework.
Best regards,
Johan Stenberg
ZhangQing
Miketrix
Johan,
Then I'm confused. What I read was that stop bits = 0 was impossible because the stop bit represents the end of the bit frame. It tells hardware the the byte is complete.