By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,933 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,933 IT Pros & Developers. It's quick & easy.

Unable to set fparity member of DCB structure using SetCommState()

P: 1
I need ur help regarding Serial communication in Win32.

The problem, i m having is quite strange. It is related to fParity member of DCB structure

After setting the fparity=True with SetCommState(), when i get DCB structure with GetCommState(), i always find fparity=FALSE.


I have tested it on 3 machine all running windows xp sp2 and standard COM driver but having the same problem.

Its looks as SetCommState is unable to set fparity member of DCB structure.

Plz see the code snippet

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

PortDCB.fParity = TRUE; // Enable parity checking
PortDCB.Parity = ODDPARITY; // 0-4=no,odd,even,mark,space
// Configure the port according to the specifications of the DCB
// structure.
if (!SetCommState (hPort, &PortDCB))
{
// Could not configure the serial port.
DWORD dwError = GetLastError ();
return FALSE;
}
::GetCommState(hPort, &PortDCB);
//At this place, i found PortDCB.fparity=FALSE


regards,


Asad Jahangir
Mar 20 '08 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
Sorry this question has been overlooked, you would have been better off asking it in C/C++.

Anyway, in the code you posted you never set the value of dcb.DCBlength which needs to be set to the size of the structure dcb.
Jul 15 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.