cdholding image

comm32 home
comm32 download
comm32 forum
buy comm32

EvtCharEnable

Sets or Retrieves the status of the EvtCharEnable property. Enable or Disable EvtChar OnComm events.
Used in conjunction with the EvtChar property.

Available at Design time and Runtime.

Only available using the Comm32 ocx. Not supported by MSComm

         Syntax object.EvtCharEnable = value
     
  object Name of the communications control.
  value A boolean expression. True or False
     
  Examples  
    object.EvtChar = 3
object.EvtCharEnable = True
'// Set the value (Look for the ETX char)
       
   

if object.EvtCharEnable = True then
      MsgBox("It's enabled")
   Else
      MsgBox("It's NOT enabled")
End If

'// Retrieves the value
       

Remarks:

MSComm32 is old and therefore still ONLY detects the standard Win3/Dos EOF char (Ascii char 26). Modern file systems do not require or use the EOF character to indicate the End of File but some communications protocols may use a special character as a way to indicate the Start or End of a message.

The Ascii table has a number of 'Start' and 'End' codes such as STX ( 2 ), ETX ( 3 ) and EOT ( 4 ) as well as the old EOF. Comm32 therefore allows you to use any ascii character in the range 0 to 255

The EvtChar property is used in conjuction with the EvtCharEnable property. If enabled this property will cause an OnComm event to be triggered when the EvtChar is received by the com port hardware. These properties are similar to the EOFChar/EOFEnable properties but an evtChar OnComm event is generated independent of the Input property. The evtChar event is triggered as soon as the evtChar is detected in the incoming data stream. Using this property you could set RThreshold=0 so that no evReceive events are ever triggered and simply wait for the evtChar event to indicate that the evtChar has arrived and is waiting to be read from the buffer.


Example Lets assume we're receiving an unknown amount of data. We don't know how much data but in this example we do know that it'll be terminated by the EOF character. Maybe we're running at a very high baud rate but don't want to do any processing at all untill we know that ALL the data is waiting in the receive buffer. By setting RThreshold=0 we'll simply ignore data arriving at the com port until we get an evtChar OnComm event. Of course we also need to make sure the receive buffer is large enough to hold all the expected data.

'// InBufferSize = n         Make sure the receive buffer is big enough
'// InputLen = 0              we will read all available chars from the buffer when we call Input
'// RThreshold = 0          we DO NOT want OnComm events when data is received. We'll ignore it
'// EvtCharEnable = True     
'// EvtChar = 26          This is the default EOF character - we could detect any other character if we wanted to.

Private Sub Comm1_OnComm
       Select Case Comm1.CommEvent

              Case evReceive
                      '// This event never happens because we set RThreshold to zero
                      '// We're just ignoring the port

              Case evEvtChar
                      '// When this even occurs it means our End character arrived and we
                      '// can read the whole buffer in one go.
                      Text1.Text = Comm1.Input

       End Select
End Sub

 

For those users who understand the windows communications API - the EvtChar and EvtCharEnable properties are connected to the DCB EvtChar property and the RXFlag CommEvent.

 
Copyright (c) 2010 Axis Controls Ltd