Re: [PATCH 07/12] gatchat: implementation for +CPOS send
Hi Jarko, On 03/24/2011 08:46 AM, Jarko Poutiainen wrote: --- gatchat/gatchat.c | 37 + 1 files changed, 33 insertions(+), 4 deletions(-) I dropped this patch (along with 08) and implemented my own versions. Please review the implementation and let me know if you can see any problems. While GAtChat can handle the short prompting now (at least in my testing), I'm still hating the extra hoops we had to jump through to make this happen. I'd still prefer using 27.005 style prompts, as there are still cases (e.g. echo enabled) where the current implementation might not work. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 07/12] gatchat: implementation for +CPOS send
--- gatchat/gatchat.c | 37 + 1 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 3fd564d..eeb8d24 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -53,6 +53,7 @@ struct at_command { GAtNotifyFunc listing; gpointer user_data; GDestroyNotify notify; + gboolean short_prompt; }; struct at_notify_node { @@ -725,9 +726,18 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) unsigned char *buf = ring_buffer_read_ptr(rbuf, p-read_so_far); GAtSyntaxResult result; + struct at_command *cmd; p-in_read_handler = TRUE; + cmd = g_queue_peek_head(p-command_queue); + if (cmd) + if (cmd-short_prompt + !g_strcmp0(*cmd-prefixes, +CPOS:) + p-syntax-set_hint) + p-syntax-set_hint(p-syntax, + G_AT_SYNTAX_EXPECT_SHORT_PROMPT); + while (p-suspended == FALSE (p-read_so_far len)) { gsize rbytes = MIN(len - p-read_so_far, wrap - p-read_so_far); result = p-syntax-feed(p-syntax, (char *)buf, rbytes); @@ -754,6 +764,12 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data) break; case G_AT_SYNTAX_RESULT_PROMPT: + if (cmd) + if (cmd-short_prompt + !g_strcmp0(*cmd-prefixes, + +CPOS:)) + cmd-short_prompt = FALSE; + chat_wakeup_writer(p); ring_buffer_drain(rbuf, p-read_so_far); break; @@ -995,7 +1011,8 @@ static guint at_chat_send_common(struct at_chat *chat, guint gid, GAtNotifyFunc listing, GAtResultFunc func, gpointer user_data, - GDestroyNotify notify) + GDestroyNotify notify, + gboolean short_prompt) { struct at_command *c; @@ -1007,6 +1024,7 @@ static guint at_chat_send_common(struct at_chat *chat, guint gid, if (c == NULL) return 0; + c-short_prompt = short_prompt; c-id = chat-next_cmd_id++; g_queue_push_tail(chat-command_queue, c); @@ -1439,7 +1457,7 @@ guint g_at_chat_send(GAtChat *chat, const char *cmd, { return at_chat_send_common(chat-parent, chat-group, cmd, prefix_list, FALSE, NULL, - func, user_data, notify); + func, user_data, notify, FALSE); } guint g_at_chat_send_listing(GAtChat *chat, const char *cmd, @@ -1452,7 +1470,8 @@ guint g_at_chat_send_listing(GAtChat *chat, const char *cmd, return at_chat_send_common(chat-parent, chat-group, cmd, prefix_list, FALSE, - listing, func, user_data, notify); + listing, func, user_data, notify, + FALSE); } guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd, @@ -1465,7 +1484,17 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd, return at_chat_send_common(chat-parent, chat-group, cmd, prefix_list, TRUE, - listing, func, user_data, notify); + listing, func, user_data, notify, + FALSE); +} + +guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, + const char **prefix_list, GAtResultFunc func, + gpointer user_data, GDestroyNotify notify) +{ + return at_chat_send_common(chat-parent, chat-group, + cmd, prefix_list, FALSE, NULL, + func, user_data, notify, TRUE); } gboolean g_at_chat_cancel(GAtChat *chat, guint id) -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 07/12] gatchat: implementation for +CPOS send
Hi Denis, On Fri, 2011-03-18 at 06:42 +0200, Denis Kenzior wrote: Hi Jarko, On 03/11/2011 06:23 AM, Jarko Poutiainen wrote: --- gatchat/gatchat.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 3fd564d..64f131d 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1468,6 +1468,19 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd, listing, func, user_data, notify); } +guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, + const char **prefix_list, GAtResultFunc func, + gpointer user_data, GDestroyNotify notify) +{ + if(chat != NULL) + chat-parent-syntax-set_hint(chat-parent-syntax, + G_AT_SYNTAX_EXPECT_SHORT_PROMPT); So unfortunately you can't do this. GAtChat is a command queue and we might be in the process of sending / receiving responses for multiple commands that are ahead of this one. So you can't really manipulate the syntax directly here. You have to do this only once the CPOSR has been sent on the wire. Ok, thanks. Still having trouble to understand GAtChat. Not just sure where I should set the hint then but I get your point. Now I'm also a little confused because previously you suggested that I'd make a new g_at_chat_send variant that would set the hint so what did you mean by it then if not this? + + return at_chat_send_common(chat-parent, chat-group, + cmd, prefix_list, FALSE, NULL, + func, user_data, notify); +} + gboolean g_at_chat_cancel(GAtChat *chat, guint id) { /* We use id 0 for wakeup commands */ Regards, -Denis Br, Jarko ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 07/12] gatchat: implementation for +CPOS send
Hi Jarko, +guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, + const char **prefix_list, GAtResultFunc func, + gpointer user_data, GDestroyNotify notify) +{ + if(chat != NULL) + chat-parent-syntax-set_hint(chat-parent-syntax, + G_AT_SYNTAX_EXPECT_SHORT_PROMPT); So unfortunately you can't do this. GAtChat is a command queue and we might be in the process of sending / receiving responses for multiple commands that are ahead of this one. So you can't really manipulate the syntax directly here. You have to do this only once the CPOSR has been sent on the wire. Ok, thanks. Still having trouble to understand GAtChat. Not just sure where I should set the hint then but I get your point. Now I'm also a little confused because previously you suggested that I'd make a new g_at_chat_send variant that would set the hint so what did you mean by it then if not this? Look at how e.g. expect_pdu boolean is handled. You need to do something very similar but after sending the first chunk followed by \r. (e.g. when AT+CPOS\r was sent). You probably need to add another flag/boolean to the command data structure for this. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 07/12] gatchat: implementation for +CPOS send
Hi Jarko, On 03/11/2011 06:23 AM, Jarko Poutiainen wrote: --- gatchat/gatchat.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 3fd564d..64f131d 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1468,6 +1468,19 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd, listing, func, user_data, notify); } +guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, + const char **prefix_list, GAtResultFunc func, + gpointer user_data, GDestroyNotify notify) +{ + if(chat != NULL) + chat-parent-syntax-set_hint(chat-parent-syntax, + G_AT_SYNTAX_EXPECT_SHORT_PROMPT); So unfortunately you can't do this. GAtChat is a command queue and we might be in the process of sending / receiving responses for multiple commands that are ahead of this one. So you can't really manipulate the syntax directly here. You have to do this only once the CPOSR has been sent on the wire. + + return at_chat_send_common(chat-parent, chat-group, + cmd, prefix_list, FALSE, NULL, + func, user_data, notify); +} + gboolean g_at_chat_cancel(GAtChat *chat, guint id) { /* We use id 0 for wakeup commands */ Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 07/12] gatchat: implementation for +CPOS send
--- gatchat/gatchat.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 3fd564d..64f131d 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1468,6 +1468,19 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd, listing, func, user_data, notify); } +guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, + const char **prefix_list, GAtResultFunc func, + gpointer user_data, GDestroyNotify notify) +{ + if(chat != NULL) + chat-parent-syntax-set_hint(chat-parent-syntax, + G_AT_SYNTAX_EXPECT_SHORT_PROMPT); + + return at_chat_send_common(chat-parent, chat-group, + cmd, prefix_list, FALSE, NULL, + func, user_data, notify); +} + gboolean g_at_chat_cancel(GAtChat *chat, guint id) { /* We use id 0 for wakeup commands */ -- 1.7.0.4 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono