at75c1222 ETC-unknow, at75c1222 Datasheet - Page 29

no-image

at75c1222

Manufacturer Part Number
at75c1222
Description
Manufacturer
ETC-unknow
Datasheet
Description
Return Values
Example
IOCTL Method
2664A–INTAP–07/02
Select() waits for a number of file descriptors to change status. The main usage of
select() is to check if data (G.711 frames) are available for reading without having to
actually read the data. In particular, when blocking operation is selected, it advises if a
read access will block or not. This is similar to a polling operation.
Three independent sets of descriptors are watched:
1. Those listed in “readfds” will be watched to see if characters become available
2. Those in “writefds” will be watched to see if a write will not block (not used there)
3. Those in “exceptfds” will be watched for exceptions (not used there).
On exit, the sets are modified in place to indicate which descriptors actually changed
status.
Four macros are provided to manipulate the sets:
“n” is the highest-numbered descriptor in any of the three sets, plus 1.
“timeout” is an upper limit on the amount of time elapsed before select returns. It may
be zero, causing select to return immediately. If timeout is NULL (no timeout),
select can block indefinitely.
On success, select returns the number of descriptors contained in the descriptor sets,
which may be zero if the timeout expires before an event occurs. On error, -1 is
returned, and errno is set appropriately, the sets and timeout become undefined, there-
fore their contents are not to be relied upon after an error.
This code checks if a G.711 frame has been received. The time-out is 5 ms.
#include <unistd.h>
int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
struct timeval *timeout);
for reading.
FD_ZERO will clear a set.
FD_SET and FD_CLR add or remove a given descriptor from a set.
FD_ISSET tests to see if a descriptor is part of the set. This is useful after select
returns.
fd_set rfds;
struct timeval tv;
int retval;
/* initialize file descriptor list */
FD_ZERO(&rfds);
FD_SET(df, &rfds);
/* define delay */
tv.tv_sec = 0;
tv.tv_usec = 5000;
retval = select(df+1, &rfds, NULL, NULL, &tv); /* df supposed to be a file
descriptor related to /dev/g711encoder0 */
if (retval > 0)
else
printf("G.711 frame received.\n");
printf("G.711 frame not received within 5 ms.\n");
AT75C1222
29

Related parts for at75c1222