summaryrefslogtreecommitdiff
path: root/src/gsmd/gsmd.c
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-01-12 23:57:33 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-01-12 23:57:33 +0000
commita04e6effed0b81ec7495df2a1448484645b20cc5 (patch)
tree6292af769d08022e68cd183358ccc78c6a27238c /src/gsmd/gsmd.c
parent496d202f517dbecc1be4e1afc6782c0e3dc48373 (diff)
- 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
Diffstat (limited to 'src/gsmd/gsmd.c')
-rw-r--r--src/gsmd/gsmd.c45
1 files changed, 43 insertions, 2 deletions
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 <errno.h>
#include <fcntl.h>
#include <termios.h>
+#include <signal.h>
#define _GNU_SOURCE
#include <getopt.h>
@@ -19,6 +20,7 @@
#include <gsmd/select.h>
#include <gsmd/usock.h>
#include <gsmd/vendorplugin.h>
+#include <gsmd/talloc.h>
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;
personal git repositories of Harald Welte. Your mileage may vary