From 4a39aa20e8a38999ee81ee2d0d1c61ff4c871b7a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 22 Jan 2009 19:00:42 -0500 Subject: 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. --- modem-probe/modem-probe.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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")) { -- cgit