r4136 - developers/sean_chiang/gsm-pm
sean_chiang at sita.openmoko.org
sean_chiang at sita.openmoko.org
Fri Feb 29 09:41:55 CET 2008
Author: sean_chiang
Date: 2008-02-29 09:41:52 +0100 (Fri, 29 Feb 2008)
New Revision: 4136
Modified:
developers/sean_chiang/gsm-pm/gsm-pm.c
Log:
drain the uart before we send AT at POFF
Modified: developers/sean_chiang/gsm-pm/gsm-pm.c
===================================================================
--- developers/sean_chiang/gsm-pm/gsm-pm.c 2008-02-29 04:12:52 UTC (rev 4135)
+++ developers/sean_chiang/gsm-pm/gsm-pm.c 2008-02-29 08:41:52 UTC (rev 4136)
@@ -91,6 +91,19 @@
return tcsetattr(fd, 0, &ti);
}
+static void drain(int fd)
+{
+ int rc;
+ struct termios t;
+ rc = tcflush(fd, TCIOFLUSH);
+ rc = tcgetattr(fd, &t);
+ printf("c_iflag = 0x%08x, c_oflag = 0x%08x, c_cflag = 0x%08x, c_lflag = 0x%08x\n",
+ t.c_iflag, t.c_oflag, t.c_cflag, t.c_lflag);
+ t.c_iflag = t.c_oflag = 0;
+ cfmakeraw(&t);
+ rc = tcsetattr(fd, TCSANOW, &t);
+}
+
int main(int argc, char **argv) {
char *p_DL, *p_POW, *p_RES, *p_OPTS, *p_DEV;
@@ -151,14 +164,25 @@
printf("can't set baudrate\n");
exit(1);
}
+
+ drain(fd);
- write(fd, "AT", 2);
- write(fd, " \r", 2);
- write(fd,"AT at POFF", 7);
+ if ( write(fd, "AT\r", 3) <= 0 ) {
+ printf("1 error\n");
+ exit(1);
+ }
+ if ( write(fd, "AT\r", 3) <= 0 ) {
+ printf("2 error\n");
+ exit(1);
+ }
+ if ( write(fd,"AT at POFF\r", 8) <=0 ) {
+ printf("3 error\n");
+ exit(1);
+ }
close(fd);
+
+ sleep(1);
- sleep(1);
-
if ( p_POW ) {
sprintf(buf, "echo \"0\" > %s", p_POW);
system(buf);
More information about the commitlog
mailing list