Jim.Gilliland@p3.f209.n141.z1.FIDONET.ORG (Jim Gilliland) (01/30/90)
RY> The reason that I ask is that I'd like to optimize RY> the sending of data across that COM port. RY> That is, I'd like to write the COM port at will with RY> any size of data, however I'd like these writes to RY> be buffered and then sent when a timer expires or the RY> queue fills up. There's no simple way to do this because there is no way to get the COM device driver to tell you when its queue is empty. You can get reasonably good COM device performance, though, by using DosWriteAsync to write to the port, allowing you to prepare the next "packet" while the current one is being sent. The DosWriteAsync will always return control immediately, but it will clear a semaphore when the write has actually completed. If the COM queue has room for the data, the semaphore will be cleared very quickly. If the queue is full, then the semaphore will not be cleared until enough data has been transmitted to allow the new data to enter the queue. By the way, you mentioned using a low-priority thread to do the writes. I would instead use a high-priority thread, if performance is your goal. As long as the thread is blocked on a semaphore, you will not be wasting CPU resources - your thread will keep the queue full, but will be idle (and blocked) otherwise. Obviously, though, you do NOT want to do any polling or unnecessary looping in such a thread. The best solution, of course, would be for the COM driver to support a user-specified and/or variable-size output buffer. But it doesn't. -- Jim Gilliland - via FidoNet node 1:140/22 UUCP: alberta!dvinci!weyr!141!209.3!Jim.Gilliland Internet: Jim.Gilliland@p3.f209.n141.z1.FIDONET.ORG Standard Disclaimers Apply...