[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

eia - serial communication control (Windows 95/NT)

bind -a '#t' dir
dir/eia0
dir/eia0ctl
dir/eia1
dir/eia1ctl
dir/eia2
dir/eia2ctl
dir/eia3
dir/eia3ctl

Description

The serial line device serves a one-level directory that gives access to the serial ports. The device creates four pairs of files numbered 0 through 3 in the directory specified in path. Each file pair consists of a stream data file (e.g., eia0) and a stream control file (e.g., eia0ctl) associated with the port.

The data file can be read and written to use that port. Reads will block until at least one character is available.

The ctl file can be used to push stream modules onto the port . One can also write one of the following commands to a ctl file:
b n Set the baud rate to n.
d n Set DTR if n is non-zero; else clear it.
k n Send a break lasting n milliseconds.
r n Set RTS if n is non-zero; else clear it.
m n Obey modem CTS signal if n is non-zero; else clear it.
p c Set parity to odd if c is o, to even if c is e; else set no parity.
s n Set number of stop bits to n. Legal values are 1 or 2.
l n Set number of bits per byte to n. Legal values are 5, 6, 7, or 8.

Example

The following code fragment opens a serial port, and sets the speed to 9600 bps.

init(ctxt: ref Draw->Context, argv: list of string)
{
	sys = load Sys Sys->PATH;
	if (len argv != 2) {
		sys->print("Usage: %s {serial_device_path}\n",hd 
argv);
		return;
	}
		path := hd tl argv;
		data := sys->open(path, Sys->ORDWR);
		if (data == nil) {
			sys->print("unable to open %s: %r\n",path);
			return;
		}
		ctl := sys->open(path+"ctl",Sys->ORDWR);
		if (ctl == nil) {
			sys->print("unable to open %s: %r\n",path+"ctl");
			return;
		}
# set the speed to 9600 bps
		bps := array of byte "b 9600";
		if(sys->write(ctl,bps,len bps) == -1) {
			sys->print("change speed failed: %r\n");
			return;
		}
# read and write to the data fd reads and writes to the
# serial port
} 

Files

eia0
eia0ctl
eia1
eia1ctl
eia2
eia2ctl
eia3
eia3ctl


[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.