Serial COM port communication problems



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.

.



Relevant Pages

  • Re: Serial COM port communication problems
    ... The serial port receives char packets of different sizes, ... 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: ports/126853: ports-mgmt/portaudit: speed up audit of installed packages
    ... I think it won't be very hard: I'll try to see how to extend portaudit ... port sources to give the port version that includes both mentioned ... Affected package: ruby-1.8.6.111_4,1 ... Download is made in the mirror mode, ...
    (freebsd-hackers)
  • Re: Strange capture of my eth0 interface.
    ... but I doubt if there is any connection. ... so I did a fresh install. ... > then seeing that the package manager does indeed detect the switch - don't ... > Port numbers are like telephones. ...
    (comp.os.linux.security)
  • Re: amd64 questions
    ... so if you want to install a 64 bit package ... install of a 32-bit pkg with its dependencies. ... them (ie libraries in /usr/lib32). ... have a broken copy of the tarball the port is using. ...
    (freebsd-hackers)
  • Re: amd64 questions
    ... amd64 object files. ... so if you want to install a 64 bit package ... My copy of the port sets that for amd64 already. ...
    (freebsd-hackers)