473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3045
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******** ******@tk2msftn gp13.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
2581
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
12558
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 addition to it's normal work load. I created 5 AutoResetEvent objects and have the main thread call set when it wants the worker thread to execute some additional code. In the worker thread, I have 5 separate WaitOne(0,false) functions being...
4
3196
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 interchangeable, or when should I use one over the other? TIA Charles
3
10412
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 all, and one of the threads is hanging at: bool replyReceived = readerCommand.SignalReply.WaitOne(readerCmd.rxTimeOutMs, false); Apparently the 1000ms rxTimeOutMs is not working. I have two threads
5
9357
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 been using the following code for past 4 years, and It was working perfectly fine till Nov-Dec last year. I suspect a security update had messed it up. Please have a look at the following code.
0
978
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 they work just fine. I also have another in the project called COMMS.cs. When I try to use the serial port in the COMMS.cs file I get an error saying that Access to the port was denied. I know the port exists cause i have used it before in the same...
3
10880
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 AutoResetEvent(); if ( !ThreadPool.QueueUserWorkItem(WorkerProc, ev) ) { throw new ApplicationException("fail to queue task"); } ev.WaitOne(5000, false); //timeout == 5000 ms
4
5933
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 AutoResetEvent, but I don't think it's the best practice....
4
2142
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 serial communications are handled entirely in their own thread. For the most part this works perfectly.However, there appears to be a problem where multiple instances of the application are running in different Windows XP environments. It seems...
0
9546
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,...
0
10491
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, 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...
1
10247
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,...
0
9079
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, 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...
1
7571
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 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...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.