From a04e6effed0b81ec7495df2a1448484645b20cc5 Mon Sep 17 00:00:00 2001 From: laforge Date: Fri, 12 Jan 2007 23:57:33 +0000 Subject: - use talloc (of samba project) to debug memory allocations and simplify code - introduce new ucmd_alloc() function - add DTMF support to gsmd, libgsmd and gsmd-util - fix crash of libgsmd when events don't have handlers registered - implement call progress for TI modem - split modem init string in separate commands to fit our parser git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@544 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/gsmd/gsmd.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/gsmd/gsmd.c') diff --git a/src/gsmd/gsmd.c b/src/gsmd/gsmd.c index c56e74c..a16e6b5 100644 --- a/src/gsmd/gsmd.c +++ b/src/gsmd/gsmd.c @@ -5,6 +5,7 @@ #include #include #include +#include #define _GNU_SOURCE #include @@ -19,6 +20,7 @@ #include #include #include +#include static int gsmd_test_atcb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { @@ -40,8 +42,22 @@ int gsmd_initsettings(struct gsmd *gsmd) { int rc; + /* echo on, verbose */ rc |= gsmd_simplecmd(gsmd, "ATE0V1"); - rc |= gsmd_simplecmd(gsmd, "AT+CRC=1;+CREG=2;+CMEE=1;+CLIP=1;+COLP=1;+CTZR=1;+CFUN=1"); + /* use +CRING instead of RING */ + rc |= gsmd_simplecmd(gsmd, "AT+CRC=1"); + /* enable +CREG: unsolicited response if registration status changes */ + rc |= gsmd_simplecmd(gsmd, "AT+CREG=2"); + /* use +CME ERROR: instead of ERROR */ + rc |= gsmd_simplecmd(gsmd, "AT+CMEE=1"); + /* use +CLIP: to indicate CLIP */ + rc |= gsmd_simplecmd(gsmd, "AT+CLIP=1"); + /* use +COLP: to indicate COLP */ + rc |= gsmd_simplecmd(gsmd, "AT+COLP=1"); + /* use +CTZR: to report time zone changes */ + rc |= gsmd_simplecmd(gsmd, "AT+CTZR=1"); + /* power on the phone */ + rc |= gsmd_simplecmd(gsmd, "AT+CFUN=1"); if (gsmd->vendorpl && gsmd->vendorpl->initsettings) return gsmd->vendorpl->initsettings(gsmd); @@ -108,6 +124,7 @@ static struct option opts[] = { { "device", 1, NULL, 'p' }, { "speed", 1, NULL, 's' }, { "logfile", 1, NULL, 'l' }, + { "leak-report", 0, NULL, 'L' }, { 0, 0, 0, 0 } }; @@ -125,6 +142,20 @@ static void print_help(void) ); } +static void sig_handler(int signr) +{ + switch (signr) { + case SIGTERM: + case SIGINT: + talloc_report_full(gsmd_tallocs, stderr); + exit(0); + break; + case SIGUSR1: + talloc_report_full(gsmd_tallocs, stderr); + break; + } +} + int main(int argc, char **argv) { int fd, argch; @@ -134,12 +165,22 @@ int main(int argc, char **argv) char *device = "/dev/ttyUSB0"; char *logfile = "syslog"; + signal(SIGTERM, sig_handler); + signal(SIGINT, sig_handler); + signal(SIGSEGV, sig_handler); + signal(SIGUSR1, sig_handler); + + gsmd_tallocs = talloc_named_const(NULL, 1, "GSMD"); + /*FIXME: parse commandline, set daemonize, device, ... */ - while ((argch = getopt_long(argc, argv, "Vdhp:s:l:", opts, NULL)) != -1) { + while ((argch = getopt_long(argc, argv, "VLdhp:s:l:", opts, NULL)) != -1) { switch (argch) { case 'V': /* FIXME */ break; + case 'L': + talloc_enable_leak_report_full(); + break; case 'd': daemonize = 1; break; -- cgit v1.2.3