Need to read data from dahdi card e1 port with a third party code.
here is an example of code that i tried but it does not work i need your help please.
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
#include <dahdi/user.h>
#include <dahdi/fasthdlc.h>
int main()
{
int fd=0,ret=0;
char buf[128]="";
fd=open("/dev/dahdi/channel",O_RDONLY);
if (fd) {
printf("open on /dev/dahdi/channel the descriptor is %d \n",fd);
for(;;) {
ret = read(fd, buf, sizeof(buf));
if(ret == 0) {
/* EOF. */
printf( "Error EOF reading dahdi device , errno=%d: %s.\n", errno, strerror(errno));
break;
} else if(ret < 0) {
if(errno == EAGAIN || errno == EWOULDBLOCK) {
/* Done until next successful poll(). /
printf( “Error EAGAIN reading dahdi device , errno=%d: %s.\n”, errno, strerror(errno));
break;
} else if(errno == EINTR) {
/ Try again. /
printf( “Error EINTR reading dahdi device , errno=%d: %s.\n”, errno, strerror(errno));
} else if(errno == ELAST) {
printf( “Error ELAST reading dahdi device , errno=%d: %s.\n”, errno, strerror(errno));
} else {
/ Some unexpected error. /
printf( “Unexpected Error reading dahdi device , errno=%d: %s.\n”, errno, strerror(errno));
break;
}
} else {
/ Got some data. */
printf( “merci reading dahdi device %s.\n”, buf);
break
}
}
}
else {
printf(“open fail on /dev/dahdi/channel\n”);
}
exit(0);
}
but this code return
open on /dev/dahdi/channel the descriptor is 3
Unexpected Error reading dahdi device , errno=38: Function not implemented.