com port interface
Hi elrayes,
Fortunately, dealing with virtual serial ports is transparent and exactly the same as dealing with regular serial ports (provided you’re not the one creating the virtual port).
Unfortunately, there’s no specific API for dealing with serial ports, so you’ll have to either treat them as files, or use a ready made ActiveX or COM object with its associated API.
If you’re a seasoned programmer and begin with a good design (as opposed to hacking code), the task of writing a “driver”/API is not difficult and the code practically writes itself (very few lines of code, really!), but otherwise writing a robust serial communication engine is not trivial.
I could briefly say that this involves the following:
1. open the COM as an overlapped file;
2. create and spawn 3 threads taking care of reading, writing and management (monitor and shut-down), respectively, together with associated synchronization events (to be used with WaitForMultipleObjects);
3. pumping messages in and out of circular (or dynamically allocated, whichever you prefer) buffers.
If what I said here sounds familiar, you’ll have no problems writing your own API quickly and I think you should attempt to do so.
Otherwise I’d suggest finding a good ActiveX.
Arthur