1 configuring serialport timeouts, 2 configuring common serialport properties – Casio Naurtech CETerm Ver.5.5 Scripting Guide User Manual

Page 114

Advertising
background image

N

AURTECH

W

EB

B

ROWSER AND

T

ERMINAL

E

MULATION FOR

W

INDOWS

CE

AND

W

INDOWS

M

OBILE




CETerm Scripting Guide

Page 114


5.8.3.1 Configuring SerialPort Timeouts


When reading from the serial port, the default timeouts prevent blocking of the
read operation. Most reads should be performed in response to an
EV_RXCHAR event indicating that data is available from the attached device.
Often however, some timeout is needed to allow a complete data message to be
received. In these cases, we recommend a small
ReadTotalTimeoutConstant and perhaps a small
ReadTotalTimeoutMultiplier. Beware of a read request with a large
maxCount parameter because this can result in a large total timeout if
ReadTotalTimeoutMultiplier is non-zero.

var portIndex = 5;
var sp = Device.SerialPort( portIndex );
sp.ReadTotalTimeoutConstant = 100;
sp.ReadTotalTimeoutMultiplier = 0;
sp.ReadIntervalTimeout = 0;


You should review the Microsoft documentation mentioned above and may need
to experiment with timeouts to configure the behavior that works best with your
peripheral and software architecture. For example, if you do not seem to get a
“complete message” during your read, you may need a larger timeout or may
need to save the partial data and perform another read at a later time.

When writing to the serial port, the default timeouts wait for all the data to be
written. In most cases this will be instantaneous because the data are placed in
the output buffer. If flow-control is enabled and transmission is blocked, the
buffer may fill and the write may block. You should use write timeouts if blocking
is possible so that CETerm is not fully blocked waiting for the write to complete.

var portIndex = 5;
var sp = Device.SerialPort( portIndex );
sp.WriteTotalTimeoutConstant = 100;
sp.WriteTotalTimeoutMultiplier = 10;

5.8.3.2 Configuring Common SerialPort Properties

In addition to the timeout properties discussed above, there are a couple of other
properties which must often be configured. These include the baud rate, flow
control and the EventMask. Here is a sample function used to configure and
open a port.

function OpenPort( portIndex )
{

Advertising
This manual is related to the following products: