COMPORT Component
Version 0.9
December 13, 2001
by Pete Kleinschmidt - petek1827@yahoo.com

This COMPORT Component implements some of the functionality of the missing QCOMPORT Component. It uses
the WIN32 API and does not require any additional dlls. Simply add the line
$INCLUDE "COMPORT.CMP"
to the top of your project and go.

Please note that the COMPORT Component was developed for a small in-house application. As
a result it has not been extensively tested. It currently seems to work well on my system (Win98SE)
but I cannot guarantee that it will work for others. Use at your own risk.

There are three files included in this package.

COMPORT.CMP     This is the file that implements the COMPORT Component
PORTAPP.BAS     This is a small application that demonstrates using the COMPORT Component
README.TXT     Your reading it.

Properties
 
Field Type R/W Default Description
Handle LONG R -  
Port STRING RW "COM1"  
BaudRate DWORD RW 9600  
DataBits BYTE RW 8 number of bits/byte, 4-8
Parity BYTE RW 0(NOPARITY)  
StopBits BYTE RW 1  
ReadBufSize DWORD RW 1024  
WriteBufSize DWORD RW 1024  
BytesNotRead DWORD R 0 number of bytes received but not yet read
BytesNotWritten DWORD R 0 number of bytes remaining to be transmitted
Connected BYTE R 0(FALSE)  


Methods

Name    Type    Description
Open    SUB    Opens Communication Port  
Close    SUB    Closes Communication Port  
WriteString    SUB   WriteString(Str$, Wait AS Dword)   Writes a string to a Communications Port Wait time is in milliseconds
ReadString    FUNCTION (dwRdSize AS DWORD, Wait AS Dword) as String     dwRdSize AS DWORD  Returns a string representation of data read from a Communications Port Wait time is in milliseconds

Events

Name    Type    Occurs when
OnOpen    SUB    Com Port is successfully opened
OnClose    SUB    Com Port is successfully closed
OnWriteString    SUB    Data successfully written to Com Port
OnReadString    SUB    Data successfully read from Com Port
OnComError    SUB(ErrorMessage AS String)    An error occurs



Before you begin trying to work with this component I recommend that you make sure you can
communicate with your target device using a terminal program. Make sure you understand what
settings your device requires and what commands it expects. There are probably dozens of these
programs at your favorite shareware site.

This component currently does not have the ability change flow control settings (Hardware, Xon/Xoff, etc).
When a port is opened it should default to whatever flow control settings were last used to open
the port or to the default settings. Implementing it should not be difficult if you have a good handle on how
flow control works. It should only involve changing some of the Device Control Block (DCB) settings
the same way I currently change Baud, Parity, etc. Deciding which ones and in what order would be
the tricky part. The following docs may help you out.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/hardware/commun_2pf7.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwbgen/html/msdn_serial.asp

Please Do not email me asking for help on how to use this component. Post your questions
to the discussion board. I really wish I had the time to help you, but I don't. Bug reports
are welcome.