🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6018

Getting Crazy, Parity Again!

#6018
From: Ramy
Date: Sun, 19 Jun 2005 13:31
104 lines
4216 bytes
Hi all,

Bob Gonder if you still here i did not understand your last post

http://groups-beta.google.com/group/borland.public.cppbuilder.nativeapi/msg/804e82ad0dd98598?hl=en

maybe if you'll just write this part of code AS IT SHOULD BE it
will be much easier. 

Anyway.... 

Nothing i tried is not working, at the end of the code fParity
is allways '0'.

Here is my last try, i copied it AS IT IS from Microsoft web
site, from the bottom of this following page -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecoreos5/html/wce50conConfiguringaSerialPort.asp

First the code - 

int InitCommunication( void )
{
  int k = 0;
  DCB PortDCB;
  HANDLE hPort = NULL;

  hPort = CreateFile("COM1",
                      GENERIC_READ | GENERIC_WRITE,
                      0,
                      0,
                      OPEN_EXISTING,
                      0,
                      0);

// Initialize the DCBlength member. 
PortDCB.DCBlength = sizeof ( DCB ); 

// Get the default port setting information.
GetCommState ( hPort, &PortDCB );  

// Change the DCB structure settings.
PortDCB.BaudRate = 9600;              // Current baud 
PortDCB.fBinary = TRUE;               // Binary mode; no EOF check 
PortDCB.fParity = TRUE;               // Enable parity checking 
PortDCB.fOutxCtsFlow = FALSE;         // No CTS output flow control 
PortDCB.fOutxDsrFlow = FALSE;         // No DSR output flow control 
PortDCB.fDtrControl = DTR_CONTROL_ENABLE; 
                                      // DTR flow control type 
PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity 
PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx 
PortDCB.fOutX = FALSE;                // No XON/XOFF out flow control 
PortDCB.fInX = FALSE;                 // No XON/XOFF in flow control 
PortDCB.fErrorChar = FALSE;           // Disable error replacement 
PortDCB.fNull = FALSE;                // Disable null stripping 
PortDCB.fRtsControl = RTS_CONTROL_ENABLE; 
                                      // RTS flow control 
PortDCB.fAbortOnError = FALSE;        // Do not abort reads/writes on 
                                      // error
PortDCB.ByteSize = 8;                 // Number of bits/byte, 4-8 
PortDCB.Parity   = NOPARITY;          // 0-4=no,odd,even,mark,space  
PortDCB.StopBits = ONESTOPBIT;        // 0,1,2 = 1, 1.5, 2 

// Configure the port according to the specifications of the DCB 
// structure.
if ( !SetCommState ( hPort, &PortDCB ) ) 
{
  // Could not configure the serial port.
  DWORD dwError = GetLastError ();
  dwError = dwError; 
//MessageBox (hMainWnd, TEXT("Unable to configure the serial port"),
//            TEXT("Error"), MB_OK);

  return FALSE;
}

  if ( GetCommState ( hPort, &PortDCB ) )  
    k = k; 
}


I only added to the top of this code the CreateFile() function 
to open the port and it's getting Pass, and i added to the 
bottom of this code the lines -

if ( GetCommState ( hPort, &PortDCB ) )  
  k = k;                // Here i put my breakpoint  

in order to get the status of the com, my breakpoint is on the
'k = k' line. 

 --------> 

untill the last GetCommState() function i see that fParity = 1, 
BUT right after this line it's changing to Zero again! 

Why does it happen? What's the problem of this code?

I need that fParity will be '1' for parity enabled. 

Thanks very much! 

Ramy
Technical Details
Message-ID: <42b573b8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1cdafdd48cb76d8c,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ramy" <Ramy@NoMail.com>
Sender: "Ramy" <Ramy@NoMail.com>
Reply-To: "Ramy" <Ramy@NoMail.com>
Subject: Getting Crazy, Parity Again!  
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 62.0.27.159     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42b573b8$1@newsgroups.borland.com>
Date: 19 Jun 2005 06:31:36 -0700
X-Trace: newsgroups.borland.com 1119187896 207.105.83.66 (19 Jun 2005 06:31:36 -0700)
Lines: 105
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail