SerComm Control

This Control has been tested with Win98SE, WinMe, Win2K(Prof./Server), WinXP(Home/Prof.).

Functions :

ClosePort()	Closes the opened Port , returns false if closed

InBufferCount()             Returns the Number of Bytes in the InBuffer  ( for Information only )

IsOpen()                            Returns the state of the Comm-Port  ( true / false )

OpenPort()                       Opens the Port , returns true if opened

Receive()                          Returns ( only ) the content of the InBuffer (Can‘t block the system)

Transmit()                          Transmit s the given string , returns number of transmitted bytes

Get/Set Properties :             ( true : 1  / false : 0 )

AddCR                                Adds Carriage Return ( 0x0d ,13) to the transmitted string  (true,false)

DtrLine                               DTR line High or Low  (true / false )    	[1] [2]

HandsRts                            RTS /CTS -Handshake  ( true / false )

HandsXon                         Xon/Xoff - Handshake    (true / false )

Port                                   Number of the Comm-Port   (Number )

RtsLine                               RTS line High or Low ( true / false )         	[1] [2]

Settings                               Port settings  (Baudrate, Parity, Bytesize, Stopbits)    (String)   /  Default : 9600,n,8,1

StripCR                               Strips Carriage Return from InString   ( true / false )

StripLF                                Strips Line Feed (0x0a,10) from InString   ( true / false )

StripNULL                        Strips NULL character ( 0x0,: 0) from InString ( true / false )

TimeOut                             TimeOut settings  (String)      / Default 0,0,10,10,0	[3]

Events :

To process a special event you have to mask  the returned DWORD‘s of one of the (overall) events

with it‘s identifier.

Example : EvModemStat returns ‚Changed‘. Changed   AND (& , binary !)   0x01 gives true (1) if InBuffer is full.

EvError 	        Fires if at least one of the following bits are set and returns DWORD Errors with:

     0x0010	CE_BREAK	The hardware detected a break condition.

     0x0008	CE_FRAME	The hardware detected a framing error.

     0x0400	CE_IOE	An I/O error occurred during communications with the device.

     0x8000	CE_MODE	The requested mode is not supported, or the hCommDev parameter is invalid.

                       	 If this bit set, this is the only valid error.

     0x0002	CE_OVERRUN	A character-buffer overrun has occurred. The next character is lost.

     0x0001	CE_RXOVER	An input buffer overflow has occurred. There is either no room in the input

                      	buffer, or a character was received after the end-of-file (EOF) character was received.

     0x0004	CE_RXPARITY	The hardware detected a parity error.

     0x0100	CE_TXFULL	The application tried to transmit a character, but the output buffer was full.

EvModemStat        Fires if at least one of the following bits has been changed and returns DWORD Changed (Status changed)

   and  DWORD Status  (with the current Status of all bits)

     0x0001             EV_IQU_OF	The Input Buffer is full	      ( size is set to 512 bytes, the device driver may change it )

     0x0002             EV_OQU_OF        The Output Buffer is full          (         "                   "                   "                      "                        )

     0x0010             MS_CTS_ON	The CTS (clear-to-send) signal is on.

     0x0020             MS_DSR_ON	The DSR (data-set-ready) signal is on.

     0x0040             MS_RING_ON	The ring indicator signal is on.

     0x0080             MS_RLSD_ON	The RLSD (receive-line-signal-detect) signal is on.

EvRXChar           Fires  if a new character arrived  the Input Buffer.

________________________________________________________________________________________________________________

1.	Some multimeters with serial interface requires DTR = High (+12 V) and RTS = Low (-12 V) to power

theire output opto couplers.

2.      Enabling the  RTS/CTS handshaking will set the RTS line to ‚toggle‘,

to set RTS line to High or Low requires to disable RTS/CTS handshaking.

3.           TimeOut

   	String           ReadIntervalTimeout, ReadTotalTimeoutMultiplier, ReadTotalTimeoutConstant,

WriteTotalTimeoutMultiplier, WriteTotalTimeoutConstant

               ReadIntervalTimeout	Specifies the maximum time, in milliseconds, allowed to elapse between the arrival

of two characters on the communications line. During a ReadFile operation, the

time period begins when the first character is received. If the interval between the arrival

of any two characters exceeds this amount, the ReadFile operation is completed and

any buffered data is returned. A value of zero indicates that interval timeouts are not used.

A value of 0xffffffff (MAXDWORD) , combined with zero values for both the

ReadTotalTimeoutConstant  and ReadTotalTimeoutMultiplier members, specifies that the

read operation is to return immediately with the characters that have already been 	                                              received, even if no characters have been received.

ReadTotalTimeoutMultiplier	Specifies the multiplier, in milliseconds, used to calculate the total timeout period for

read operations. For each read operation, this value is multiplied by the requested

number of bytes to read.

ReadTotalTimeoutConstant	Specifies the constant, in milliseconds, used to calculate the total timeout period for

 	read operations. For each read operation, this value is added to the product of the

ReadTotalTimeoutMultiplier member and the requested number of bytes.

A value of zero for both the ReadTotalTimeoutMultiplier and	                                                ReadTotalTimeoutConstant members indicates that total timeouts

are not used for read operations.

WriteTotalTimeoutMultiplier	Specifies the multiplier, in milliseconds, used to calculate the total timeout period f

or write operations. For each write operation, this value is multiplied by the number

of bytes 	to be written.

WriteTotalTimeoutConstant	Specifies the constant, in milliseconds, used to calculate the total timeout period for

 	write operations. For each write operation, this value is added to the product of the

WriteTotalTimeoutMultiplier member and the number of bytes to be written.

A value of zero for both the WriteTotalTimeoutMultiplier and

WriteTotalTimeoutConstant members indicates that total timeoutsare

not used for write operations.

-----------------------------------------------------------------------------------------------------------------------------

Dr.Detlef Kersten

Analysetechnik@t-online.de