Article View: borland.public.cppbuilder.nativeapi
Article #6473Re: Response not in que?
From: Neil P.
Date: Wed, 11 May 2005 13:38
Date: Wed, 11 May 2005 13:38
65 lines
3860 bytes
3860 bytes
I like to thank everyone for helping me. I hope the code snippet did not confuse anyone, and I know I might not be doing things right, but I am trying to correct my mistakes. I don't use CheckCommStatus() anywhere in my snippet? > Your use of CheckCommStatus() to poll the serial port status could be > slowing the code down. If you get rid of it entirely and just let the > overlapped I/O do the work for you, you'll probably notice that your unit's > responses come through a lot faster. You know that the unit should be > sending a byte back to you, so just perform an overlapped reading > immediately after you finish writing, and you will still be able to detect > when the reading has completed. > Gambit Let me explain, a little more to see if my problem becomes a whole lot clearer for everyone. I have developed a unit that talks with a software application using commport 1 or COM1. The embeded unit and pc software is communicating @ 9600 baud. The pc software is the master and the embeded unit is a slave. I poll the embeded unit and it responds ( < 1ms) for all intend and purposes. I tested the respond time of the embeded unit using Hyperterminal and it never fails ( < 1ms) you can't even time it, if all your using is Hyperterminal, just see that it always respond immediately. Now, if Hyperterminal is using the same baud rate and same settings as my application, I expect my application to behave the same way. Yet what I find, is that in the snippet I sent if I write a little more test code, where I increment a counter to see how many attempts it takes to recieve the information coming from the embeded unit, I find that it sometimes takes more than 3 tries, sometimes more than 10 tries, before the unit comes out of the loop. The question is why? The information should be there almost instantly. This is my calculations, 9600 baud = 104.16 us per bit, if I am recieving just one byte coming back, 104.16 uS x 8bits = 833.28 uS in my code snippet, I use GetTickCount to start a timer of the number of bytes expected and I go ahead and multiply it by 2, so at to give it even more time. So if I am doing things correctly, I should have 833.28uS x 2 1.66Sec approximately double the time it would take for that byte to actually get Windows to pick up the byte and have it ready for me to read it? I go a step further and give the application an extra three times to try and it still fails? I don't understand why? Everything tells me the byte should be there and maybe it is, but definetly I am doing something terribly wrong in my Read snippet, because I am not getting that byte???? Can you guys look at my snippet and see what I am doing wrong, I have no idea, I have tried everything I know? Thank you, Neil P.
Technical Details
Message-ID:
<42820cad$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<427fa27e@newsgroups.borland.com> <vugv711ona1kdbekucqqkg6csqkcd4agrd@4ax.com> <427fca8b$1@newsgroups.borland.com> <427fce92$1@newsgroups.borland.com> <427fd0af@newsgroups.borland.com> <427ff371$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,369fa724017da622 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Neil P." <nporve01@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <427fa27e@newsgroups.borland.com> <vugv711ona1kdbekucqqkg6csqkcd4agrd@4ax.com> <427fca8b$1@newsgroups.borland.com> <427fce92$1@newsgroups.borland.com> <427fd0af@newsgroups.borland.com> <427ff371$1@newsgroups.borland.com> Subject: Re: Response not in que? Date: Wed, 11 May 2005 09:38:11 -0400 Lines: 69 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 68.209.111.59 Message-ID: <42820cad$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1115819181 68.209.111.59 (11 May 2005 06:46:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail