http://bugzilla.openmoko.org/cgi-bin/bugzilla/show_bug.cgi?id=766

From: From Cesar Eduardo Barros <cesarb@cesarb.net>

This patch adds extra debugging showing exactly what was sent to the modem
(except for the \r, which isn't checked at all), and most importantly,
when, to help with debugging.

Also, the patch shows the cause of the problem is not a short write of the
CR at the end of a command.

Signed-off-by: Jim Huang <jserv@openmoko.org>
---
 src/gsmd/atcmd.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: gsm/src/gsmd/atcmd.c
===================================================================
--- gsm.orig/src/gsmd/atcmd.c	2007-09-18 00:34:26.000000000 +0800
+++ gsm/src/gsmd/atcmd.c	2007-09-18 00:36:26.000000000 +0800
@@ -426,7 +426,7 @@
 /* callback to be called if [virtual] UART has some data for us */
 static int atcmd_select_cb(int fd, unsigned int what, void *data)
 {
-	int len, rc;
+	int len, rc, rc2;
 	static char rxbuf[1024];
 	struct gsmd *g = data;
 	char *cr;
@@ -467,11 +467,16 @@
 					fd, rc);
 				return rc;
 			}
+			DEBUGP("write `%s'(%d/%d)\n", pos->cur, rc, len);
 			if (!cr || rc == len)
 				rc ++;	/* Skip the \n or \0 */
 			pos->buflen -= rc;
 			pos->cur += rc;
-			write(fd, "\r", 1);
+			rc2 = write(fd, "\r", 1);
+			if (rc2 != 1)
+				gsmd_log(GSMD_ERROR,
+					"error during write of \\r to fd %d: %d\n",
+					fd, rc2);
 
 			if (!pos->buflen) {
 				/* success: remove from global list of
