diff options
author | Dan Williams <dcbw@redhat.com> | 2009-01-22 19:00:42 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-01-22 19:00:42 -0500 |
commit | 4a39aa20e8a38999ee81ee2d0d1c61ff4c871b7a (patch) | |
tree | 63971a6014a0b7de63990aaf6115fce96704691f | |
parent | 7d0641fab1dfd144bfc4705ae62b1c4e87ad1d79 (diff) |
modem-probe: only discover capabilties once on timeout
If the port timed out on a command for some reason, don't try the
secondary query and take yet *more* time.
-rw-r--r-- | modem-probe/modem-probe.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modem-probe/modem-probe.c b/modem-probe/modem-probe.c index fc0e5d7..803d5d5 100644 --- a/modem-probe/modem-probe.c +++ b/modem-probe/modem-probe.c @@ -142,6 +142,12 @@ find_response (const char *line, const char **responses, int *idx) #define RESPONSE_LINE_MAX 128 #define SERIAL_BUF_SIZE 2048 +/* Return values: + * + * -2: timeout + * -1: read error + * 0...N: response index in **needles array + */ static int modem_wait_reply (int fd, guint32 timeout_secs, @@ -209,6 +215,10 @@ modem_wait_reply (int fd, g_usleep (1000); } while (!done && (time (NULL) < end) && (result->len <= SERIAL_BUF_SIZE)); + /* Handle timeout */ + if (*out_terminator < 0 && !*out_response) + reply_index = -2; + g_string_free (result, TRUE); return reply_index; } @@ -302,7 +312,7 @@ static int modem_probe_caps(int fd) reply = NULL; /* Try an alternate method on some hardware (ex BUSlink SCWi275u) */ - if (!(ret & MODEM_CAP_GSM) && !(ret & MODEM_CAP_IS707_A)) { + if ((idx != -2) && !(ret & MODEM_CAP_GSM) && !(ret & MODEM_CAP_IS707_A)) { const char *gmm_responses[] = { GMM_TAG, NULL }; if (modem_send_command (fd, "AT+GMM\r\n")) { |