Printable versions
This Page
All Pages
PDF

Index

Class
Port

Properties
List
Enabled
BaudRate
ComPort

Methods
Read
Write
Purge
Dispose

ByteArrayToString
StringToByteArray

Events
OnRead
OnWritten
OnDSR
OnCTS
OnRI
OnDCD
OnForceClose

More Properties
Parity
StopBits
ByteSize
StartTrigger
EndTrigger
BufferSize
Timeout

DSR
CTS
RI
DCD

Handshake
RTS
DTR
Break
InfraRed

MultiThreading
Parent
NoEvents

Port.OnRead SerialTools v1.00 and later

Event that is raised when data is received on the serial port.

OnRead is called when data has been received on the serial port.

Timeout. If Port.Timeout is set to a value different from 0 (default) OnRead is called with null (C#) or Nothing (VB.NET) as argument if no data has been received during the time intervall specified by Timeout. Timeout is specified in miliseconds.

Buffer size. Use Port.BufferSize to specify how many bytes should be received before OnRead is called (default 0 - disabled).

Simple parsing. If Port.EndTrigger is set to a value different from null (default). OnRead will be called when the specified string is found in the input from the serial port. This is very usefull if you got data with a known format coming in to the serial port. If EndTrigger is used BufferSize is ignored.
If Port.StartTrigger is set to a value different from null (default). All data is ignored until the specified string is found in the serial port input. If both StartTrigger and EndTrigger is used only data between (including the triggers themself) the triggers will be passed on to OnRead. If EndTrigger is null, OnRead will be called when BufferSize bytes has been received. If EndTrigger is null StartTrigger must be "retriggered" each time OnRead is called or else OnRead will be called with data each time the input buffer is full.

OnRead is called with a string as argument. To convert this string to binary data see Port.StringToByteArray and to convert from binary data to a string see Port.ByteArrayToString

See also Port.OnForceClose for more info on how to handle Bluetooth interruption.


See also Port.Enabled and Port.Read.

Syntax
obj_OnRead ( Value )

Part Type Description
obj   Event source.
Value string Data read from the serial port.



Compact Framework
© 2016 Franson Technology AB, All rights reserved, Contact | | Affiliate | Login