469,963 Members | 1,344 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

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

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
1 4157
Banfa
9,065 Expert Mod 8TB
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.

Similar topics

10 posts views Thread by junky_fellow | last post: by
2 posts views Thread by Chua Wen Ching | last post: by
5 posts views Thread by Steven Woody | last post: by
9 posts views Thread by CptDondo | last post: by
3 posts views Thread by Hallvard B Furuseth | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.