Thread&time critical port processing
Posted on 2005-03-21
I am developing application which controls DTR singnal on com port or set some values on LPT port.
I am using delphi6&7.
For com port handling I use CPortLib, for LPT SmallPort.
The problem I don't know how to make processing accurate as it can be.
while not self.terminated do
- some non time critical processing.
start of loop which calculates times based on some values passed in string...
- CalculateTimeDTR should be on
calculate TimeDTR should be off
SetDTR (false, stoptime, durationtime)
end of loop
procedure TMyThread.SetDTR(onoff: boolean;var StopTime: Cardinal;DurationTime: Cardinal);
while Windows.GetTickCount<StopTime do Sleep(1);
if onoff then ComPort.SetDTR(true)
Priority of thread is set to tpTimeCritical.
What to do to maximum accurracy of port output.
ComPort&LPT components are created in thread.
Basicaly my thread does not need processor all the time, but only when the right time comes.
Some questions will be posted later. Thanks for any hints/ideas....