Article View: borland.public.cppbuilder.nativeapi
Article #6209Re: Please help, Parity does Not Working Again........
From: Bob Gonder
Date: Thu, 02 Jun 2005 17:10
Date: Thu, 02 Jun 2005 17:10
59 lines
3005 bytes
3005 bytes
Ramy wrote: >>CreateFile(...); >>BuildCommDCB(...) >>SetCommState(...) >>SetCommTimeouts(...) >> >>What exactly do you say, that i can remove the call for the >>SetCommState() function? ( i prefer to use BuildCommDCB() >>becouse it's giving me much more control ). > >Sorry, i ment to say that i prefer to use 'SetCommState' (not >BuildCommDCB() as i said ) becouse it's giving me much more Yes, use SetCommState, I never ever mentioned not using SetCommState. >control as you see in the large DCB init part at the begining >of the function. Ok, see all of that "large DCB init part at the begining" ? That's all going to waste because after that, you are calling BuildCommDCB() which completely replaces all of those settings. (Help says it only replaces some of them, but it's pretty obvious that it is replacing some that you don't want replaced) You do this ( just a small bit of your code): my_DCB.BaudRate = SystemInfo.ComInfo.BaudRate; my_DCB.ByteSize = 8; my_DCB.Parity = (char)SystemInfo.ComInfo.Parity; Then you do this: BuildCommDCB( "COM1:9600,S,8,1", &my_DCB ) Which internally does this: my_DCB.BaudRate = 9600; my_DCB.ByteSize = 8; my_DCB.Parity = 4 And, it goes on to reset all of the other settingsin my_DCB to whatever Bill Gates thinks is best for you. My suggestion is to either Not use BuildCommDCB at all, because it just overrides all of your settings, or use it *first*, and then override the automatic settings with your own. So...One of these: my_DCB.BaudRate = SystemInfo.ComInfo.BaudRate; my_DCB.ByteSize = 8; my_DCB.Parity = (char)SystemInfo.ComInfo.Parity; . . . etc . . . SetCommState - - Or - - BuildCommDCB( "COM1:9600,S,8,1", &my_DCB ) my_DCB.fBinary = true; my_DCB.fParity = 1; (whatever else you need setting that BuildCommDCB didn't set for you ) SetCommState
Technical Details
Message-ID:
<gmdu911tosvsi52h9nhjg5s59406ea2q50@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<429ddcd0$1@newsgroups.borland.com> <hlrr9117ici0n26ua1vmn2odmbri4mornt@4ax.com> <429ebbbf$1@newsgroups.borland.com> <429ebe00$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,499887f6c1e08a34 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Please help, Parity does Not Working Again........ Date: Thu, 02 Jun 2005 10:10:50 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <gmdu911tosvsi52h9nhjg5s59406ea2q50@4ax.com> References: <429ddcd0$1@newsgroups.borland.com> <hlrr9117ici0n26ua1vmn2odmbri4mornt@4ax.com> <429ebbbf$1@newsgroups.borland.com> <429ebe00$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.200.242 X-Trace: newsgroups.borland.com 1117732248 67.77.200.242 (2 Jun 2005 10:10:48 -0700) Lines: 61 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail