hp-support-head-portlet

Actions
Loading...

Welcome to HP Customer Support

hp-contact-secondary-navigation-portlet

Actions
Loading...

hp-share-print-widget-portlet

Actions
Loading...

hp-concentra-wrapper-portlet

Actions
Loading...

HP Pen Plotters - The Basic [OPEN "Com...] Statement Details

OPEN "COM... Statement
Purpose:
Opens a communications file.
Valid only with Asynchronous Communications Adapter.
Format:
OPEN "COMn:[speed) [,parity] {,data] [,stop] [,RS] [,CS[n]] [,DS[n]] [,CD[n][,LF] [,PE]"
AS [#]filenum [LEN= number]
Remarks:
n
is 1 or 2, indicating the number of the Asynchronous Communications Adapter.
speed
is an integer constant specifying the transmit/receive bit rate in bits per second (bps). Valid speeds are 75, 110, 150, 300, 600, 1200, 1800, 2400, 4800. and 9600. The default is 300 bps.
parity
is a one-character constant specifying the parity for transmit and receive as follows:
S
SPACE: Parity bit always transmitted and received as a space (0 bit).
O
ODD: Odd transmit parity; odd receive parity checking.
M
MARK: Parity bit always transmitted and received as a mark (1 bit).
E
EVEN: Even transmit parity; even receive parity checking.
N
NONE: No transmit parity; no receive parity checking. The default is EVEN (E).
data
is an integer constant indicating the number of transmit/receive data bits. Valid values are: 5, 6, 7, or 8. The default is 7.
stop
is an integer constant indicating the number of stop bits. Valid values are 1 or 2. The default is two stop bits for 75 and 110 bps; one stop bit for all others. If you use 5 for data, a 2 here means 1-1/2 stop bits.
filenum
is an integer expression that evaluates to a valid file number. The number is then associated with the file for as long as it is open and is used by other communications I/O statements to refer to the file.
number
is the maximum number of bytes that can be read from the communication buffer when using GET or PUT. The default is 128 bytes.
OPEN "COM.. allocates a buffer for I/O in the same fashion as OPEN for disk files. It supports RS232 asynchronous communication with other computers and peripherals.
A communications device can be open to only one file number at a time.
The RS, CS, DS, CD, LF and PE options affect the line signals as follows:
RS
suppresses RTS (Request To Send)
CS[n]
controls CTS (Clear To Send)
DS[n]
controls DSR (Data Set Ready)
CD[n]
controls CD (Carrier Detect)
LF
sends a line feed following each carriage return
PE
enables parity checking
The CD (Carrier Detect) is also known as the RLSD (Received Line Signal Detect).
  note:
The speed, parity, data, and stop parameters are positional, but RS, CS, DS, CD, LF, and PE are not.
The RTS (Request To Send) line is turned on when executing an OPEN "COM.. statement unless the RS option is included.
The n argument in the CS, DS, and CD options specifies the number of milliseconds to wait for the signal before returning a Device time-out error. n can range from 0 to 65535. If n is omitted or is equal to zero, then the line status is not checked at all.
The defaults are CS1000, DS1000, and CD0. If RS was specified, CS0 is the default.
That is, normally I/O statements to a communications file fail if the CTS (Clear To Send) or DSR (Data Set Ready) signals are off. The system waits 1 second before returning a Device time-out. The CS and DS options allow you to ignore these lines or to specify the amount of time to wait before the time-out.
Normally Carrier Detect (CD or RLSD) is ignored when an OPEN "COM... statement is executed. The CD option allows you to test this line by including the n parameter, in the same way as CS and DS. If n is omitted or is equal to zero, then Carrier Detect is not checked at all (which is the same as omitting the CD option).
The LF parameter is intended for those using communications files to print to a serial line printer. When specifying LF, a line feed character (hex 0A) is automatically sent after each carriage return character (hex 0C). (This includes the carriage return sent as a result of the width setting.) INPUT # and LINE INPUT # when used to read from a communications file that was opened with the LF option, stop when they see a carriage return. The line feed is always ignored.
The PE option enables parity checking. The default is no parity checking. The PE option causes a Device I/O error on parity errors and turns on the high order bit for 7 or less data bits. The PE option does not affect framing and overrun errors. These errors always turn on the high order bit and cause a Device I/O error.
Any coding errors within the string expression starting with speed result in a Bad file name error. No indication is given as to which parameter is in error.
If specifying 8 data bits, specify parity N. BASIC uses all 8 bits in a byte to store numbers, so if transmitting or receiving numeric data (for example, by using PUT), specify 8 data bits. (This is not necessary if sending numeric data as text.)
Examples:
In this example, file 1 is opened for communication with all defaults. The speed is 300 bps with even parity. There are 7 data bits and 1 stop bit.
10 OPEN "COM1:" AS #1
In this example, file 2 is opened for asynchronous I/O at 1200; no parity is to be produced or checked; 8-bit bytes are sent and received; and 1 stop bit is transmitted.
10 OPEN 'COM2:1200,N,S" AS #1
This example opens COM1: at 9600 bps with no parity and 8 data bits. CTS, DSR, and CD are not checked.
10 OPEN COM1:9600,N,8,,CS,DS,CD" AS #1

hp-feedback-input-portlet

Actions
Loading...

hp-online-communities-portlet

Actions
Loading...

Ask the community!


Support Forum

Support Forum

Join the conversation! Find Solutions, ask questions, and share advice with other HP product owners. Visit now


hp-feedback-banner-portlet

Actions
Loading...

hp-country-locator-portlet

Actions
Loading...
Country: Flag Croatia

hp-detect-load-my-device-portlet

Actions
Loading...