Article View: borland.public.cppbuilder.nativeapi
Article #6193Re: Please help, Parity does Not Working Again........
From: Bob Gonder
Date: Wed, 01 Jun 2005 17:35
Date: Wed, 01 Jun 2005 17:35
50 lines
3228 bytes
3228 bytes
Ramy wrote:
>Hi, i don't know what's happened but suddenly it's stoped working,
>few hours ago i checked it and it wokred just fine, the parity
>flag 'fParity' was '1' ( = Enabled ) and i saw on the scope
>device the parity bit, but suddenly it stoped working, here is
>my code, near it's bottom you can see the line "k = k;" , just
>after i sucessfuly read the state of the port, when the
>program reach to the breakpoint that i put on this line, i can
>see in the watch that 'my_DCB.fParity' value is zero ( 0 =
>Disabled )although that as you can see at the beginning of the
>function i set "my_DCB.fParity = 1;", so how come it's suddenly
>changing to '0' ??
>
>
> my_DCB.DCBlength= sizeof( my_DCB ); // Sizeof(DCB)
> my_DCB.BaudRate = SystemInfo.ComInfo.BaudRate; // Current baud rate
> my_DCB.fBinary = true; // Binary mode, no EOF check
{big snip}
> if ( my_DCB.fParity == 1 ) // If Parity Checking Enabled
> {
> switch( my_DCB.Parity ) // Switch By Parity Value
> {
> case SPACEPARITY:
> strcat( com_params, ", S, 8, 1" ); // Set Parity to '1'
> break;
>
> case MARKPARITY:
> strcat( com_params, ", M, 8, 1" ); // Set Parity to '0'
> break;
> }
> }
> if ( !BuildCommDCB( com_params, &my_DCB ) ) // Fills DCB Structure with Com Values
> return FAIL;
Well, now, this is at least the third time I'm telling you not to do
that.
BuildComDCB replaces all of your hard work up at the top, with
whatever Bill Gates thinks is best for you.
If you really need to use that function (and I don't think you do),
then use it to set defaults, and *then* override them with your
indiviual settings (such as fParity=1)
IOW, you already set the baud rate, the parity settings, seems like
everything has been set manually in my_DCB, and then you throw it all
away with a call to BuildCommDCB() ?
Technical Details
Message-ID:
<hlrr9117ici0n26ua1vmn2odmbri4mornt@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<429ddcd0$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: Wed, 01 Jun 2005 10:35:04 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <hlrr9117ici0n26ua1vmn2odmbri4mornt@4ax.com> References: <429ddcd0$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.154.209 X-Trace: newsgroups.borland.com 1117647302 67.77.154.209 (1 Jun 2005 10:35:02 -0700) Lines: 53 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail