The linux vm codes stop bits as follows: 0=1.5, 1=1, 2=2. I have long seen it (on Windows) expressed as
ONESTOPBIT := 0. ONE5STOPBITS := 1. TWOSTOPBITS := 2.
Someone trying to write code that works across platforms will get snagged, at least if using the usual Windows definitions. Is this something that can/should be done better to make the stop bits as platform-neutral as possible? What would you change?
On Wed, Nov 24, 2010 at 02:10:44PM -0500, Schwab,Wilhelm K wrote:
The linux vm codes stop bits as follows: 0=1.5, 1=1, 2=2. I have long seen it (on Windows) expressed as
ONESTOPBIT := 0. ONE5STOPBITS := 1. TWOSTOPBITS := 2.
The Windows and Unix SerialPlugin code the stop bits identically, although on Unix the 1.5 setting apparently gets rounded up to 2. See man termios for the reason.
Windows:
/* set stop bits */ switch(stopBitsType) { case 0: dcb.StopBits = 1; break; /* 1.5 stop bits */ case 1: dcb.StopBits = 0; break; /* 1 stop bit */ case 2: dcb.StopBits = 2; break; /* 2 stop bits */ default: goto errExit; }
Unix:
/* stopBits 0=1.5, 1=1, 2=2 */ /* I don't know how to get 1.5 stop bits. Oh well. So you get 2 instead */ #define MAX_STOP_BITS 2 /* c_cflag definitions */ static const unsigned int stopBitsDecode[MAX_STOP_BITS + 1] = { CSTOPB, 0, CSTOPB };
Someone trying to write code that works across platforms will get snagged, at least if using the usual Windows definitions. Is this something that can/should be done better to make the stop bits as platform-neutral as possible? What would you change?
In the plugin, I would change nothing. In class SerialPlugin, I would add some better method comments.
If I wanted my application code to be easier to understand for someone accustomed to Windows headers, I might consider making ONESTOPBIT, ONE5STOPBITS and TWOSTOPBITS be class variables somewhere in my application. But that looks a bit silly, so I guess I just go with the method comments and leave it at that.
Dave
vm-dev@lists.squeakfoundation.org