Main Site Documentation

Serial StopBits.None issues


#1

Greetings, remember me ::slight_smile:

It seems that StopBits.None does not work with Premium hardware - is this a known issue?

This code breaks Spider and G400

SerialPort port = new SerialPort("COM1",9600,Parity.None,8,StopBits.None);
port.Open();

But works happily on STM boards.

Changing it to:

SerialPort port = new SerialPort("COM1",9600,Parity.None,8,StopBits.One);
port.Open();

Happy Spider and G400…


#2

The legend returns.

He’s not dead to us after all ! I take it all back !


#3

We will check and get back to you.


#4

And welcome back :clap:


#5

How can we forget these piercing eyes!?


#6

@ Brett - Lucky you said that…
@ Gus - Thanks
@ Architect - better? :wink:


#7

My son’s favorite fruit. :slight_smile:


#8

@ Justin -

Can you explain more about that please, because few days ago, we tested few things that related to UART - LCD Touch with stop bit is None, it seems fine.


#9

@ Dat - The following code fails on a Spider and G400 (and i would guess a G120) but is fine on a Cerb.

SerialPort port = new SerialPort("COM1",9600,Parity.None,8,StopBits.None);
port.Open();

Here is the exception.

Using mainboard GHI Electronics FEZSpider version 1.0
#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message:
#### System.IO.Ports.SerialPort::InternalOpen [IP: 0000] ####
#### System.IO.Ports.SerialPort::Open [IP: 0018] ####
#### StopBitsTest.Program::ProgramStarted [IP: 0014] ####
#### StopBitsTest.Program::Main [IP: 0015] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.SerialPort.dll

Changing the StopBits.None to StopBits.One runs fine on the Spider and G400

SerialPort port = new SerialPort("COM1",9600,Parity.None,8,StopBits.One);
port.Open();

#10

@ Justin -

Yes, you are right, I just opened our code and see that we are using stop bit 1. ;D
So, a new know issue will be added.
Thanks


#11

@ Dat - Rodger


#12

No problems on a G120 (Cobra II), although I am using Gadgeteer.Interfaces.Serial, not SerialPort.


#13

Hi,
I think stopbit.none is not complient with the definition of rs232. The receiver must synchronize on the falling edge from the stop signal e.g. (logic 1) to the start bit (logic 0). If there would be no stop bit the receiver could not synchronize as you can not know whether the last data bit is high or low… Stopbit.one means at least one bit length on logic 1, it can be longer and it is longer if no data are transmitted.
Regards
Roland


#14

In the post release issues it says “Premium Libray, UART won’t work if configuration uses stop bit 1. Click here for the link on the forum.”

And here it says that StopBits.One is working but StopBits.None isn’t. So which is it?


#15

I have a feeling that the stopbits.none is for when the port is used in the synchronous mode (if supported) and is not actually valid for asynchronous use. I can’t find any reference to no stop bits for UART cases anywhere.

It’s certainly not something I have seen before either having used RS232 for the last 25+ years :slight_smile:

EDIT: Just found this.

http://msdn.microsoft.com/en-us/library/system.io.ports.stopbits(v=vs.110).aspx


#16

@ ollengenic -
I think the statement in the post release issues that StopBits.One does not work is (inadvertently) wrong.
As the link in Dave McLaughlin’s post shows StopBits.None is not allowed in .NET as well.
This is normal, not an issue.


#17

Corrected it!


#18

@ Dat - You know more about this code than I do, but please re-read the link given by Dave McLaughlin. As I read it, it sounds like the exception is the correct result for StopBits.None.

Same comment for NETMF: http://msdn.microsoft.com/en-us/library/hh423688.aspx

Edit: added NETMF reference