I have a need for read and write access a COM port for an application. It appears that MS Visual C++ and Visual Basic no longer support "conveinient" library functions for the COM port. As such I decided to build my own Communications Class with Window API functions found in windows.h. The experience would be good.
The MSDN site is helpful to some extent, with a huge portion of the site dedicated to APIs. However, the examples frequently introduce new terminology and concepts, of which I am woefully unfamiliar, i.e. threads, that produces more questions per line of code than anything else. Conceptually it sounds like threads behave as hardware interrupts. What say you?
I can open and close COM1: and setup the DCB and TimeOuts, which is all fairly straight forward. Using WriteFile, the recommended method to write to the port, I receive a persistent error code (5) from GetLastError(). The decoded meaning is "Access Denied". What could be causing this error?
According to MSDN literature, API functions like WriteFile and ReadFile have a pointer to a structure in their parameter list called OVERLAPPED. Windows CE requires NULL for the structure pointer because it does not support overlapping (asynchronus operation of RX and TX sides). Does Windows-XP allow for NULL pointer to OVERLAPPED if the application needs only synchronus TX/RX capability? I wonder if this might be contributing to the cause of error-5.
In past months I've seen a coule of homebrew classes for communications using the API, but I don't fully understand what the authors intent, so prefer to avoid implementing something I can't support.
Your constructive comments would be greatly appreciated.
Regards,
J=K
Saints have a past and Sinners have a future.



LinkBack URL
About LinkBacks


