12.07.2015 Views

spec - Local Sector 7 web page

spec - Local Sector 7 web page

spec - Local Sector 7 web page

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

RS-232 Serial InterfacesSerial functions are available on all the systems <strong>spec</strong> supports. The device nodes areselected in the config file, where they are assigned <strong>spec</strong> device numbers startingfrom zero that are used in the functions below.ser_get(dev_num) — Reads a string of characters, up to and including a newline,from serial device dev_num and returns the string so read. The routine will notreturn until the read is satisfied. Use ser_get(dev_num, 0) to read up to anewline with a timeout.ser_get(dev_num, n) — If n is greater than 0, this routine reads n bytes from theserial device dev_num and returns the string so obtained. If n is zero, the routinereads characters up to and including a newline. If the read is not satisfiedwithin two seconds, the routine returns the null string.ser_get(dev_num, mode) — If mode is the string "byte" , reads and returns oneunsigned binary byte. The following modes read short or long integers andwork the same on both big-endian and little-endian platforms. If mode is thestring "int2" reads two binary bytes and returns the short integer so formed.If mode is the string "int4" reads four binary bytes and returns the long integerso formed. By default, the incoming data is treated as big endian. Iftheincoming data is little endian, use "int2_swap" or "int4_swap" . Ifthe devicereturns less than the required number of bytes, the characters so read are discarded,and ser_get() returns the null string. The tty mode for the deviceneeds to be selected as raw in the config file for this command to work properly.ser_put(dev_num, string) — Writes the string string to the serial device havingdevice number dev_num ,asset in the config file . Returns the number of byteswritten.<strong>spec</strong> uses the standard tty(4) driver interface on the UNIX systems. Serial line characteristicsare set according to the device modes set in the config file. Availablemodes are either raw or cooked, with cooked mode also having noflow, igncr (no-op onnon-System V) and evenp or oddp options. The baud rate for the serial line is alsotaken from the config file.ser_par(dev_num, par [, val ]) — Sets parameters for the serial device dev_num .Values for par include:"timeout" — Sets or returns the current value for the timeout for reads fromcooked serial lines. The units are seconds. If val is zero, timeouts aredisabled. If val is less than zero, the default timeout of two seconds isset.INTERIM WORK-IN-PROGRESS (8/16/01) NOT FOR GENERAL DISTRIBUTION REFERENCE MANUAL 97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!