| Class TVSSComm32 (unit VSSComm32) |
TComponent
| Constructors |
constructor Create( AOwner: TComponent );used as a check if file is assigned (******************************************************************************) TVSSComm32 PUBLIC METHODS (
| Functions |
destructor Destroy;
function StartComm: Boolean;
procedure StopComm;
function WriteCommData( pDataToWrite: PChar; dwSizeofDataToWrite: Word ): Boolean;
procedure CloseReadThread;TVSSComm32.
procedure CloseWriteThread;
procedure ReceiveData( Buffer: PChar; BufferLength: Word );
procedure RequestHangup;
procedure CommWndProc( var msg: TMessage );
function GetReceiveDataEvent: TReceiveDataEvent;
function GetRequestHangupEvent: TNotifyEvent;
procedure SetCommsLogFileName( LogFileName: string );
procedure SetReceiveDataEvent( AReceiveDataEvent: TReceiveDataEvent );
procedure SetRequestHangupEvent( ARequestHangupEvent: TNotifyEvent );| Properties |
property BaudRate : TBaudRate
property CommPort : Tcommport
property DataBits : TDatabits
property Parity : TParity
property StopBits : TStopBits| Events |
event OnReceiveData : TReceiveDataEvent
event OnRequestHangup : TNotifyEvent| Variables |
FBaudRate : TBaudrate;
FCommPort : TCommport;
FCommsLogFileName : TCommport;
FDataBits : TDatabits;
FHWnd : THandle;
FOnReceiveData : TReceiveDataEvent;
FOnRequestHangup : TNotifyEvent;
FParity : TParity;
FStopBits : TStopBits;
hCloseEvent : THandle;
hCommFile : THandle;
ReadThread : TReadThread;
WriteThread : TWriteThread;| Constructors |
constructor Create( AOwner: TComponent );Public declarations
used as a check if file is assigned (******************************************************************************) TVSSComm32 PUBLIC METHODS (
| Functions |
destructor Destroy;FCommsLogFileName := '';
function StartComm: Boolean;FUNCTION: StartComm // PURPOSE: Starts communications over the comm port. // PARAMETERS: hNewCommFile - This is the COMM File handle to communicate with. This handle is obtained from TAPI. // RETURN VALUE: TRUE if able to setup the communications. // COMMENTS: // StartComm makes sure there isn't communication in progress already, creates a Comm file, and creates the read and write threads. It also configures the hNewCommFile for the appropriate COMM settings. // If StartComm fails for any reason, it's up to the calling application to close the Comm file handle. // //
procedure StopComm;TVSSComm32.StartComm} // // FUNCTION: StopComm // // PURPOSE: Stop and end all communication threads. // // PARAMETERS: // none // // RETURN VALUE: // none // // COMMENTS: // // Tries to gracefully signal all communication threads to // close, but terminates them if it has to. // //
function WriteCommData( pDataToWrite: PChar; dwSizeofDataToWrite: Word ): Boolean;TVSSComm32.StopComm} // // FUNCTION: WriteCommData(PChar, Word) // // PURPOSE: Send a String to the Write Thread to be written to the Comm. // // PARAMETERS: // pszStringToWrite - String to Write to Comm port. // nSizeofStringToWrite - length of pszStringToWrite. // // RETURN VALUE: // Returns TRUE if the PostMessage is successful. // Returns FALSE if PostMessage fails or Write thread doesn't exist. // // COMMENTS: // // This is a wrapper function so that other modules don't care that // Comm writing is done via PostMessage to a Write thread. Note that // using PostMessage speeds up response to the UI (very little delay to // 'write' a string) and provides a natural buffer if the comm is slow // (ie: the messages just pile up in the message queue). // // Note that it is assumed that pszStringToWrite is allocated with // LocalAlloc, and that if WriteCommData succeeds, its the job of the // Write thread to LocalFree it. If WriteCommData fails, then its // the job of the calling function to free the string. // //
procedure CloseReadThread;Protected declarations
TVSSComm32.WriteCommData} (******************************************************************************) // TVSSComm32 PROTECTED METHODS (******************************************************************************) // // FUNCTION: CloseReadThread // // PURPOSE: Close the Read Thread. // // PARAMETERS: // none // // RETURN VALUE: // none // // COMMENTS: // // Closes the Read thread by signaling the CloseEvent. // Purges any outstanding reads on the comm port. // // Note that terminating a thread leaks memory. // Besides the normal leak incurred, there is an event object // that doesn't get closed. This isn't worth worrying about // since it shouldn't happen anyway. // //
procedure CloseWriteThread;TVSSComm32.CloseReadThread} // // FUNCTION: CloseWriteThread // // PURPOSE: Closes the Write Thread. // // PARAMETERS: // none // // RETURN VALUE: // none // // COMMENTS: // // Closes the write thread by signaling the CloseEvent. // Purges any outstanding writes on the comm port. // // Note that terminating a thread leaks memory. // Besides the normal leak incurred, there is an event object // that doesn't get closed. This isn't worth worrying about // since it shouldn't happen anyway. // //
procedure ReceiveData( Buffer: PChar; BufferLength: Word );TVSSComm32.CloseWriteThread
procedure RequestHangup;
procedure CommWndProc( var msg: TMessage );FCommsLogFileName := LogFileName;
function GetReceiveDataEvent: TReceiveDataEvent;
function GetRequestHangupEvent: TNotifyEvent;
procedure SetCommsLogFileName( LogFileName: string );*****************************************************************************) // TVSSComm32 PRIVATE METHODS (
procedure SetReceiveDataEvent( AReceiveDataEvent: TReceiveDataEvent );
procedure SetRequestHangupEvent( ARequestHangupEvent: TNotifyEvent );| Properties |
property BaudRate : TBaudRate
property CommPort : TcommportPublished declarations
property DataBits : TDatabits
property Parity : TParity
property StopBits : TStopBits| Events |
event OnReceiveData : TReceiveDataEventproperty CommPort: string read FCommPort write FCommPort;} { property CommsLogFileName: string read FCommsLogFileName write SetCommsLogFileName;
event OnRequestHangup : TNotifyEvent| Variables |
FBaudRate : TBaudrate;
FCommPort : TCommport;
FCommsLogFileName : TCommport;
FDataBits : TDatabits;
FHWnd : THandle;
FOnReceiveData : TReceiveDataEvent;
FOnRequestHangup : TNotifyEvent;
FParity : TParity;
FStopBits : TStopBits;
hCloseEvent : THandle;
hCommFile : THandle;
ReadThread : TReadThread;Private declarations
WriteThread : TWriteThread;