2 setting the portname, 3 configuring serialport properties – Casio Naurtech CETerm Ver.5.5 Scripting Guide User Manual
Page 113

N
AURTECH
W
EB
B
ROWSER AND
T
ERMINAL
E
MULATION FOR
W
INDOWS
CE
AND
W
INDOWS
M
OBILE
CETerm Scripting Guide
Page 113
The SerialPort objects are obtained from the root Device object by
specifying the desired index:
var index = 0;
var sp = Device.SerialPort( index );
where sp is the reference to the SerialPort object. It is a good practice to use
a local variable to hold the reference inside a function when multiple port
operations must be performed.
5.8.2 Setting the PortName
By default, the SerialPort
objects correspond to the “COMx:” ports. If you
plan to control “COM1:” then you should use Device.SerialPort(1). In a
few cases, you may need to control a non-COM port, such as a virtual serial port
“BSP1:” for a Bluetooth device. In this case, you can use any SerialPort
object that is not being used for a COM port and set the PortName as needed.
var bluetoothPortIndex = 5;
var bluetoothPortName = "BSP1:";
var sp = Device.SerialPort( bluetoothPortIndex );
sp.PortName = bluetoothPortName;
It is also possible to specify COM ports with numbers greater than 9. Following
the Windows convention, prepend the string "$device\\" to the name. The double
backslash is required in JavaScript literal strings to specify a single backslash
character. For example, to open COM123, use the name "$device\\COM123:".
You must set the name before opening the port.
5.8.3 Configuring SerialPort Properties
All serial port settings can be controlled through SerialPort object properties.
Please refer to Section 3.15 for a complete list of properties. In general, you will
set needed properties before opening the port for the first time, but most
properties can be changed at any time.
Some properties are intuitive and control well known settings such as the baud
rate. Other properties, such as timeouts and “handshaking” can be more
complex and confusing. It can be helpful to search for information at
msdn.microsoft.com with the keywords “serial communications reference ce” to
learn additional details about Windows CE serial port control and behavior.