dev_read

Gamma: Version 4.0
Prev |  | Next

# `dev_read`

`dev_read` -- is a modification of QNX 4 `dev_read`.

## Syntax

    dev_read (devno, nchars, min_chars, time, timeout)

## Arguments

`devno`

  A device id number returned from dev_open.

`nchars`

  The number of characters to read.

`min_chars`

  The minimum number of characters to read.

`time`

  The inter-character time limit.

`timeout`

  A timeout value for the entire read.

## Returns

A buffer containing the characters which were successfully returned from this call, or nil if an error occurred.

## Description

This function is a modification of the QNX 4 `dev_read` function. It is currently only available in QNX 4.

This function does not support the proxy and armed arguments to the C `dev_read` function. The characters read from the device are returned in a buffer rather than filled in to a buf argument as with the C function. Otherwise, the function of this call is identical to the QNX 4 `dev_read` function.

The min, time, and timeout values are used as follows:

Table 1. `dev_read` min, time, and timeout values

min | time | timeout | Description
--- | --- | --- | ---
0 | 0 | 0 | Returns immediately with as many bytes as are currently available (up to nchars bytes).
M | 0 | 0 | Return with up to nchars bytes only when at least M bytes are available.
0 | T | 0 | Return with up to nchars bytes when at least one byte is available, or T * 0.1 sec has expired.
M | T | 0 | Return with up to nchars bytes when either M bytes are available or at least one bytes has been received and the inter-byte time between any subsequently received characters exceeds T * 0.1 sec.
0 | 0 | t | Reserved.
M | 0 | t | Return with up to nchars bytes when t * 0.1 sec has expired, or M bytes are available.
0 | T | t | Reserved.
M | T | t | Return with up to nchars when M bytes are available, or t * 0.1 sec has expired and no characters are received, or at least one byte has been received and the inter-byte time between any subsequently received characters exceeds T * 0.1 sec.
0 | T | t | Reserved.
M | T | t | Return with up to nchars when M bytes are available, or t * 0.1 sec has expired and no characters are received, or at least one byte has been received and the inter-byte time between any subsequently received characters exceeds T * 0.1 sec.

If an error occurs the errno is set. The following error constants are relevant:

- EAGAIN The O_NONBLOCK flag is set on the devno.

- EBADF The devno argument is invalid or not open for read

- EINTR The function was interrupted by a signal

- EIO The process cannot read data from the devno

- ENOSYS This function is not supported for the given devno

## Example

        Gamma> id = dev_open("/dev/ser1",O_RDWR);
        4
        Gamma> x = dev_read(id,5,1,0,100);
        #[104 101 108 108 111]
        Gamma> buffer_to_string(x);
        "hello"

## See Also

`fd_open`, `fd_close`, `ser_setup`

Prev | Home | Next
QNX 4 | Up | `dev_setup`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.