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?