473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Overlapped I/O on XP

Hi -

I'm using overlapped i/o on Windows 98 and on XP
and am getting different results.

Here's the code snippet:

// read the command id and the message length
BOOL rc;
ResetEvent(m_SerialRecvOL.hEvent);
rc = ReadFile(m_hSerialPort, &buf[1], 6, pBytesRead,
(LPOVERLAPPED) &m_SerialRecvOL);
if (!rc && GetLastError() == ERROR_IO_PENDING) {
waitStatus = WaitForSingleObject(
m_SerialRecvOL.hEvent, 5000);
if (status == WAIT_OBJECT_0){
GetOverlappedResult(m_hSerialPort,
&m_SerialRecvOL, pBytesRead, FALSE);
rc = TRUE;
}
}

On windows 98, ReadFile returns with rc = false
and pBytesRead = 0 and then the operation is
successfully completed later and GetOverlappedResult
fills in pBytesRead with 6 to indicate 6 bytes read.

On XP, ReadFile returns right away with rc = true
and *pBytesRead = 3. I don't get all my data (6 bytes),
yet the call to ReadFile indicates that it's done
even though it only reads 3 bytes.

Can anyone tell me what I'm missing here?

Thanks,
Donna Rigas
ioline corporation

Nov 16 '05 #1
1 1806
Hi,

I think this is normal for a serial port. You need to keep reading until no
more data arrives, or you have the data you are expecting. Not sure
specifically why W98 and XP behaviour differs but this is hardly surprising
as XP is a NT derivative so completely different underlying code.

PS This is not really a suitable NG for this subject

Cheers

Doug Forster

"donna rigas" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
Hi -

I'm using overlapped i/o on Windows 98 and on XP
and am getting different results.

Here's the code snippet:

// read the command id and the message length
BOOL rc;
ResetEvent(m_SerialRecvOL.hEvent);
rc = ReadFile(m_hSerialPort, &buf[1], 6, pBytesRead,
(LPOVERLAPPED) &m_SerialRecvOL);
if (!rc && GetLastError() == ERROR_IO_PENDING) {
waitStatus = WaitForSingleObject(
m_SerialRecvOL.hEvent, 5000);
if (status == WAIT_OBJECT_0){
GetOverlappedResult(m_hSerialPort,
&m_SerialRecvOL, pBytesRead, FALSE);
rc = TRUE;
}
}

On windows 98, ReadFile returns with rc = false
and pBytesRead = 0 and then the operation is
successfully completed later and GetOverlappedResult
fills in pBytesRead with 6 to indicate 6 bytes read.

On XP, ReadFile returns right away with rc = true
and *pBytesRead = 3. I don't get all my data (6 bytes),
yet the call to ReadFile indicates that it's done
even though it only reads 3 bytes.

Can anyone tell me what I'm missing here?

Thanks,
Donna Rigas
ioline corporation


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: yamadora1999 | last post by:
hi :) http://groups.google.com/groups?q=author:dmost%40magna.com.au&hl=ko&lr=&ie=UTF-8&selm=8pguo8%24bbl%241%40nnrp1.deja.com&rnum=3 GetQueuedCompletionStatus is return new OVERLAPPED yet. i...
5
by: Michelle Kinsey-Clinton | last post by:
Hello, I am writing an ASP app which is giving me some very frustrating errors. They appear intermittently, no real pattern to them, and often go away if you reload, or back up a few pages and...
3
by: AmyAdmin | last post by:
I am running windows 2000 with IIS 5.0 and I have ASP and .NET apps running on that server, and I've been getting the error message in my event viewer: DCom got error "Overlapped I/O operation is...
1
by: Lewap | last post by:
Hi! I have a problem: Function CreateNamedPipe (a piece of source below) called in a NT service I get an error 997 - Overlapped I/O operation is in progress. When I run the same code as...
2
by: CeZaR | last post by:
Hi, What does the "overlapped" word means in windows programming? I've read about overlapped structures, functions?! What does it mean? Thanks!
1
by: dvestal | last post by:
I'm trying to use Overlapped I/O from C#, and utterly failing. I've tried to boil down my code to as simple an example as possible, in hopes that you people can point to where I'm going wrong. ...
4
by: Eric Renken | last post by:
I am trying to do an Overlapped ReadFile on a HID device and it just isn't working for me. The WaitForSingleObject keeps giving me an error "The system cannot find the file specified." This...
0
by: Ingenious | last post by:
Hi I am reading data from device in overlapped way. i am able to read the data correctly with WaitforMultipleObject() but now i want to use HasOverlappedIoCompleted () to inceraese the speed...
7
by: =?Utf-8?B?TmljayBCdXJraXR0?= | last post by:
Hi. I have a C# app that uses named pipes via InteropServices. I have no problems running on a 32-bit machine, or when targeting x86 architecture, but it fails on a 64-bit machine when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.