ComOpen() generate/enh73.jpg


Open a serial device/port for communication.

Syntax

ComOpen([<cName>], [<cPort>], [<nBaud>], [<cParity>], [<nWord>], [<nStop>]) --> lOpened

Arguments

<cName> --> Optional name of the communications device to open.

generate/notepad1.gifIf you intend to open more than one serial communications device then you must specify a communications device name, e.g, "Weight Scale", "Cash Register", "Modem", "Serial Port 4", etc., in order to allow CAPITAL to distinguish between them.

<cPort> --> Port name/identifier. Consult the table below for the list of valid port names:

Valid Port Names

COM1

COM2

COM3

COM4

COM5

COM6

COM7

COM8

COM9

<nBaud> The port's baud rate. Consult the table below for the list of acceptable baud rates:

 

Baud Rates

110

300

600

1200

2400

4800

9600

14400

19200

38400

56000

128000

256000

<cParity> The parity setting of the port. Consult the table below for the list of valid parity codes:

Parity Code

Meaning

N

None

O

Odd

E

Even

M

Mark

S

Space

<nWord> The word size. Consult the table below for the list of valid word sizes:

Acceptable Word Sizes

5

6

7

8

<nStop> The number of stop bits. Consult the table below for the list of valid stop bits:

Acceptable Stop Bits

1

1.5

2

Returns

TRUE is returned if the communications port was successfully opened, otherwise FALSE is returned.

Description

Opens and optionally configures a serial port for communication.

You may also setup a communications port via a user interface dialog by calling the ComSetup() function.

All parameters are optional however it is strongly recommended that they all be specified when calling the ComOpen() function, unless you wish to set-up your parameters using ComSetup().

Example

* Set parameters directly

If ComOpen("My Port1", "COM1", 9600, "N", 8, 1)

   Echo("Com port successfully opened.")

Endif

* Use parameters based on ComSetup()

If ComOpen("My Port1")

   Echo("Com port successfully opened.")

Endif

____________________________

Related Topics:

Business Function List

ComClose()

ComSetup()

Weight Scale Interfacing Example: Digi D770



CAPITAL VISUAL BUILDER