Re: Serial COM port communication problems



On May 21, 6:18 am, an0...@xxxxxxxxx wrote:
Hi,

Working on a application that does extensive Serial I/O and using MSDN
functions as WaitCommEvent(). CreateFile is used to open the com
port, and use ReadFile() and WriteFile() to read and write to the
serial port.

The serial port receives char packets of different sizes, each packet
is divided by different size sub-packets, each of those sub packets
contains a CR char that signals it's (sub-package) end. The end of the
hole package is embedded only on the interpretation of the last sub-
packet inside the main packet...

The receiving buffer is read by setting the mask to rx flag being the
event char CR, so, each time the CR is detected, an event is triggered
and the read port operation is then called. The problem is that many
sub-packages arrive in succession and some sub-packages are lost. I
suppose some bytes are lost while the Read operation triggered by
arrival of the CR event reads the Buffer.

As for now the only way to get the hole package is by reading the
receiving buffer after some time has elapsed or when one knows for
sure that the package has arrived by counting nearly by hand the
number of events, not so nice...

I would like to read the receiving buffer each time a sub-package is
detected but I don't know if that is a good approach as sub-packages
arrive in quick succession and information is lost.

The other approach that was tested is to read each byte that arrives
and later build up the entire package and analyze it, in this case the
Overlapped method was used after requesting the number of bytes in the
receive buffer. But for some reason packages are also lost.

From the other side of the transmition there is no further

signalization, overhead or a fixed package size.

Unfortunately I don't know how to continue or even if the approach is
a good one. Any advise or ideas would be kindly appreciated, Thank you
very much.
Best Regards

PD: I have read the document serial comminication in Win32 and many
other related documents from code guru. I found pertinent to ask some
advice at dejanews too.

I have few question regarding to your post:

0) What is your COM device? is it some MCU or anything else.
1) What baudrate you are on? switching to some other baudrate should
confirm the consistent error rate that should make sure about hardware
reliability.
2) What is average packet size of yoru data?
3) Last but not least, what is the cable length tha tyou are using
between device and PC? i had a wier experience in last few days about
that.



ali

.



Relevant Pages

  • Serial COM port communication problems
    ... serial port. ... The receiving buffer is read by setting the mask to rx flag being the ... sub-packages arrive in succession and some sub-packages are lost. ... As for now the only way to get the hole package is by reading the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Command: df
    ... > in which packet should I look??? ... a TCP packet. ... difference between a packet and a package.) ... Summary: The GNU core utilities: a set of tools commonly used in shell scripts ...
    (comp.os.linux.development.system)
  • Re: Packet Construction and Protocol Testing...
    ... :This is a set of Python libraries which make writing protocol testing ... :Summer of Code student I'm working with has also been using this ... :This code sends a quick and dirty, ICMPv4 ping packet on localhost. ... :currently a simple manual in the package. ...
    (freebsd-net)
  • Re: Problems with CAsyncSocket.
    ... I will get exactly the entire packet. ... laptop and usually always on an different PC I will receive only ... a part of a package. ... and then go back to receiving. ...
    (microsoft.public.vc.mfc)
  • Re: Ice Cream Directions Translation
    ... > Danny Wilde wrote: ... Add the contents of the Mix 1 package to the mixture, stir ... You would just add the packet, ...
    (sci.lang.japan)