Example - HP 9000 Series 300 Tutorials Manual

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

Although read and write require the number of bytes to be transferred as their
third argument, other characteristics (discussed later) of the device associated
with the interface file eid can end the transfer before this number is reached.
Example
Assume you have already created an auto-addressed special file, /dev/hpib_dev
for an HP-IB device. Your program must first open /dev/hpib_dev for reading
and writing:
int
eid;
eid
=
open (li/dev/hpib_dev
lI
,
O_RDWR);
To place data on the bus, use write:
write(eid, IIThis is a test", 14);
In this example, 14 characters are sent through eid. The literal string
expression This is a test is placed in a data storage area by the compiler
for later handling by the call to write. On output, if the number of characters
requested does not match the length of the data storage space, the message is
truncated (if the byte count is smaller than the data block) or extended into
the next data block assigned by the compiler (if the byte count is larger than
the data block).
To receive 10 bytes of data from the bus and place them in
buffer,
use:
char buffer [10] ;
read(eid, buffer, 10);
In this code segment, the
read
routine will attempt to read up to 10 bytes of
data from the interface and place it in
buffer.
General-Purpose Routines
2-9

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents