Changeset 3501
- Timestamp:
- 11/24/07 19:52:38 (6 years ago)
- File:
-
- 1 edited
-
trunk/src/target/gsm/src/gsmd/machine_gta01.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/gsm/src/gsmd/machine_gta01.c
r3497 r3501 34 34 #include <gsmd/atcmd.h> 35 35 36 #define GSMD_MODEM_WAKEUP_TIMEOUT 336 #define GSMD_MODEM_WAKEUP_TIMEOUT 3 37 37 #define GSMD_MODEM_POWEROFF_TIMEOUT 3 38 38 … … 42 42 } 43 43 44 static struct gsmd_timer * poweroff_timer(struct gsmd *g)44 static struct gsmd_timer *poweroff_timer(struct gsmd *g) 45 45 { 46 46 struct timeval tv; … … 49 49 DEBUGP("Create power off timer\n"); 50 50 51 return gsmd_timer_create(&tv, &poweroff_timeout,g);51 return gsmd_timer_create(&tv, &poweroff_timeout, g); 52 52 } 53 53 54 54 static int gta01_power(struct gsmd *g, int power) 55 55 { 56 struct gsmd_atcmd * cmd = NULL;56 struct gsmd_atcmd *cmd = NULL; 57 57 58 switch (power) 59 { 60 case GSMD_MODEM_POWERUP: 58 switch (power) { 59 case GSMD_MODEM_POWERUP: 61 60 break; 62 61 63 case GSMD_MODEM_POWERDOWN: 64 65 //After send AT@POFF to GSM modem, modem will not work anymore and gsmd get no response 66 cmd = atcmd_fill("AT@POFF", 7+1, NULL, g, 0, poweroff_timer); 62 case GSMD_MODEM_POWERDOWN: 63 /* After sending "AT@POFF" to GSM modem, modem will 64 * soon power off, and then gsmd gets no response 65 * from modem. */ 66 cmd = atcmd_fill("AT@POFF", 7 + 1, NULL, 67 g, 0, poweroff_timer); 67 68 68 69 if (!cmd) … … 70 71 71 72 llist_add_tail(&cmd->list, &g->pending_atcmds); 72 if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 73 if (llist_empty(&g->busy_atcmds) && 74 !llist_empty(&g->pending_atcmds)) { 73 75 atcmd_wake_pending_queue(g); 74 76 } … … 85 87 { 86 88 DEBUGP("The wake up callback!!\n"); 87 return 0;89 return 0; 88 90 } 89 91 90 92 static void wakeup_timeout(struct gsmd_timer *tmr, void *data) 91 93 { 92 struct gsmd *g=data;93 struct gsmd_atcmd *cmd=NULL;94 DEBUGP("Wakeup time out!!\n");95 if (!llist_empty(&g->busy_atcmds)) {96 cmd = llist_entry(g->busy_atcmds.next,struct gsmd_atcmd, list);97 }98 if (!cmd) {99 DEBUGP("ERROR!! busy_atcmds is NULL\n");100 return;101 }94 struct gsmd *g = data; 95 struct gsmd_atcmd *cmd = NULL; 96 DEBUGP("Wakeup time out!!\n"); 97 if (!llist_empty(&g->busy_atcmds)) { 98 cmd = llist_entry(g->busy_atcmds.next, struct gsmd_atcmd, list); 99 } 100 if (!cmd) { 101 DEBUGP("ERROR!! busy_atcmds is NULL\n"); 102 return; 103 } 102 104 103 if (cmd->timeout != tmr) {104 DEBUGP("ERROR!! cmd->timeout != tmr\n");105 return;106 }105 if (cmd->timeout != tmr) { 106 DEBUGP("ERROR!! cmd->timeout != tmr\n"); 107 return; 108 } 107 109 108 gsmd_timer_free(cmd->timeout);109 cmd->timeout = NULL;110 gsmd_timer_free(cmd->timeout); 111 cmd->timeout = NULL; 110 112 111 // It's a wakeup command 112 if ( cmd->buf[0]==' ') { 113 llist_del(&cmd->list); 114 talloc_free(cmd); 115 // discard the wakeup command, and pass the real command. 116 if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 117 atcmd_wake_pending_queue(g); 118 } 119 } else { 120 DEBUGP("ERROR!! Wakeup timeout and cmd->buf is not wakeup command!! %s\n",cmd->buf); 121 } 113 /* It's a wakeup command */ 114 if ( cmd->buf[0] == ' ') { 115 llist_del(&cmd->list); 116 talloc_free(cmd); 117 /* discard the wakeup command, and pass the real command. */ 118 if (llist_empty(&g->busy_atcmds) && 119 !llist_empty(&g->pending_atcmds)) { 120 atcmd_wake_pending_queue(g); 121 } 122 } else { 123 DEBUGP("ERROR!! Wakeup timeout and " 124 "cmd->buf is not wakeup command!! %s\n", 125 cmd->buf); 126 } 122 127 } 123 128 124 129 static struct gsmd_timer * wakeup_timer(struct gsmd *g) 125 130 { 126 struct timeval tv;127 tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT;128 tv.tv_usec = 0;131 struct timeval tv; 132 tv.tv_sec = GSMD_MODEM_WAKEUP_TIMEOUT; 133 tv.tv_usec = 0; 129 134 DEBUGP("Create wake up timer\n"); 130 135 131 return gsmd_timer_create(&tv,&wakeup_timeout,g);136 return gsmd_timer_create(&tv, &wakeup_timeout, g); 132 137 } 133 138 134 / // adding a null '\r' before real at command.139 /* adding a null '\r' before real at command. */ 135 140 static int atcmd_wakeup_modem(struct gsmd *g) 136 141 { 137 142 DEBUGP("try to wake up\n"); 138 struct gsmd_atcmd * cmd= atcmd_fill(" \r", 2, null_wakeup_cb, g, 0, wakeup_timer); 143 struct gsmd_atcmd *cmd = atcmd_fill(" \r", 2, null_wakeup_cb, 144 g, 0, wakeup_timer); 139 145 140 146 llist_add_tail(&cmd->list, &g->pending_atcmds); 141 if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { 147 if (llist_empty(&g->busy_atcmds) && 148 !llist_empty(&g->pending_atcmds)) { 142 149 atcmd_wake_pending_queue(g); 143 150 } … … 154 161 static int gta01_init(struct gsmd *g, int fd) 155 162 { 156 int rc;157 158 163 /* 159 164 * We assume that the GSM chipset can take
Note: See TracChangeset
for help on using the changeset viewer.
