* [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client.
@ 2011-03-15 9:19 Guillaume Zajac
2011-03-17 20:13 ` Denis Kenzior
0 siblings, 1 reply; 5+ messages in thread
From: Guillaume Zajac @ 2011-03-15 9:19 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2441 bytes --]
---
gatchat/gathdlc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index 6c39e6c..38606b8 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -66,6 +66,10 @@ struct _GAtHDLC {
gboolean in_read_handler;
gboolean destroyed;
gboolean no_carrier_detect;
+ GAtSuspendFunc suspend_func;
+ gpointer suspend_data;
+ guint cmpt;
+ guint suspend_timeout;
};
static void hdlc_record(int fd, gboolean in, guint8 *data, guint16 length)
@@ -128,6 +132,34 @@ guint32 g_at_hdlc_get_recv_accm(GAtHDLC *hdlc)
return hdlc->recv_accm;
}
+void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func,
+ gpointer user_data)
+{
+ if (hdlc == NULL)
+ return;
+
+ hdlc->suspend_func = func;
+ hdlc->suspend_data = user_data;
+}
+
+static gboolean susp_timeout_cb(gpointer user_data)
+{
+ GAtHDLC *hdlc = user_data;
+
+ hdlc->cmpt = 0;
+
+ return FALSE;
+}
+
+static void hdlc_suspend(GAtHDLC *hdlc)
+{
+ g_at_io_set_write_handler(hdlc->io, NULL, NULL);
+ g_at_io_set_read_handler(hdlc->io, NULL, NULL);
+
+ if (hdlc->suspend_func)
+ hdlc->suspend_func(hdlc->suspend_data);
+}
+
static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
{
GAtHDLC *hdlc = user_data;
@@ -151,6 +183,21 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
hdlc->decode_offset == 0 && *buf == '\r')
break;
+ /* We detect the '+' character to suspend data call if
+ * 3 '+' are detected in less than 500 milliseconds
+ */
+ if (*buf == '+') {
+ if (hdlc->cmpt == 0)
+ hdlc->suspend_timeout = g_timeout_add (500,
+ susp_timeout_cb, hdlc);
+ hdlc->cmpt++;
+ if (hdlc->cmpt == 3)
+ goto suspend;
+ }
+ else {
+ hdlc->cmpt = 0;
+ }
+
if (hdlc->decode_escape == TRUE) {
unsigned char val = *buf ^ HDLC_TRANS;
@@ -195,6 +242,15 @@ out:
if (hdlc->destroyed)
g_free(hdlc);
+
+ return;
+
+suspend:
+ g_source_remove(hdlc->suspend_timeout);
+
+ ring_buffer_reset(rbuf);
+
+ hdlc_suspend(hdlc);
}
GAtHDLC *g_at_hdlc_new_from_io(GAtIO *io)
@@ -236,6 +292,8 @@ GAtHDLC *g_at_hdlc_new_from_io(GAtIO *io)
hdlc->io = g_at_io_ref(io);
g_at_io_set_read_handler(hdlc->io, new_bytes, hdlc);
+ hdlc->cmpt = 0;
+
return hdlc;
error:
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client.
2011-03-15 9:19 [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client Guillaume Zajac
@ 2011-03-17 20:13 ` Denis Kenzior
2011-03-21 14:17 ` Guillaume Zajac
0 siblings, 1 reply; 5+ messages in thread
From: Denis Kenzior @ 2011-03-17 20:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
Hi Guillaume,
On 03/15/2011 04:19 AM, Guillaume Zajac wrote:
> ---
> gatchat/gathdlc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 58 insertions(+), 0 deletions(-)
http://en.wikipedia.org/wiki/Time_Independent_Escape_Sequence
If you really want to do this, then lets do this properly, including the
guard timeouts.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client.
2011-03-17 20:13 ` Denis Kenzior
@ 2011-03-21 14:17 ` Guillaume Zajac
2011-03-21 18:57 ` Denis Kenzior
0 siblings, 1 reply; 5+ messages in thread
From: Guillaume Zajac @ 2011-03-21 14:17 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
Hi Denis,
On 17/03/2011 21:13, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 03/15/2011 04:19 AM, Guillaume Zajac wrote:
>> ---
>> gatchat/gathdlc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 58 insertions(+), 0 deletions(-)
> http://en.wikipedia.org/wiki/Time_Independent_Escape_Sequence
>
> If you really want to do this, then lets do this properly, including the
> guard timeouts.
>
> Regards,
> -Denis
>
I noticed also this guard timeouts after having sent the set of patches.
I will send a 2nd version of patches.
However I can't test the "+++" sequence with telnet because it is adding
some '\r' '\n' characters when I do do "+++" then "Enter".
I could try to filter those characters but it would add some specific
code for telnet test case.
I have tried to modifiy gsmdial to send "+++" 5 seconds after the 2 ppp
devices have been set up for instance.
I have implemented a g_at_ppp_send_escape_sequence() function to send
it. (this function directly writes on the GIOChannel)
Then the GAtChat is resumed and an ATH0 is sent.
Should I commit first the test case over gsmdial and then commit the
escape sequence detection mechanism?
Kind regards,
Guillaume
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client.
2011-03-21 14:17 ` Guillaume Zajac
@ 2011-03-21 18:57 ` Denis Kenzior
2011-03-22 8:57 ` Guillaume Zajac
0 siblings, 1 reply; 5+ messages in thread
From: Denis Kenzior @ 2011-03-21 18:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]
Hi Guillaume,
On 03/21/2011 09:17 AM, Guillaume Zajac wrote:
> Hi Denis,
>
> On 17/03/2011 21:13, Denis Kenzior wrote:
>> Hi Guillaume,
>>
>> On 03/15/2011 04:19 AM, Guillaume Zajac wrote:
>>> ---
>>> gatchat/gathdlc.c | 58
>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 files changed, 58 insertions(+), 0 deletions(-)
>> http://en.wikipedia.org/wiki/Time_Independent_Escape_Sequence
>>
>> If you really want to do this, then lets do this properly, including the
>> guard timeouts.
>>
>> Regards,
>> -Denis
>>
> I noticed also this guard timeouts after having sent the set of patches.
> I will send a 2nd version of patches.
> However I can't test the "+++" sequence with telnet because it is adding
> some '\r' '\n' characters when I do do "+++" then "Enter".
> I could try to filter those characters but it would add some specific
> code for telnet test case.
>
> I have tried to modifiy gsmdial to send "+++" 5 seconds after the 2 ppp
> devices have been set up for instance.
> I have implemented a g_at_ppp_send_escape_sequence() function to send
> it. (this function directly writes on the GIOChannel)
> Then the GAtChat is resumed and an ATH0 is sent.
>
> Should I commit first the test case over gsmdial and then commit the
> escape sequence detection mechanism?
>
The order doesn't matter, but it would be nice to have all of this in
the same patch series for context. That way the entire series can be
applied and tested in one go.
You might have to do a bit more work than just sending +++ to the
IOChannel. For instance you might need to shutdown I/O coming from the
TUN device so as not to overflow the GAtHDLC write queue. So perhaps a
proper g_at_ppp_suspend and g_at_chat_send_command_mode_escape() is needed.
Regards,
-Denis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client.
2011-03-21 18:57 ` Denis Kenzior
@ 2011-03-22 8:57 ` Guillaume Zajac
0 siblings, 0 replies; 5+ messages in thread
From: Guillaume Zajac @ 2011-03-22 8:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2127 bytes --]
Hi Denis,
On 21/03/2011 19:57, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 03/21/2011 09:17 AM, Guillaume Zajac wrote:
>> Hi Denis,
>>
>> On 17/03/2011 21:13, Denis Kenzior wrote:
>>> Hi Guillaume,
>>>
>>> On 03/15/2011 04:19 AM, Guillaume Zajac wrote:
>>>> ---
>>>> gatchat/gathdlc.c | 58
>>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> 1 files changed, 58 insertions(+), 0 deletions(-)
>>> http://en.wikipedia.org/wiki/Time_Independent_Escape_Sequence
>>>
>>> If you really want to do this, then lets do this properly, including the
>>> guard timeouts.
>>>
>>> Regards,
>>> -Denis
>>>
>> I noticed also this guard timeouts after having sent the set of patches.
>> I will send a 2nd version of patches.
>> However I can't test the "+++" sequence with telnet because it is adding
>> some '\r' '\n' characters when I do do "+++" then "Enter".
>> I could try to filter those characters but it would add some specific
>> code for telnet test case.
>>
>> I have tried to modifiy gsmdial to send "+++" 5 seconds after the 2 ppp
>> devices have been set up for instance.
>> I have implemented a g_at_ppp_send_escape_sequence() function to send
>> it. (this function directly writes on the GIOChannel)
>> Then the GAtChat is resumed and an ATH0 is sent.
>>
>> Should I commit first the test case over gsmdial and then commit the
>> escape sequence detection mechanism?
>>
> The order doesn't matter, but it would be nice to have all of this in
> the same patch series for context. That way the entire series can be
> applied and tested in one go.
>
> You might have to do a bit more work than just sending +++ to the
> IOChannel. For instance you might need to shutdown I/O coming from the
> TUN device so as not to overflow the GAtHDLC write queue. So perhaps a
> proper g_at_ppp_suspend and g_at_chat_send_command_mode_escape() is needed.
>
Thanks for the info, I will commit first my version 2 of the escape
sequence detection mechanism.
Then, I will find a proper way to reproduce the suspend mechanism with
gsmdial.
Kind regards,
Guillaume
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-22 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-15 9:19 [PATCH 3/6] gathdlc: add mechanism to detect ppp suspension from DUN client Guillaume Zajac
2011-03-17 20:13 ` Denis Kenzior
2011-03-21 14:17 ` Guillaume Zajac
2011-03-21 18:57 ` Denis Kenzior
2011-03-22 8:57 ` Guillaume Zajac
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.