at75c1222 ETC-unknow, at75c1222 Datasheet - Page 21

no-image

at75c1222

Manufacturer Part Number
at75c1222
Description
Manufacturer
ETC-unknow
Datasheet
Description
Return Values
Example
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.729 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, therefore their contents are not to be relied upon after an error.
This code checks if a G.729 frame has been received. The time-out is 20 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 = 20000;
retval = select(df+1, &rfds, NULL, NULL, &tv); /* df supposed to be a file
descriptor related to /dev/g729encoder0 */
if (retval > 0)
else
printf("G.729 frame received.\n");
printf("G.729 frame not received within 20 ms.\n");
AT75C1222
21

Related parts for at75c1222