⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modem.c

📁 VoiFax is a program that manage voice/data/fax modem in the same manner of vgetty and mgetty.VoiFax
💻 C
字号:
/*  modem, test program for voice *  Copyright (C) 2004  Simone Freddio & Andrea Emanuelli * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include "modemutil.h"#include <stdio.h>#include <stdlib.h>int handler_test(char *data);int handler_test(char *data){	printf("Handler called with data: '%s'\n", data);	return true;}int main(int argc, char **argv){	t_modem modem;	int cmdnum = 0;	char cmd[100];	char buf[1000];	int bytes;	if (argc != 2)	{		printf("Usage: modem [device]\n");		exit(0);	}	if (!modem_init(&modem, argv[1]))	{		fprintf(stderr, "Unable to init modem\n");		exit(1);	}	printf("Installing test handler on 1.\n");	modem_add_handler(&modem, handler_test, "1.", 2);		printf("Disabling echo\n");	modem_sendcmd(&modem, "ATE0");	modem_receiveresp(&modem, buf, sizeof(buf), false); /* discard response */	for (cmdnum = 0; cmdnum < 10; cmdnum++)	{		sprintf(cmd, "ATI%d", cmdnum);		modem_sendcmd(&modem, cmd);		printf("Cmd: %-10s => ", cmd);		bytes = modem_receiveresp(&modem, buf, sizeof(buf), false);		printf("Read (%d): %s\n", bytes, buf);	}	printf("Verifica comando AT tramite chat: ");	printf(modem_chat(&modem, "AT", "OK") ? "ok\n" : "error\n");			if (!modem_close(&modem))	{		fprintf(stderr, "Unable to close modem\n");		exit(1);	}		return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -