 |
|
|
|
| Author |
Message |
Timothy Dean
Joined: 15 Aug 2007 Posts: 88
|
Posted: Tue Feb 19, 2008 10:59 pm Post subject: WaitCommEvent timout |
|
|
I have a loop in a separate thread that reads data from a COM port. The
loop in the thread checks a flag to determine when to exit. My problem is
when I try to stop the read loop it hangs on WaitCommEvent when there is not
data coming from the COM port. Since overlapped is not supported in CE,
what is the best way to make the WaitCommEvent time out? I can force the
issue by using TerminateThread or closing the COM port, but I want to let it
exit gracefully if possible. Thanks.
Timothy Dean
Archived from group: microsoft>public>pocketpc>developer |
|
| Back to top |
|
 |
Henryk Birecki
Joined: 15 Aug 2007 Posts: 60
|
Posted: Wed Feb 20, 2008 6:22 am Post subject: Re: WaitCommEvent timout |
|
|
"Timothy Dean" wrote:
>I have a loop in a separate thread that reads data from a COM port. The
>loop in the thread checks a flag to determine when to exit. My problem is
>when I try to stop the read loop it hangs on WaitCommEvent when there is not
>data coming from the COM port. Since overlapped is not supported in CE,
>what is the best way to make the WaitCommEvent time out? I can force the
>issue by using TerminateThread or closing the COM port, but I want to let it
>exit gracefully if possible. Thanks.
>
I think that doing a SetCommMask(hPort, mask) should release
WaitCommEvent, but I think it may also be driver implementation
dependent, which means that it is not guaranteed.
Cheers,
Henryk Birecki |
|
| Back to top |
|
 |
Uncle Marvo
Joined: 15 Aug 2007 Posts: 173
|
Posted: Wed Feb 20, 2008 2:56 pm Post subject: Re: WaitCommEvent timout |
|
|
In reply to Timothy Dean (tim.dean@mobiledataforce.com) who wrote this in
uEoPhv1cIHA.6024@TK2MSFTNGP06.phx.gbl, I, Marvo, say :
> I have a loop in a separate thread that reads data from a COM port. The
> loop in the thread checks a flag to determine when to exit. My
> problem is when I try to stop the read loop it hangs on WaitCommEvent
> when there is not data coming from the COM port. Since overlapped is
> not supported in CE, what is the best way to make the WaitCommEvent
> time out? I can force the issue by using TerminateThread or closing
> the COM port, but I want to let it exit gracefully if possible.
Have you done a SetCommTimeouts? I believe that it defaults to "not". |
|
| Back to top |
|
 |
Timothy Dean
Joined: 15 Aug 2007 Posts: 88
|
Posted: Wed Feb 20, 2008 1:41 pm Post subject: Re: WaitCommEvent timout |
|
|
I am using SetCommTimeouts, but that only sets the timeouts for ReadFile and
WriteFile, right? It doesn't seem to affect WaitCommEvent. Let me know if
I am missing something. Thanks.
Timothy Dean
"Uncle Marvo" wrote in message @mid.individual.net...
> In reply to Timothy Dean (tim.dean@mobiledataforce.com) who wrote this in
> uEoPhv1cIHA.6024@TK2MSFTNGP06.phx.gbl, I, Marvo, say :
>
>> I have a loop in a separate thread that reads data from a COM port. The
>> loop in the thread checks a flag to determine when to exit. My
>> problem is when I try to stop the read loop it hangs on WaitCommEvent
>> when there is not data coming from the COM port. Since overlapped is
>> not supported in CE, what is the best way to make the WaitCommEvent
>> time out? I can force the issue by using TerminateThread or closing
>> the COM port, but I want to let it exit gracefully if possible.
>
> Have you done a SetCommTimeouts? I believe that it defaults to "not".
> |
|
| Back to top |
|
 |
Uncle Marvo
Joined: 15 Aug 2007 Posts: 173
|
Posted: Wed Feb 20, 2008 8:55 pm Post subject: Re: WaitCommEvent timout |
|
|
Yep. What I always do is to set the Timeouts and then NOT use WaitCommEvent.
When the Read (which is most likely) times out you check the number of
characters returned, then if appropriate go back to the read, unless your
flag is set to exit the thread.
I have had loads of trouble with WaitCommEvent and indeed serial comms on
both PCs and CE/WM devices, Microsoft will deny that there is a problem as
will many people on this ng, but I can assure you that it is flaky.
The method I use has always worked though (so far)
Regards - Unc
In reply to Timothy Dean (tim.dean@mobiledataforce.com) who wrote this in
ObAubc9cIHA.4436@TK2MSFTNGP05.phx.gbl, I, Marvo, say :
> I am using SetCommTimeouts, but that only sets the timeouts for
> ReadFile and WriteFile, right? It doesn't seem to affect
> WaitCommEvent. Let me know if I am missing something. Thanks.
>
> Timothy Dean
>
> "Uncle Marvo" wrote in message
> @mid.individual.net...
>> In reply to Timothy Dean (tim.dean@mobiledataforce.com) who wrote
>> this in uEoPhv1cIHA.6024@TK2MSFTNGP06.phx.gbl, I, Marvo, say :
>>
>>> I have a loop in a separate thread that reads data from a COM port.
>>> The loop in the thread checks a flag to determine when to exit. My
>>> problem is when I try to stop the read loop it hangs on
>>> WaitCommEvent when there is not data coming from the COM port. Since
>>> overlapped is not supported in CE, what is the best way to
>>> make the WaitCommEvent time out? I can force the issue by using
>>> TerminateThread or closing the COM port, but I want to let it exit
>>> gracefully if possible.
>>
>> Have you done a SetCommTimeouts? I believe that it defaults to "not". |
|
| Back to top |
|
 |
Uncle Marvo
Joined: 15 Aug 2007 Posts: 173
|
Posted: Wed Feb 20, 2008 9:01 pm Post subject: Re: WaitCommEvent timout |
|
|
In reply to Me (I'm losing my grip) (paul.r@deletethisbitfortescue.org.uk)
who wrote this in 6230rjF21es72U1@mid.individual.net, I, Marvo, say :
BTW -
1. you're not hiding your email address at all, you WILL get chopped ham and
pork, and lots of it.
2. If you email me I have a piece of code you're welcome to, which works.
Regards - Unc
|
|
| Back to top |
|
 |
|
|
| Related Topics: | htc s710 and windows mobile center I have a problem with my new HTC s710 and that is that it that my device isn't recognised by windows mobile device center. I have a pc with Vista ultimate. I have installed the latest updates etc etc. Please can anyone help me? Ludi
Dumb question about tasks Hi, One of our client have bought an iPAQ PocketPC2003. I don't really know those deviced even if it looks like windows in some way. But after we sync GroupWise with it, how can we see all upcoming tasks? We only see the actual day or all pasts tasks.
notes program Hi, I have a tmobile wing and the notes program is cool. It saves my scribblings in some dwi format. How can I get those notes into my dektop PC?
Windows Mobile 5 & Bluetooth GPS Having tried and failed to get a GPSlim236 to work with TomTom on my i-mate JasJar I started looking around and found quite a few references to issues with Mindows Mobile 5 and Bluetooth GPS sets. However none of them really get to the bottom of what the
MPX220 - duplicate inbox mail when sync with outlook I have the followiing problem when i sync my mpx220 with outlook on windows xp sp2: Allmost all my emails are created in 3-4 times in my pc, so if i had originally 700 emails now i get 4500 emails!!! |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|