473,406 Members | 2,369 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,406 software developers and data experts.

AutoResetEvent.WaitOne Takes Excessive Time to Return (Serial Comms)

I have a frustrating problem where WaitOne does not return when I expect.

I am using an AutoResetEvent with an overlapped structure in a call to
WaitCommEvent. The data I am expecting on the serial port is 23 bytes long,
and is sent in response to a command.

I begin timing before sending the command, and display split times when
received data is signalled. The entire exchange of command and response is
over within 6 ms (I have checked this with a scope).

When WaitOne first returns there are 18 characters in the receive buffer,
and the split time is 5 ms. As this is not the complete message, I call
WaitOne again to wait for a signal that the remaining data has been
received.

WaitOne then takes 10 ms before returning, just to signal that the remaining
5 bytes have been received.

I do not understand why the bulk of the data can be received and signalled
in 5 ms, whilst the remaining few bytes take a whacking 10 ms to be
signalled. I have checked with a scope and there are no gaps in the data -
the received data comes in as a contiguous stream, less than 1 ms after the
command is received by the remote device.

I know this is a big ask, but can anyone think why such a thing would happen
with AutoResetEvents?

TIA

Charles
Nov 21 '05 #1
1 3022
And the answer is ...

The FT232AM chip that I am using has a fixed 16 ms latency when the buffer
is not full.

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:Ol**************@tk2msftngp13.phx.gbl...
I have a frustrating problem where WaitOne does not return when I expect.

I am using an AutoResetEvent with an overlapped structure in a call to
WaitCommEvent. The data I am expecting on the serial port is 23 bytes
long, and is sent in response to a command.

I begin timing before sending the command, and display split times when
received data is signalled. The entire exchange of command and response is
over within 6 ms (I have checked this with a scope).

When WaitOne first returns there are 18 characters in the receive buffer,
and the split time is 5 ms. As this is not the complete message, I call
WaitOne again to wait for a signal that the remaining data has been
received.

WaitOne then takes 10 ms before returning, just to signal that the
remaining 5 bytes have been received.

I do not understand why the bulk of the data can be received and signalled
in 5 ms, whilst the remaining few bytes take a whacking 10 ms to be
signalled. I have checked with a scope and there are no gaps in the data -
the received data comes in as a contiguous stream, less than 1 ms after
the command is received by the remote device.

I know this is a big ask, but can anyone think why such a thing would
happen with AutoResetEvents?

TIA

Charles

Nov 21 '05 #2

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

Similar topics

2
by: M | last post by:
does c# or the .NET framework provide any serial communications support? where can i find some info on how to handle serial ports in c#? thanks m
2
by: Phil | last post by:
I have an application that has a main thread and a worker thread. From time to time, the main thread, because of user input, needs to notify the worker thread to execute an extra bit of code, in...
4
by: Charles Law | last post by:
I've been using monitors a bit lately (some of you may have heard ;-) ) and then up pop Manual and AutoResetEvents , and they look for all the world like the same thing. Are they...
3
by: Ed Sutton | last post by:
Can any one please offer any theories on how ManualResetEvent.WaitOne can hang when used with a timeout? When I notice my USB/Serial devices are no longer receiving communications, I hit break...
5
by: Maqsood Ahmed | last post by:
Hello, We have been experiencing a problem with AutoResentEvent class for past 2-3 months. It seems that it just stops at WaitOne and the thread doesn't released from blocking state. We have...
0
by: sgarcia22 | last post by:
Hello all, I workin on a windows application and it requires communicating using serial ports. The application only has one form called Form1. When I use the serial ports in the Form1.cs file...
3
by: Morgan Cheng | last post by:
In order to arrange a time-out operation, I make the task running in a worker thread; and wait in main thread with AutoResetEvent help. The code is like below. AutoResetEvent ev = new...
4
by: buu | last post by:
so, I have a private object as system.threading.AutoResetEvent, and I would like to read it's current status. currently I have an another boolean object wich I update together with an...
4
by: adlloyd | last post by:
Hi all, I've got an application that's written in C++ making use of MFC (VS6). Its purpose is to process SMS messages received from a GSM modem connected via a serial port (USB connection). The...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
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...
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
isladogs
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...

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.