3 ms·
I'll never understand the mindset behind windows developers that says: "When starting a project to do some simple low-level task, first throw up a uselessly sim
by ajross 18y ago
I'll never understand the mindset behind windows developers that says: "When starting a project to do some simple low-level task, first throw up a uselessly simple GUI application and put a button on it." I mean, half of this article is about how to use the GUI wizard, just to show off about 10 lines of code.
Beyond that, it's reasonably instructive. I'm happy to know that RS-232 isn't forgotten in the .NET world; there is lots of legacy hardware out with important things to say.
Although I was amused by this bit of hubris in the API design:
serialPort1.StopBits= StopBits.One;
I'd be curious to hear why the designer felt that the concept of a "stop bit" was so important or complicated that it deserved its own abstraction for the number one. :)
- jcl 18y agoIt looks like the StopBits enumeration is in place for type-safety. It has the values None, One, Two, and OnePointFive. With just those four values, any representation other than an enumeration would be either inefficient or confusing. http://msdn.microsoft.com/en-us/library/system.io.ports.stopbits.aspx http://msdn.microsoft.com/en-us/library/system.io.ports.stop... http://en.wikipedia.org/wiki/Asynchronous_start-stop http://en.wikipedia.org/wiki/Asynchronous_start-stop
- ajross 18y agoNot really, no. The "stop bit" is an asynchronous delay inserted between the transition edge of the final bit of a byte and the rising edge of the next start bit. It's a fundamentally analog unit of time that just happens to be measured in "bits". In principle, there could be hardware that wants three stop bits, or 0.7. To the extent that there are only four values, that's purely because of historical convention (and maybe limitations of early PC UARTs, I don't have datasheets handy). All of which could have been easily and more robustly encapsulated by the use of a float instead of the bizzaro-world enum that they chose.