r2732 - in trunk/src/target/gsm: include/gsmd src/gsmd
laforge at sita.openmoko.org
laforge at sita.openmoko.org
Fri Aug 17 10:36:16 CEST 2007
Author: laforge
Date: 2007-08-17 10:36:11 +0200 (Fri, 17 Aug 2007)
New Revision: 2732
Modified:
trunk/src/target/gsm/include/gsmd/gsmd.h
trunk/src/target/gsm/src/gsmd/atcmd.c
Log:
mlbuf in gsmd struct (Andrzej Zaborowski)
Modified: trunk/src/target/gsm/include/gsmd/gsmd.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/gsmd.h 2007-08-17 08:35:29 UTC (rev 2731)
+++ trunk/src/target/gsm/include/gsmd/gsmd.h 2007-08-17 08:36:11 UTC (rev 2732)
@@ -79,6 +79,9 @@
struct gsmd_device_state dev_state;
struct llist_head operators; /* cached list of operator names */
+ unsigned char *mlbuf; /* ml_parse buffer */
+ unsigned int mlbuf_len;
+ int mlunsolicited;
};
struct gsmd_user {
Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c 2007-08-17 08:35:29 UTC (rev 2731)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c 2007-08-17 08:36:11 UTC (rev 2732)
@@ -194,10 +194,7 @@
{
struct gsmd *g = ctx;
struct gsmd_atcmd *cmd = NULL;
- static char mlbuf[MLPARSE_BUF_SIZE];
int rc = 0;
- static int mlbuf_len;
- static int mlunsolicited = 0;
int cme_error = 0;
DEBUGP("buf=`%s'(%d)\n", buf, len);
@@ -278,9 +275,9 @@
* input. Wait for the next line, concatenate
* and resumbit to unsolicited_parse(). */
DEBUGP("Multiline unsolicited code\n");
- mlbuf_len = len;
- memcpy(mlbuf, buf, len);
- mlunsolicited = 1;
+ g->mlbuf_len = len;
+ memcpy(g->mlbuf, buf, len);
+ g->mlunsolicited = 1;
return 0;
}
/* if unsolicited parser didn't handle this 'reply', then we
@@ -303,16 +300,16 @@
/* it might be a multiline response, so if there's a previous
response, send out mlbuf and start afresh with an empty buffer */
- if (mlbuf_len) {
+ if (g->mlbuf_len) {
if (!cmd->cb) {
gsmd_log(GSMD_NOTICE, "command without cb!!!\n");
} else {
DEBUGP("Calling cmd->cb()\n");
- cmd->resp = mlbuf;
+ cmd->resp = g->mlbuf;
rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
DEBUGP("Clearing mlbuf\n");
}
- mlbuf_len = 0;
+ g->mlbuf_len = 0;
}
/* the current buf will be appended to mlbuf below */
@@ -360,17 +357,17 @@
/* we reach here, if we are at an information response that needs to be
* passed on */
- if (mlbuf_len)
- mlbuf[mlbuf_len ++] = '\n';
+ if (g->mlbuf_len)
+ g->mlbuf[g->mlbuf_len ++] = '\n';
DEBUGP("Appending buf to mlbuf\n");
- if (len > sizeof(mlbuf) - mlbuf_len)
- len = sizeof(mlbuf) - mlbuf_len;
- memcpy(mlbuf + mlbuf_len, buf, len);
- mlbuf_len += len;
+ if (len > sizeof(g->mlbuf) - g->mlbuf_len)
+ len = sizeof(g->mlbuf) - g->mlbuf_len;
+ memcpy(g->mlbuf + g->mlbuf_len, buf, len);
+ g->mlbuf_len += len;
- if (mlunsolicited) {
- rc = unsolicited_parse(g, mlbuf, mlbuf_len,
- strchr(mlbuf, ':') + 1);
+ if (g->mlunsolicited) {
+ rc = unsolicited_parse(g, g->mlbuf, g->mlbuf_len,
+ strchr(g->mlbuf, ':') + 1);
if (rc == -EAGAIN) {
/* The parser wants one more line of
* input. Wait for the next line, concatenate
@@ -378,8 +375,8 @@
DEBUGP("Multiline unsolicited code\n");
return 0;
}
- mlunsolicited = 0;
- mlbuf_len = 0;
+ g->mlunsolicited = 0;
+ g->mlbuf_len = 0;
return rc;
}
return 0;
@@ -397,15 +394,16 @@
gsmd_log(GSMD_NOTICE, "command without cb!!!\n");
} else {
DEBUGP("Calling final cmd->cb()\n");
- /* send final result code if there is no information response in mlbuf */
- if (mlbuf_len) {
- cmd->resp = mlbuf;
- mlbuf[mlbuf_len] = 0;
+ /* send final result code if there is no information
+ * response in mlbuf */
+ if (g->mlbuf_len) {
+ cmd->resp = g->mlbuf;
+ g->mlbuf[g->mlbuf_len] = 0;
} else
cmd->resp = buf;
rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
DEBUGP("Clearing mlbuf\n");
- mlbuf_len = 0;
+ g->mlbuf_len = 0;
}
/* remove from list of currently executing cmds */
@@ -571,6 +569,9 @@
llparse_init (&g->llp);
+ g->mlbuf_len = 0;
+ g->mlunsolicited = 0;
+
g->llp.cur = g->llp.buf;
g->llp.len = sizeof(g->llp.buf);
g->llp.cb = &ml_parse;
More information about the commitlog
mailing list