troubleshooting Question

SetCommState, DTR. RTS and unexplained long delays

Avatar of rossmcm
rossmcmFlag for New Zealand asked on
Microsoft Development
2 Comments1 Solution1385 ViewsLast Modified:
I have an app (Delphi 5) that switches the baud rate of a COM port in between sending and receiving - i.e. it usually communicates with a peripheral at 2400 baud (sends and receives at 2400) but occasionally needs to send a command at 2400 and receive a response packet at 19200.  It knows when it needs to do this and so I wait till the command packet is sent, then switch the baud rate for the response.  After the response has been received I switch it back to 2400 again.  This worked fine under Win16 where I had direct port access available, however the W32 port doesn't work, because...

As well as switching the baud rate this app requires DTR and CTS to be set into specific states (they actually provide power to the serial peripheral).  I have noticed that changing the baudrate seems to reset these control lines so I have code to reassign the states of DTR and RTS after the baud rate is changed.  

The problem is that the call to set the baud rate takes a long time - like 100's of mS.  I'm using the Async32/VaComm component and I've traced it into VaComm but it's the actual call to the API (SetCommState) where the delay occurs. As a result, the power to the peripheral dies for 200 mS or so.

Any idea why this API call takes so long, or, is there is any way of changing the baud rate of a port without calling this API?
ASKER CERTIFIED SOLUTION
mblat

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros