All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] emulator: add support of void parameters in CMER
  2011-02-24 15:46 [PATCH " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-24 15:46 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  0 siblings, 0 replies; 5+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-24 15:46 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

---
 src/emulator.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 4896ae1..c4bc505 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -312,23 +312,23 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 	case G_AT_SERVER_REQUEST_TYPE_SET:
 	{
 		GAtResultIter iter;
-		int mode;
+		int mode = em->events_mode;
 		int ind = em->events_ind;
-		int val;
+		int val = 0;
 
 		g_at_result_iter_init(&iter, result);
 		g_at_result_iter_next(&iter, "");
 
 		/* mode */
-		if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
+		if (!g_at_result_iter_next_number_or_void(&iter, &mode))
 			goto fail;
 
 		if ((mode != 0) && (mode != 3))
 			goto fail;
 
 		/* keyp */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_or_void(&iter, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -337,8 +337,8 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* disp */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_or_void(&iter, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -347,8 +347,8 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* ind */
-		if (g_at_result_iter_next_number(&iter, &ind) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_or_void(&iter, &ind)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -357,8 +357,8 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* bfr */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_or_void(&iter, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -367,7 +367,7 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* check that bfr is last parameter */
-		if (g_at_result_iter_skip_next(&iter) == TRUE)
+		if (g_at_result_iter_skip_next(&iter))
 			goto fail;
 
 done:
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 0/2] add support of void parameters in CMER
@ 2011-02-24 17:16 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 17:16 ` [PATCH 1/2] gatchat: add g_at_result_iter_next_number_default API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-24 17:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

following commands are supported :
AT+CMER=3,0,0,1,0

OK
AT+CMER=3,0,0,1

OK
AT+CMER=3,,,1

OK
AT+CMER=3,,,1,

OK
AT+CMER=,,0,1,

OK
AT+CMER=3, ,,1

OK
AT+CMER=3,a,0,1

ERROR
AT+CMER=3,"a",0,1

ERROR
AT+CMER=3,

OK
AT+CMER=3

OK

Frédéric Danis (2):
  gatchat: add g_at_result_iter_next_number_default API
  emulator: add support of void parameters in CMER

 gatchat/gatresult.c |   30 ++++++++++++++++++++++++++++++
 gatchat/gatresult.h |    2 ++
 src/emulator.c      |   24 ++++++++++++------------
 3 files changed, 44 insertions(+), 12 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] gatchat: add g_at_result_iter_next_number_default API
  2011-02-24 17:16 [PATCH v2 0/2] add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-24 17:16 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 17:16 ` [PATCH 2/2] emulator: add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 20:02 ` [PATCH v2 0/2] " Denis Kenzior
  2 siblings, 0 replies; 5+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-24 17:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

---
 gatchat/gatresult.c |   30 ++++++++++++++++++++++++++++++
 gatchat/gatresult.h |    2 ++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index 8a6dfae..f992486 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -292,6 +292,36 @@ gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint *number)
 	return TRUE;
 }
 
+gboolean g_at_result_iter_next_number_default(GAtResultIter *iter, gint dflt,
+						gint *number)
+{
+	unsigned int pos;
+	int len;
+	char *line;
+
+	if (iter == NULL)
+		return FALSE;
+
+	if (iter->l == NULL)
+		return FALSE;
+
+	line = iter->l->data;
+	len = strlen(line);
+
+	pos = skip_to_next_field(line, iter->line_pos, len);
+
+	if (pos != iter->line_pos) {
+		iter->line_pos = pos;
+
+		if (number)
+			*number = dflt;
+
+		return TRUE;
+	}
+
+	return g_at_result_iter_next_number(iter, number);
+}
+
 gboolean g_at_result_iter_next_range(GAtResultIter *iter, gint *min, gint *max)
 {
 	int pos;
diff --git a/gatchat/gatresult.h b/gatchat/gatresult.h
index a74741f..f498c86 100644
--- a/gatchat/gatresult.h
+++ b/gatchat/gatresult.h
@@ -58,6 +58,8 @@ gboolean g_at_result_iter_next_string(GAtResultIter *iter, const char **str);
 gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
 						const char **str);
 gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint *number);
+gboolean g_at_result_iter_next_number_default(GAtResultIter *iter, gint dflt,
+						gint *number);
 gboolean g_at_result_iter_next_hexstring(GAtResultIter *iter,
 		const guint8 **str, gint *length);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] emulator: add support of void parameters in CMER
  2011-02-24 17:16 [PATCH v2 0/2] add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 17:16 ` [PATCH 1/2] gatchat: add g_at_result_iter_next_number_default API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-24 17:16 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 20:02 ` [PATCH v2 0/2] " Denis Kenzior
  2 siblings, 0 replies; 5+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-24 17:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]

---
 src/emulator.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 9cd3252..20a575f 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -312,7 +312,7 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 	case G_AT_SERVER_REQUEST_TYPE_SET:
 	{
 		GAtResultIter iter;
-		int mode;
+		int mode = em->events_mode;
 		int ind = em->events_ind;
 		int val;
 
@@ -320,15 +320,15 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 		g_at_result_iter_next(&iter, "");
 
 		/* mode */
-		if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
+		if (!g_at_result_iter_next_number_default(&iter, mode, &mode))
 			goto fail;
 
 		if (mode != 0 && mode != 3)
 			goto fail;
 
 		/* keyp */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_default(&iter, 0, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -337,8 +337,8 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* disp */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_default(&iter, 0, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -347,18 +347,18 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* ind */
-		if (g_at_result_iter_next_number(&iter, &ind) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_default(&iter, ind, &ind)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
 
-		if ((ind != 0) && (ind != 1))
+		if (ind != 0 && ind != 1)
 			goto fail;
 
 		/* bfr */
-		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
-			if (g_at_result_iter_skip_next(&iter) == FALSE)
+		if (!g_at_result_iter_next_number_default(&iter, 0, &val)) {
+			if (!g_at_result_iter_skip_next(&iter))
 				goto done;
 			goto fail;
 		}
@@ -367,7 +367,7 @@ static void cmer_cb(GAtServer *server, GAtServerRequestType type,
 			goto fail;
 
 		/* check that bfr is last parameter */
-		if (g_at_result_iter_skip_next(&iter) == TRUE)
+		if (g_at_result_iter_skip_next(&iter))
 			goto fail;
 
 done:
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] add support of void parameters in CMER
  2011-02-24 17:16 [PATCH v2 0/2] add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 17:16 ` [PATCH 1/2] gatchat: add g_at_result_iter_next_number_default API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-24 17:16 ` [PATCH 2/2] emulator: add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-24 20:02 ` Denis Kenzior
  2 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2011-02-24 20:02 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 809 bytes --]

Hi Frédéric,

On 02/24/2011 11:16 AM, Frédéric Danis wrote:
> following commands are supported :
> AT+CMER=3,0,0,1,0
> 
> OK
> AT+CMER=3,0,0,1
> 
> OK
> AT+CMER=3,,,1
> 
> OK
> AT+CMER=3,,,1,
> 
> OK
> AT+CMER=,,0,1,
> 
> OK
> AT+CMER=3, ,,1
> 
> OK
> AT+CMER=3,a,0,1
> 
> ERROR
> AT+CMER=3,"a",0,1
> 
> ERROR
> AT+CMER=3,
> 
> OK
> AT+CMER=3
> 
> OK
> 
> Frédéric Danis (2):
>   gatchat: add g_at_result_iter_next_number_default API
>   emulator: add support of void parameters in CMER
> 
>  gatchat/gatresult.c |   30 ++++++++++++++++++++++++++++++
>  gatchat/gatresult.h |    2 ++
>  src/emulator.c      |   24 ++++++++++++------------
>  3 files changed, 44 insertions(+), 12 deletions(-)
> 

Both patches have been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-24 20:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-24 17:16 [PATCH v2 0/2] add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-24 17:16 ` [PATCH 1/2] gatchat: add g_at_result_iter_next_number_default API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-24 17:16 ` [PATCH 2/2] emulator: add support of void parameters in CMER =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-24 20:02 ` [PATCH v2 0/2] " Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2011-02-24 15:46 [PATCH " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-24 15:46 ` [PATCH 2/2] emulator: " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.