Hi Mats,
I already spent two days on msdn library to figured out. I’ll try to be more
specific in few lines.
There is a simple communication between PC and some external device on COM,
without handshaking, etc. just simple async. communication. The PC initiate
(request) the transfer with a block of 16 bytes and the device respond with
another block ( in my case 12 bytes ). It’s just a convention, I wrote both
programs ( PC and asm for external device ).
In windows app. ( that?s the ugly part ) I have a lot of interface buttons,
combo, etc and I can’t just put some loop to watch the serial port ![:slight_smile: :slight_smile:](/images/emoji/twitter/slight_smile.png?v=12)
because the program will latch in that loop without the incom data.
So, I get some serial-port-component from net, I dropped into my app. And in
his EV_RXCHAR event I expect to collect the data ONLY when it arrives on COM
port. This event comes with a parameter “Count” wich should indicate the
number of bytes ready to be read. That?s the event code ( cbuilder style ):
void __fastcall TTIGER::Comm1RxChar(TObject *Sender, DWORD Count){
BYTE *sData = new BYTE[Count];
Comm1->Read(sData,Count);
//do something with data
deletesData;
sData=NULL;
}
As I said before, I expect Count = 12 ( whenever arrives ) and in win98
works fine allways, but in 2000/XP the bytes don’t arrives all together. The
event handler is called few times to get all 12 expected bytes.
Sometimes arrives 3, 4, 5, othertimes 8 bytes and after the last 4 but never
all 12 together. I increase app. thread prio to “Time Critical” but nothing.
I don’t have a header in protocol, so I need to watch the number of bytes
arrived and after, some checksum, etc.
How can I force to read all bytes within a time-window ( a timeout ) but
still remain in that event.
Thanks in advance,
eddy
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mats PETERSSON
Sent: Tuesday, October 26, 2004 11:04 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] irp_mj_read problem
Hi Eddy,
I’m not sure what your question is, but I’ll try to explain what I think
you’re asking.
- The serial port has a buffer of some sort. The serial driver can set up
when (at which buffer fill-level) it wants the serial port to interrupt.
It’s not unlikely that XP and 98 have different setups here.
- The handling of interrupts, while on a high-level it’s the same, there
are most certainly big differences in XP and 98 here, which means, maybe,
that 98 has a slower response to interrupts.
3, The handling of process/thread switching is quite different in Win98 and
XP.
- Different hardware platforms have different speeds, which affects all
sorts of things, includig process/thread switching, interrupt response
time, I/O port read times, etc.
All the above variables will affect how quickly the OS (driver) can get
data out of the serial port, what size “lumps” it comes in.
Since there isn’t a concept of packet on the basic serial port at the
hardware level, other than a word-size of (usually) 8 bits. (You can add
that layer in software), the serial driver has no idea of what the software
expects, and as such can not tell whether the software expects to read 1,
2, 5, 8, 16, 23 or any other number of bytes (yes, it could look at the
read request, but that’s often misleading, because it may well request to
read 1000 bytes, but the data arriving may only be 3 bytes).
So, when reading data from the serial port, you must expect it to return
ANY number of bytes from the last read (up to the maximum that you specify,
obviously).
I’m sure you can solve your problem by adding a simple loop (with timeout
of course) that reads the expected number of bytes.
If this didn’t actually clarify your situation, please let me know.
–
Mats
xxxxx@lists.osr.com wrote on 10/26/2004 05:03:18 AM:
Hi all,
I am not an expert in writeing drivers. I build some software to
aquire some data from serial port. In windows98 works great. In
2000/XP are some problems.
My function to get data from serial port is something like:
Comm1->Read(buffer,nr_of_bytes_to_read);
wich it’s called from an RXChar event.
In win98 I can get with this blocks of data ( eg 16 bytes to read
once ) but in XP the data arrives in the event chaotic ( sometimes
in blocks of 8 bytes, some times one-by-one bytes and never like I
expect). I watch the requests with PortMon.
I tested many components ( drivers ) for Delphi / CBuilder / .NET
and all the same thing. What is the problem ? My app. is just a
simple logger of few bytes givem by a microcontroller on serial
port. I can give more details if needed.
Thanks in advance,
eddy
Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004
ForwardSourceID:NT00006072
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@hcv.ro
To unsubscribe send a blank email to xxxxx@lists.osr.com
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004