📄 dtmfascii.c
字号:
#include <stdio.h>#include <stdlib.h>#include <strings.h>#include <sys/ioctl.h>#include <sys/types.h>#include <sys/time.h>#include <signal.h>#include <unistd.h>#include <fcntl.h>#include <asm/errno.h>#include "ixjuser.h"void closeall(void);void getdata(int);int ixj1, size1, len, cmd;unsigned long write1;char buff1[480];int main(int argc, char *argv[]){ char pname1[80], buff1[480]; int cnt, oflags1, oflags2; sprintf(pname1, "/dev/ixj%s", argv[1]); ixj1 = open(pname1, O_RDWR); atexit(closeall); signal(SIGIO, &getdata); fcntl(ixj1, F_SETOWN, getpid()); oflags1 = fcntl(ixj1, F_GETFL); fcntl(ixj1, F_SETFL, oflags1 | FASYNC); getchar();}void closeall(void){ ioctl(ixj1, IXJCTL_DSP_IDLE); close(ixj1);}void getdata(int x){ fd_set rfds,wfds,efds; struct timeval tv; IXJ_EXCEPTION ixje; int nmax, size; char buf[480]; signal(SIGIO, &getdata);// nmax = (ixj1 > 0 ? ixj1+1 : 1); nmax = ixj1+1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); FD_SET(ixj1, &rfds); FD_SET(ixj1, &wfds); FD_SET(ixj1, &efds); tv.tv_sec = 0; tv.tv_usec = 300; select(nmax,&rfds, &wfds, &efds, &tv); if(FD_ISSET(ixj1,&rfds)) { } if(FD_ISSET(ixj1,&wfds)) { } if(FD_ISSET(ixj1,&efds)) { ixje.bytes = ioctl(ixj1, IXJCTL_EXCEPTION); if(ixje.bits.dtmf_ready) { // Deal with DTMF ioctl(ixj1, IXJCTL_CPT_STOP); printf("DTMF from card 0 = %c\n",ioctl(ixj1, IXJCTL_GET_DTMF_ASCII)); } if(ixje.bits.hookstate) { if(ioctl(ixj1, IXJCTL_HOOKSTATE)) { ioctl(ixj1, IXJCTL_DIALTONE); printf("Off Hook\n"); } else printf("On Hook\n"); } fflush(stdout); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -