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,m ark,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
1 4434 Banfa 9,065
Recognized Expert Moderator Expert
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Randy Yates |
last post by:
Hi,
I work in an embedded environment in which we often use a mix of C and
assembly code. Thus a recurring requirement is to be able to take a C
header file with structure definitions as input and create an assembly
include file with the structure member offsets defined.
The problem is that the structure offsets are a
complicated function of other syntactic elements such as other
structures (I could have a structure as a member of...
|
by: junky_fellow |
last post by:
I am trying to print the offset of a particulat member in
a structure, but it's not working. I am using the following
expression to print the offset.
&(struct my_struct *)0->member_name
What's wrong with this ?
If I use,
&((struct my_struct *)0)->member_name, it works. But it seems
|
by: Chua Wen Ching |
last post by:
Hi there,
SetCommState fail to work in C#, i keep gettting the error of 87, invalid
parameter.
I use this GetLastError to get the value 87.
There is a difference between GetLastError and GetLastWin32Error
Marshal.GetLastWin32Error - returns 0 (means fail to open)
|
by: Zak Milas |
last post by:
I have the code below:
Private Sub cmdFill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdFill.Click
Dim Employee As UploadFile, Count As Integer, Temp As String
FileNum = FreeFile()
FileOpen(FileNum, TextBox1.Text, OpenMode.Random, , , Len(Employee))
Count = 1
lstView.Items.Clear()
Do While Not EOF(FileNum)
FileGet(FileNum, Employee, Count)
|
by: Steven Woody |
last post by:
hi,
i get a struct as below,
typedef struct
{
uint16_t id;
long offset;
} foo_t;
| |
by: CptDondo |
last post by:
I am missing something about structure declarations....
I am trying to get the size of a structure member using sizeof.
my xml.h file (beware of line wrap):
struct fieldSchedule_t {
uint8_t action;
uint16_t fromBearing, toBearing;
};
|
by: Hallvard B Furuseth |
last post by:
to find the required alignment of a struct, I've used
#include <stddef.h>
struct Align_helper {
char dummy;
struct S align;
};
enum { S_alignment = offsetof(struct Align_helper, align) };
|
by: deepak |
last post by:
Hi Experts,
I'm getting this compilation error while trying to access a member in
structure.
at what time we will get this error message?
Thanks,
Deepak
|
by: pereges |
last post by:
Hi, I'm trying to deallocate a kd tree which I created dynamically.
There were no problems
creating the structure and I can access it easily but there is a
problem while trying to free
it. Here's the structure for the a single node in the tree:
typedef struct kdnode_s
{
bbox box; /* Bounding box */
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |