Defining initialization data – QuickLabel NiceWatch User Manual

Page 62

Advertising
background image

Working with Triggers

62

NiceWatch User Guide

Defining Initialization Data

Initialization data is set of characters that need to be sent to the serial device in order to
activate it and make it ready to send data to the PC computer. There are two methods how
the initialization data is defined:

1. If you have a dummy serial device that is activated by a certain combination of

characters, you can type in such characters. Click on the small arrow button on the
right to display list of all available special characters.

2. If your serial device can report its current working state back to the computer, you

can use Visual Basic script and communicate with the serial device. You can
program your script code to handle bidirectional communication to the serial
device.

When you are using bidirectional communication, the ordinary scenario is to send some
initialization string to the device and then listen for a reply. If the reply is what you are
expecting it to be, the initialization was successful. If the reply is not valid, the
initialization failed, an error in logged the system log, but trigger will still be checked.

Two special functions are available in Visual Basic script for data sending and receiving
to/from serial port.

Comport.Send

ComPort.Send(Data: string, Length: integer): integer

The ComPort class function Send has two parameters.
The first parameter contains the data that will be sent to
the serial port. The second parameter must contain the
length of the sent data. Function return integer values:

1 - if writing to serial port was successful and

0 - if error occurs.

Comport.Receive

ComPort.Receive(TimeOut: integer): string

The ComPort class function Receive has parameter
TimeOut. This parameter contains the time (in seconds),
how long the function will wait for the incoming data.

The function returns data if it is available in the specified
time frame. If the data is not received, the function
returns empty string.

The built-in function InitData must be part of the script code, but you are free to modify
it. Use the functions Comport.Send and Comport.Receive to exchange data with the serial
device and then decide if the initialization was successful or not.

Then set the output of the InitData function accordingly to let the application know the
result of the initialization sequence.

Advertising