Read() - Multitech MultiConnect MTPCIE-H5 Developer's Manual

Hide thumbs Also See for MultiConnect MTPCIE-H5:
Table of Contents

Advertisement

USING LINUX WITH H5 DEVICES
pathname – file name with its own path.
flags – is an int specifying file opening mode: is one of O_RDONLY, O_WRONLY or O_RDWR which request opening
the file read-only, write-only or read/write, respectively.
Returns:
The new file descriptor fildes if successful, -1 otherwise.
Example
Open the /dev/ttyACM0.
int fd; // file descriptor for the /dev/ttyACM0 entry
if((fd = open("/dev/ttyACM0", O_RDONLY) < 0)
{
/* Error Management Routine */
} else {
/* ttyACM0 Device Opened */
}

read()

The read() function reads nbyte bytes from the file associated with the open file descriptor, fildes, and copies them
in the buffer that is pointed to by buf.
Header File
unistd.h
Prototype:
ssize_t read(int fildes, void *buf, size_t nbyte)
Parameters:
fildes - file descriptor
buf - destination buffer pointer
nbyte - number of bytes that read() attempts to read
Returns:
The number of bytes actually read if the operation is completed successfully, otherwise it is -1.
Example
Read sizeof(read_buff) bytes from the file associated with fd and stores them into read_buff.
char read_buff[BUFF_LEN];
if(read(fd, read_buff, sizeof(read_buff)) < 0)
{
/* Error Management Routine */
} else {
/* Value Read */
}
TM
MultiConnect
PCIe MTPCIE-H5/MTPCIE-BW Developer Guide
71

Advertisement

Table of Contents
loading

This manual is also suitable for:

Multiconnect mtpcie-bw

Table of Contents