EvtChar
Sets or Retrieves the character that will trigger an EvtChar OnComm Event. Used in conjunction with the EvtCharEnable property. (Similar to the EOF Event)
Available at Design time and Runtime. Can NOT be changed while the port is open.
Only available using the Comm32 ocx. Not supported by MSComm
 |
| |
Syntax |
object.EvtChar = value |
| |
|
|
| |
object |
Name of the communications control. |
| |
value |
A decimal expression. Ascii value 0 to 255 Default is 26 |
| |
|
|
| |
Examples |
|
| |
|
object.EvtChar = 3 |
'// Set the value (Look for the ETX char) |
| |
|
|
|
| |
|
n = object.EvtChar |
'// Retrieves the value |
| |
|
|
|
|
 |
Remarks:
MSComm32 is old and therefore still 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 such as EOT, ETX or EOF or any other ascii character as a way to indicate 'End of Message' or 'End of Transmision'.
The Ascii table has other 'End' codes such as ETX ( 3 ) and EOT ( 4 ) and Comm32 therefore allows you to use any ascii character.
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 EOT 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. We'll set RThreshold=0 to simply ignore data arriving at the com port until we get an evtChar OnComm event.
'// InBufferSize = n Make sure the receive buffer is big enough
'// InputLen = 0 we will read all available chars from the buffer whenwe call Input
'// RThreshold = 0 we DO NOT want OnComm events when data is received. We'll ignore it
'// EvtCharEnable = True
'// EvtChar = 4 In this sample we'll detect EOT
Private Sub Comm1_OnComm
Select Case Comm1.CommEvent
Case comEvReceive
'// This event never happens because we set RThreshold to zero
'// We're just ignoring the port
Case comEvEvtChar
'// When this event 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 |