# Serial Port Events

The serial port has three events (script points), which are accessible by right-clicking the serial device in the Project Explorer.

Before invoking the On Data Received method, ensure that if you transmit ASCI text, all data sent and received must be ASCI text and both sender and receiver must be using the same encoding algorithm. Sending or receiving non-ASCI text may result in data loss and unexpected results.

Serial Port Events | Description
--- | ---
On Data Received () | Will be raised whenever new data is received by the serial port device. The event argument contains the received data as a string (using UTF-8 encoding). Note: See the Microsoft Developer Network Help for more information.
On Error Received () | Will be raised whenever new data is received by the serial port device. The event argument contains the received data as a string (using UTF-8 encoding). Note: See the Microsoft Developer Network Help for more information.
On Pin Changed () | Will be raised whenever a non-data signal event has occurred on the port represented by the serial device. Note: See the Microsoft Developer Network Help for more information. This script point does not correspond to the Cognex Designer implementation of input or output pins on Task Blocks.