summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modem-probe/77-probe-modem-capabilities.rules1
-rw-r--r--modem-probe/modem-probe.85
-rw-r--r--modem-probe/modem-probe.c32
3 files changed, 35 insertions, 3 deletions
diff --git a/modem-probe/77-probe-modem-capabilities.rules b/modem-probe/77-probe-modem-capabilities.rules
index 7efb56f..3b3c34e 100644
--- a/modem-probe/77-probe-modem-capabilities.rules
+++ b/modem-probe/77-probe-modem-capabilities.rules
@@ -5,6 +5,7 @@ SUBSYSTEM!="tty", GOTO="modem_probe_end"
KERNEL!="tty*", GOTO="modem_probe_end"
DRIVERS=="option|sierra|cdc_acm|hso", IMPORT{program}="modem-probe --export $tempnode"
+DRIVERS=="serial_cs", IMPORT{program}="modem-probe --delay 2000 --export $tempnode"
LABEL="modem_probe_end"
diff --git a/modem-probe/modem-probe.8 b/modem-probe/modem-probe.8
index 83956b7..8788ce2 100644
--- a/modem-probe/modem-probe.8
+++ b/modem-probe/modem-probe.8
@@ -3,7 +3,7 @@
modem-probe \- udev callout to identify Hayes-compatible modem capabilities
.SH SYNOPSIS
.BI modem-probe
-[\fI--export\fP] [\fI--verbose\fP] [\fI--quiet\fP] [\fI--log <file>\fP] \fI<devpath>\fP
+[\fI--export\fP] [\fI--delay <ms>\fP] [\fI--verbose\fP] [\fI--quiet\fP] [\fI--log <file>\fP] \fI<devpath>\fP
.SH "DESCRIPTION"
.B modem-probe
is normally called from a udev rule, to provide udev with the modem
@@ -18,6 +18,9 @@ The following commandline switches alter modem-probe's behavior:
.BI \-\-export
print values as environment keys
.TP
+.BI \-\-delay
+time to wait (in ms) before probing the port
+.TP
.BI \-\-verbose
print debugging information
.TP
diff --git a/modem-probe/modem-probe.c b/modem-probe/modem-probe.c
index 9494c3b..ddeb413 100644
--- a/modem-probe/modem-probe.c
+++ b/modem-probe/modem-probe.c
@@ -306,6 +306,7 @@ static int modem_probe_caps(int fd)
g_free (reply);
reply = NULL;
+ verbose ("GCAP failed, trying ATI...");
if (modem_send_command (fd, "ATI\r\n")) {
idx = modem_wait_reply (fd, 3, ati_responses, terminators, &term_idx, &reply);
if (0 == term_idx && 0 == idx) {
@@ -313,7 +314,9 @@ static int modem_probe_caps(int fd)
ret = parse_gcap (reply);
}
}
- }
+ } else
+ verbose ("timed out waiting for GCAP reply (idx %d, term_idx %d)", idx, term_idx);
+
g_free (reply);
reply = NULL;
@@ -339,6 +342,7 @@ print_usage (void)
{
printf("Usage: probe-modem [options] <device>\n"
" --export export key/value pairs\n"
+ " --delay <ms> delay before probing (1 to 3000 ms inclusive)\n"
" --verbose print verbose debugging output\n"
" --log <file> log all output\n"
" --help\n\n");
@@ -356,6 +360,7 @@ main(int argc, char *argv[])
{
static const struct option options[] = {
{ "export", 0, NULL, 'x' },
+ { "delay", required_argument, NULL, 'a' },
{ "verbose", 0, NULL, 'v' },
{ "quiet", 0, NULL, 'q' },
{ "log", required_argument, NULL, 'l' },
@@ -365,9 +370,11 @@ main(int argc, char *argv[])
const char *device = NULL;
const char *logpath = NULL;
+ const char *delay_str = NULL;
gboolean export = 0;
struct termios orig, attrs;
int fd, caps;
+ guint32 delay_ms = 0;
while (1) {
int option;
@@ -380,6 +387,9 @@ main(int argc, char *argv[])
case 'x':
export = TRUE;
break;
+ case 'a':
+ delay_str = optarg;
+ break;
case 'v':
verbose = TRUE;
break;
@@ -418,6 +428,24 @@ main(int argc, char *argv[])
do_exit (3);
}
+ verbose ("probing %s", device);
+
+ if (delay_str) {
+ unsigned long int tmp;
+
+ tmp = strtoul (delay_str, NULL, 10);
+ if (tmp < 1 || tmp > 3000) {
+ g_printerr ("Invalid delay: %s\n", delay_str);
+ do_exit (3);
+ }
+ delay_ms = (guint32) tmp;
+ }
+
+ if (delay_ms) {
+ verbose ("waiting %ums before probing", delay_ms);
+ g_usleep (delay_ms * 1000);
+ }
+
fd = open (device, O_RDWR | O_EXCL | O_NONBLOCK);
if (fd < 0) {
g_printerr ("open(%s) failed: %d\n", device, errno);
@@ -439,7 +467,7 @@ main(int argc, char *argv[])
attrs.c_cc[VEOF] = 1;
attrs.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
- attrs.c_cflag |= (B9600 | CS8 | CREAD | 0 | 0 | 0);
+ attrs.c_cflag |= (B9600 | CS8 | CREAD | PARENB);
tcsetattr (fd, TCSANOW, &attrs);
caps = modem_probe_caps (fd);