Skip to contentSkip to conversation

HE910 + ofono: "Activating context failed with error: Unknown error type"

DISCUSSION Marko Sulejic 3 participants 13 messages Jun 25, 2015 – Jul 1, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

I need your help in using a Telit HE910 with ofono (and eventually connman). (I am using ofono 1.16 with HE910 firmware version 12.00.006; connman version is 1.29).

My problem is the following ...
on startup everything works fine and the ppp0 connection is established, but problems occur in the following case:

connmanctl> disconnect cellular_*_context15
Disconnected cellular_*_context15

connmanctl> connect cellular_*_context15
Error /net/connman/service/cellular_*_context15: Input/output error

ofonod[5355]: gprs-context.c(244):at_gprs_activate_primary() cid 1 ofonod[5355]: gprs.c(889):pri_activate_callback() 0x1a18c50 ofonod[5355]: gprs.c(893):pri_activate_callback() Activating context failed with error: Unknown error type
connmand[3815]: Failed to change property: /he910_0/context15 org.ofono.ConnectionContext.Active: org.ofono.Error.Failed Operation failed

The same error happens if I am manually sending connect/disconnect via dbus-send.

Only a hard ofono restart can establish the connection again. This behavior happens all the time once a ppp0 disconnect happened (e.g. by removing the SIM; manual disconnect via dbus or connmanctl).

A subquestion regarding connman:
Can connmand be configured in such a way that on every connection loss, ofono is triggered to reconnect to the Internet?

Thank you very muchin advance,
Marko

#1 lore raw

Hi again,

the problem seems to be in the
atmodem/gprs-context.c : gprs_activate_primary
function, where

     if (g_at_chat_send(gcd->chat, buf, none_prefix,
                 at_cgdcont_cb, gc, NULL) > 0)

is called after a reconnect, and then it fails.

It seems to work if I call

g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
NULL, NULL, NULL)

prior.

So this would mean that a disconnect or similar action sets DCD to low, and the chats are closed.

Does oFono anywhere in the code sets DCD explicitely to low or is it maybe a bug?

My patch would look something like this (if it is an HE910 issue only):

     if (gcd->vendor == OFONO_VENDOR_TELIT)
     {
         if(g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
                     NULL, NULL, NULL) <= 0)
             goto error;
     }

Thanks,
Marko

Am 2015-06-25 um 11:15 schrieb Marko Sulejic:

Quoted 44 lines

Hi,

I need your help in using a Telit HE910 with ofono (and eventually connman).
(I am using ofono 1.16 with HE910 firmware version 12.00.006; connman version is 1.29).

My problem is the following ...
on startup everything works fine and the ppp0 connection is established, but problems occur in the following case:

connmanctl> disconnect cellular_*_context15
Disconnected cellular_*_context15

connmanctl> connect cellular_*_context15
Error /net/connman/service/cellular_*_context15: Input/output error

ofonod[5355]: gprs-context.c(244):at_gprs_activate_primary() cid 1 ofonod[5355]: gprs.c(889):pri_activate_callback() 0x1a18c50 ofonod[5355]: gprs.c(893):pri_activate_callback() Activating context failed with error: Unknown error type
connmand[3815]: Failed to change property: /he910_0/context15 org.ofono.ConnectionContext.Active: org.ofono.Error.Failed Operation failed

The same error happens if I am manually sending connect/disconnect via dbus-send.

Only a hard ofono restart can establish the connection again. This behavior happens all the time once a ppp0 disconnect happened (e.g. by removing the SIM; manual disconnect via dbus or connmanctl).

A subquestion regarding connman:
Can connmand be configured in such a way that on every connection loss, ofono is triggered to reconnect to the Internet?

Thank you very muchin advance,
Marko
_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#2 lore raw

Am 2015-06-25 um 15:05 schrieb Marko Sulejic:

Quoted 85 lines

Hi again,

the problem seems to be in the
atmodem/gprs-context.c : gprs_activate_primary
function, where

    if (g_at_chat_send(gcd->chat, buf, none_prefix,
                at_cgdcont_cb, gc, NULL) > 0)

is called after a reconnect, and then it fails.

It seems to work if I call

g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
NULL, NULL, NULL)

prior.

So this would mean that a disconnect or similar action sets DCD to low, and the chats are closed.

Does oFono anywhere in the code sets DCD explicitely to low or is it maybe a bug?

My patch would look something like this (if it is an HE910 issue only):

    if (gcd->vendor == OFONO_VENDOR_TELIT)
    {
        if(g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
                    NULL, NULL, NULL) <= 0)
            goto error;
    }

Thanks,
Marko

Am 2015-06-25 um 11:15 schrieb Marko Sulejic:

Quoted 38 lines

Hi,

I need your help in using a Telit HE910 with ofono (and eventually connman).
(I am using ofono 1.16 with HE910 firmware version 12.00.006; connman version is 1.29).

My problem is the following ...
on startup everything works fine and the ppp0 connection is established, but problems occur in the following case:

connmanctl> disconnect cellular_*_context15
Disconnected cellular_*_context15

connmanctl> connect cellular_*_context15
Error /net/connman/service/cellular_*_context15: Input/output error

ofonod[5355]: gprs-context.c(244):at_gprs_activate_primary() cid 1 ofonod[5355]: gprs.c(889):pri_activate_callback() 0x1a18c50 ofonod[5355]: gprs.c(893):pri_activate_callback() Activating context failed with error: Unknown error type
connmand[3815]: Failed to change property: /he910_0/context15 org.ofono.ConnectionContext.Active: org.ofono.Error.Failed Operation failed

The same error happens if I am manually sending connect/disconnect via dbus-send.

Only a hard ofono restart can establish the connection again. This behavior happens all the time once a ppp0 disconnect happened (e.g. by removing the SIM; manual disconnect via dbus or connmanctl).

A subquestion regarding connman:
Can connmand be configured in such a way that on every connection loss, ofono is triggered to reconnect to the Internet?

Quoted 6 lines

Thank you very muchin advance,
Marko
_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Quoted 4 lines

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Hi,

ok, the above code doesn't seem to solve the problem.

Regards,
Marko

#3 lore raw

Hi Marko,
I had a similar problem with HE910 and I solved with the following code line immediatly after line 99 in he910.c plugin:

99| g_hash_table_insert(options, "Baud", "115200"); 100| *g_hash_table_insert(options, "Local", "on");*

Let me know if it helps.

Enrico

2015-06-29 13:16 GMT+02:00 Marko Sulejic <[email protected]>:

Quoted 113 lines

Am 2015-06-25 um 15:05 schrieb Marko Sulejic:

Quoted 86 lines

Hi again,

the problem seems to be in the
atmodem/gprs-context.c : gprs_activate_primary
function, where

    if (g_at_chat_send(gcd->chat, buf, none_prefix,
                at_cgdcont_cb, gc, NULL) > 0)

is called after a reconnect, and then it fails.

It seems to work if I call

g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
NULL, NULL, NULL)

prior.

So this would mean that a disconnect or similar action sets DCD to low, and the chats are closed.

Does oFono anywhere in the code sets DCD explicitely to low or is it maybe a bug?

My patch would look something like this (if it is an HE910 issue only):

    if (gcd->vendor == OFONO_VENDOR_TELIT)
    {
        if(g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
                    NULL, NULL, NULL) <= 0)
            goto error;
    }

Thanks,
Marko

Am 2015-06-25 um 11:15 schrieb Marko Sulejic:

Quoted 37 lines

Hi,

I need your help in using a Telit HE910 with ofono (and eventually connman).
(I am using ofono 1.16 with HE910 firmware version 12.00.006; connman version is 1.29).

My problem is the following ...
on startup everything works fine and the ppp0 connection is established, but problems occur in the following case:

connmanctl> disconnect cellular_*_context15
Disconnected cellular_*_context15

connmanctl> connect cellular_*_context15
Error /net/connman/service/cellular_*_context15: Input/output error

ofonod[5355]: gprs-context.c(244):at_gprs_activate_primary() cid 1 ofonod[5355]: gprs.c(889):pri_activate_callback() 0x1a18c50 ofonod[5355]: gprs.c(893):pri_activate_callback() Activating context failed with error: Unknown error type
connmand[3815]: Failed to change property: /he910_0/context15 org.ofono.ConnectionContext.Active: org.ofono.Error.Failed Operation failed

The same error happens if I am manually sending connect/disconnect via dbus-send.

Only a hard ofono restart can establish the connection again. This behavior happens all the time once a ppp0 disconnect happened (e.g. by removing the SIM; manual disconnect via dbus or connmanctl).

A subquestion regarding connman:
Can connmand be configured in such a way that on every connection loss, ofono is triggered to reconnect to the Internet?

Quoted 7 lines

Thank you very muchin advance,
Marko
_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Quoted 5 lines

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Hi,

ok, the above code doesn't seem to solve the problem.

Regards,

Marko

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#4 lore raw

Hi Enrico!

Am 2015-06-29 um 14:59 schrieb Enrico Sau:

Quoted 4 lines

Hi Marko,
I had a similar problem with HE910 and I solved with the following code line immediatly after line 99 in he910.c plugin:

Quoted 8 lines

99| g_hash_table_insert(options, "Baud", "115200"); 100| *g_hash_table_insert(options, "Local", "on");*

Let me know if it helps.

Enrico

Thanks for the answer, but unfortunately it didn't help me.

I figured out that the *at_cgdcont_cb() *callback is not called on reconnect:

_The correct log_ (on startup):

Jun 29 15:16:38 mx31tt01 daemon.warn connmand[561]: Skipping disconnect 
of /he910_0/context15, network is connecting.
Jun 29 15:16:38 mx31tt01 daemon.debug ofonod[657]: 
gprs-context.c(240):at_gprs_activate_primary() cid 1
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: > 
AT+CGDCONT=1,"IP","web.one.at"\r
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: < 
AT+CGDCONT=1,"IP","web.one.at"\r
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: < \r\nOK\r\n
Jun 29 15:16:38 mx31tt01 daemon.debug ofonod[657]: 
gprs-context.c(200):*at_cgdcont_cb()* ok 1
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: > 
AT+CGDATA="PPP",1\r
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: < 
AT+CGDATA="PPP",1\r
Jun 29 15:16:38 mx31tt01 daemon.info ofonod[657]: Modem: < \r\nCONNECT\r\n
Jun 29 15:16:38 mx31tt01 daemon.debug ofonod[657]: 
gprs-context.c(176):*at_cgdata_cb()* ok 1
Jun 29 15:16:38 mx31tt01 daemon.debug ofonod[657]: 

gprs-context.c(141):setup_ppp()

_And the fail log _(on reconnect):

Jun 29 15:19:34 mx31tt01 daemon.debug ofonod[657]: 
gprs-context.c(240):at_gprs_activate_primary() cid 1
Jun 29 15:19:34 mx31tt01 daemon.info ofonod[657]: Modem: > 

AT+CGDCONT=1,"IP","web.one.at"\r
...

Jun 29 15:20:14 mx31tt01 daemon.err connmand[561]: Failed to change 
property: /he910_0/context15 org.ofono.ConnectionContext.Active: 
org.freedesktop.DBus.Error.NoReply Did not receive a reply. Possible 
causes include: the remote application did not send a reply, the mess
Jun 29 15:21:25 mx31tt01 daemon.warn connmand[561]: Skipping disconnect 
of /he910_0/context15, network is connecting.
Jun 29 15:21:25 mx31tt01 daemon.err connmand[561]: Failed to change 

property: /he910_0/context15 org.ofono.ConnectionContext.Active:
org.ofono.Error.InProgress Operation already in progress

Any idea what could cause this?

Regards,
Marko

Quoted 133 lines

2015-06-29 13:16 GMT+02:00 Marko Sulejic <[email protected] <mailto:[email protected]>>:

Am 2015-06-25 um 15:05 schrieb Marko Sulejic:

Hi again,

the problem seems to be in the atmodem/gprs-context.c : gprs_activate_primary function, where

if (g_at_chat_send(gcd->chat, buf, none_prefix,
at_cgdcont_cb, gc, NULL) > 0)

is called after a reconnect, and then it fails.

It seems to work if I call

g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
NULL, NULL, NULL)

prior.

So this would mean that a disconnect or similar action sets DCD to low,
and the chats are closed.

Does oFono anywhere in the code sets DCD explicitely to low or is it maybe a bug?

My patch would look something like this (if it is an HE910 issue only):

if (gcd->vendor == OFONO_VENDOR_TELIT)
{
if(g_at_chat_send(gcd->chat, "AT&C0", none_prefix,
NULL, NULL, NULL) <= 0)
goto error;
}

Thanks,
Marko

Am 2015-06-25 um 11:15 schrieb Marko Sulejic:

Hi,

I need your help in using a Telit HE910 with ofono (and eventually connman).
(I am using ofono 1.16 with HE910 firmware version 12.00.006; connman version is 1.29).

My problem is the following ...
on startup everything works fine and the ppp0 connection is established,
but problems occur in the following case:

connmanctl> disconnect cellular_*_context15 Disconnected cellular_*_context15

connmanctl> connect cellular_*_context15 Error /net/connman/service/cellular_*_context15:
Input/output error

ofonod[5355]:
gprs-context.c(244):at_gprs_activate_primary() cid 1 ofonod[5355]: gprs.c(889):pri_activate_callback() 0x1a18c50 ofonod[5355]: gprs.c(893):pri_activate_callback() Activating context failed with error: Unknown error type connmand[3815]: Failed to change property:
/he910_0/context15 org.ofono.ConnectionContext.Active:
org.ofono.Error.Failed Operation failed

The same error happens if I am manually sending connect/disconnect via dbus-send.

Only a hard ofono restart can establish the connection again. This behavior happens all the time once a ppp0 disconnect happened
(e.g. by removing the SIM; manual disconnect via dbus or connmanctl).

A subquestion regarding connman:
Can connmand be configured in such a way that on every connection
loss, ofono is triggered to reconnect to the Internet?

Thank you very muchin advance, Marko
_______________________________________________
ofono mailing list ofono(a)ofono.org <mailto:[email protected]>
https://lists.ofono.org/mailman/listinfo/ofono

_______________________________________________
ofono mailing list ofono(a)ofono.org <mailto:[email protected]>
https://lists.ofono.org/mailman/listinfo/ofono

Hi,

ok, the above code doesn't seem to solve the problem.

Regards,

Marko

_______________________________________________
ofono mailing list
ofono(a)ofono.org <mailto:[email protected]>
https://lists.ofono.org/mailman/listinfo/ofono

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#5 lore raw

Hi Marko,

Quoted 7 lines

_And the fail log _(on reconnect):

Jun 29 15:19:34 mx31tt01 daemon.debug ofonod[657]:
gprs-context.c(240):at_gprs_activate_primary() cid 1
Jun 29 15:19:34 mx31tt01 daemon.info ofonod[657]: Modem: >

AT+CGDCONT=1,"IP","web.one.at"\r

Your modem is not responding to this AT command. There's not much that can be done on the oFono side. You need to figure out why the modem is acting this way.

Quoted 5 lines

...

Jun 29 15:20:14 mx31tt01 daemon.err connmand[561]: Failed to change

property: /he910_0/context15 org.ofono.ConnectionContext.Active:
org.freedesktop.DBus.Error.NoReply Did not receive a reply. Possible

Regards,
-Denis

#6 lore raw

Am 2015-06-26 um 04:20 schrieb Denis Kenzior:

Quoted 5 lines

Hi Marko,

Quoted 3 lines

_And the fail log _(on reconnect):

Quoted 9 lines
Quoted 4 lines
Jun 29 15:19:34 mx31tt01 daemon.debug ofonod[657]:
gprs-context.c(240):at_gprs_activate_primary() cid 1
Jun 29 15:19:34 mx31tt01 daemon.info ofonod[657]: Modem: >

AT+CGDCONT=1,"IP","web.one.at"\r

Your modem is not responding to this AT command. There's not much that can be done on the oFono side. You need to figure out why the modem is acting this way.

Hi Denis,

thank you for the answer. If I can figure out the error, and can solve the problem, I will let you know.

Quoted 8 lines
Quoted 5 lines

Jun 29 15:20:14 mx31tt01 daemon.err connmand[561]: Failed to change

property: /he910_0/context15 org.ofono.ConnectionContext.Active:
org.freedesktop.DBus.Error.NoReply Did not receive a reply. Possible

Regards,
-Denis

Regards,
Marko

#7 lore raw

Am 2015-06-30 um 07:54 schrieb Marko Sulejic:

Quoted 16 lines

Am 2015-06-26 um 04:20 schrieb Denis Kenzior:

Quoted 5 lines

Hi Marko,

Quoted 3 lines

_And the fail log _(on reconnect):

Quoted 9 lines
Quoted 4 lines
Jun 29 15:19:34 mx31tt01 daemon.debug ofonod[657]:
gprs-context.c(240):at_gprs_activate_primary() cid 1
Jun 29 15:19:34 mx31tt01 daemon.info ofonod[657]: Modem: >

AT+CGDCONT=1,"IP","web.one.at"\r

Your modem is not responding to this AT command. There's not much that can be done on the oFono side. You need to figure out why the modem is acting this way.

Quoted 5 lines

Hi Denis,

thank you for the answer. If I can figure out the error, and can solve the problem, I will let you know.

Hi Denis,

we figured out the problem:

At the end of a PPP connection, garbage was passed in to the AT command parser on the modem chat.
This garbage contained a doublequote, which switched the AT syntax parser into string mode.
However, because no second doublequote arrived, it stayed in this mode, and kept returning UNSURE result.

I think this is an major issue that should be fixed in oFono. The syntax parser has to be extended to handle such cases.

Regards,
Marko

#8 lore raw

Hi Marko,

Quoted 3 lines

At the end of a PPP connection, garbage was passed in to the AT command parser on the modem chat.

Well, the modem should not be passing in garbage in the first place :)

Quoted 5 lines

This garbage contained a doublequote, which switched the AT syntax parser into string mode.
However, because no second doublequote arrived, it stayed in this mode, and kept returning UNSURE result.

Do you have a trace/hexdump of what is passed on to the GAtChat object?

Quoted 3 lines

I think this is an major issue that should be fixed in oFono. The syntax parser has to be extended to handle such cases.

Any suggestions on how oFono should detect this condition?

Regards,
-Denis

#9 lore raw

Marko, let me ask a maybe stupid question: do you have modemmanager package installed?

Enrico

#10 lore raw

Hi Enrico,

we don't have such a package installed.

We have found the problem ...
have a look at my response on Denis' mail.

Regards,
Marko

Am 2015-06-30 um 17:16 schrieb Enrico Sau:

Quoted 10 lines

Marko, let me ask a maybe stupid question: do you have modemmanager package installed?

Enrico

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#11 lore raw
In reply to Denis Kenzior

Am 2015-06-27 um 01:01 schrieb Denis Kenzior:

Quoted 1 line

Hi Marko,

Hi Denis,

Quoted 6 lines
Quoted 4 lines

At the end of a PPP connection, garbage was passed in to the AT command parser on the modem chat.

Well, the modem should not be passing in garbage in the first place :)

Yeah, but it unfortunately does so :)

Quoted 8 lines
Quoted 6 lines

This garbage contained a doublequote, which switched the AT syntax parser into string mode.
However, because no second doublequote arrived, it stayed in this mode, and kept returning UNSURE result.

Do you have a trace/hexdump of what is passed on to the GAtChat object?

Before receiving the "NO CARRIER" signal,
the modem leaves the data mode
and enters the chat mode (apparently too early).

In my log you can see that it gets some leftovers of a PPP package,including an opening double quote
... but it never gets the closing one, and therefore
oFono is not responding any more.

Here is the log:
(the modem has already established a data connection, and I pull out the SIM card of its slot)

ofonod[2816]: modem.c(501):modem_change_state() old state: 3, new state: 1 ofonod[2816]: modem.c(414):flush_atoms()
ofonod[2816]: push-notification.c(166):push_notification_cleanup() 0x5519f8 ofonod[2816]: smart-messaging.c(291):smart_messaging_cleanup() 0x551e78 ofonod[2816]: network.c(1173):__ofono_netreg_remove_status_watch() 0x551178 ofonod[2816]: sms.c(1719):sms_remove() atom: 0x55a278 ofonod[2816]: phonebook.c(527):phonebook_remove() atom: 0x557000 ofonod[2816]: gprs.c(2279):gprs_context_unregister() 0x54f3c0, 0x54f290 ofonod[2816]: gprs.c(2413):gprs_context_remove() atom: 0x54f3e0 ofonod[2816]: gprs-context.c(422):at_gprs_context_remove()
kernel: [ 1711.579055] PM: Removing info for No Bus:ppp0 ofonod[2816]: gprs.c(2644):gprs_unregister() 0x54f290 ofonod[2816]: network.c(1173):__ofono_netreg_remove_status_watch() 0x551178 ofonod[2816]: gprs.c(2683):gprs_remove() atom: 0x54f2f8 ofonod[2816]: message-waiting.c(1088):mw_remove() atom: 0x54edf8 ofonod[2816]: call-barring.c(1039):call_barring_remove() atom: 0x54eb60 ofonod[2816]: call-meter.c(718):call_meter_remove() atom: 0x54d398 ofonod[2816]: call-settings.c(1393):call_settings_remove() atom: 0x54d2d8 ofonod[2816]: call-forwarding.c(1465):call_forwarding_remove() atom:
0x54d200
ofonod[2816]: ussd.c(811):ussd_remove() atom: 0x5511e0 ofonod[2816]: sim.c(2720):ofono_sim_remove_spn_watch() 0x52dd10 ofonod[2816]: network.c(1836):netreg_remove() atom: 0x550f70 ofonod[2816]: voicecall.c(2787):voicecall_remove() atom: 0x52bf80 ofonod[2816]: udevng.c(979):remove_device() /sys/devices/virtual/net/ppp0 ofonod[2816]: udev.c(428):udev_event() subsystem net remove ofonod[2816]: udev.c(337):remove_modem() /devices/virtual/net/ppp0 ofonod[2816]: udev.c(442):udev_event() subsystem net finished ofonod[2816]: Aux: < \r\n
ofonod[2816]: Aux: < +CGEV: NW DEACT IP, "10.183.107.173", 1\r\n ofonod[2816]: Modem: < ~\377}#\300!}%}"} }$Y(~
ofonod[2816]: Modem: < \r\nNO CARRIER\r\n

Quoted 6 lines
Quoted 4 lines

I think this is an major issue that should be fixed in oFono. The syntax parser has to be extended to handle such cases.

Any suggestions on how oFono should detect this condition?

Here is our "quick" solution to this problem.

gatchat.c (a3cb2b2) renamed from gatchat.c (f83233d) +2 -0
@@ -957,6 +957,11 @@
      g_at_io_set_debug(chat->io, chat->debugf, chat->debug_data);
      g_at_io_set_read_handler(chat->io, new_bytes, chat);
 
+    /* Prevent garbage that arrives from the late data connection to
+     * switch the AT syntax parser to string mode (when it contains a 

doublequote) */
+ if (chat->syntax->set_hint)
+ chat->syntax->set_hint(chat->syntax, G_AT_SYNTAX_EXPECT_GARBAGE);
+

      if (g_queue_get_length(chat->command_queue) > 0)
          chat_wakeup_writer(chat);

}

gatsyntax.c (a3cb2b2) renamed from gatsyntax.c (359f790) +19 -0
@@ -57,6 +57,8 @@
      GSM_PERMISSIVE_STATE_PROMPT,
      GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT,
      GSM_PERMISSIVE_STATE_SHORT_PROMPT,
+    GSM_PERMISSIVE_STATE_GUESS_GARBAGE,
+    GSM_PERMISSIVE_STATE_GARBAGE,
  };
 
  static void gsmv1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint)
@@ -270,6 +272,8 @@
          syntax->state = GSM_PERMISSIVE_STATE_GUESS_PDU;
      else if (hint == G_AT_SYNTAX_EXPECT_SHORT_PROMPT)
          syntax->state = GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT;
+    else if (hint == G_AT_SYNTAX_EXPECT_GARBAGE)
+        syntax->state = GSM_PERMISSIVE_STATE_GUESS_GARBAGE;
  }
 
  static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax,
@@ -358,6 +362,21 @@
              syntax->state = GSM_PERMISSIVE_STATE_RESPONSE;
              return G_AT_SYNTAX_RESULT_UNSURE;
 
+        case GSM_PERMISSIVE_STATE_GUESS_GARBAGE:
+            if (byte != '\r' && byte != '\n')
+                syntax->state = GSM_PERMISSIVE_STATE_GARBAGE;
+            break;
+
+        case GSM_PERMISSIVE_STATE_GARBAGE:
+            if (byte == '\r') {
+                syntax->state = GSM_PERMISSIVE_STATE_IDLE;
+
+                i += 1;
+                res = G_AT_SYNTAX_RESULT_GARBAGE;
+                goto out;
+            }
+            break;
+
          default:
              break;
          };
gatsyntax.h (a3cb2b2) renamed from gatsyntax.h (21f9da9) +3 -1
@@ -30,7 +30,8 @@
      G_AT_SYNTAX_EXPECT_PDU,
      G_AT_SYNTAX_EXPECT_MULTILINE,
      G_AT_SYNTAX_EXPECT_PROMPT,
-    G_AT_SYNTAX_EXPECT_SHORT_PROMPT
+    G_AT_SYNTAX_EXPECT_SHORT_PROMPT,
+    G_AT_SYNTAX_EXPECT_GARBAGE,
  };
 
  typedef enum _GAtSyntaxExpectHint GAtSyntaxExpectHint;
@@ -42,6 +43,7 @@
      G_AT_SYNTAX_RESULT_MULTILINE,
      G_AT_SYNTAX_RESULT_PDU,
      G_AT_SYNTAX_RESULT_PROMPT,
+    G_AT_SYNTAX_RESULT_GARBAGE,
  };
 
  typedef enum _GAtSyntaxResult GAtSyntaxResult;

Our opinion is that the modem should only switch its mode once it really received the NO CARRIER signal (or something in this manner).

But it's up to you to find the best solution :)

Quoted 3 lines

Regards,
-Denis

Regards,
Marko

P.S. We would also like to post a patch regarding oFono. How can we do this?

Quoted 4 lines

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#12 lore raw

Hi Marko,

Quoted 5 lines

Before receiving the "NO CARRIER" signal,
the modem leaves the data mode
and enters the chat mode (apparently too early).

Quoted 8 lines

In my log you can see that it gets some leftovers of a PPP package,including an opening double quote
... but it never gets the closing one, and therefore
oFono is not responding any more.

Here is the log:
(the modem has already established a data connection, and I pull out the SIM card of its slot)

Aha. Now I understand. You're removing the SIM card, which triggers at_gprs_context_remove. And the modem firmware is not smart enough to send the final HDLC frame prior to sending us the SIM removed event.

Quoted 2 lines

ofonod[2816]: Modem: < ~\377}#\300!}%}"} }$Y(~ ofonod[2816]: Modem: < \r\nNO CARRIER\r\n

And indeed, we switch out of HDLC mode too early in this case.

Quoted 94 lines
Quoted 8 lines
Quoted 6 lines

I think this is an major issue that should be fixed in oFono. The syntax parser has to be extended to handle such cases.

Any suggestions on how oFono should detect this condition?

Here is our "quick" solution to this problem.

gatchat.c (a3cb2b2) renamed from gatchat.c (f83233d) +2 -0
@@ -957,6 +957,11 @@
      g_at_io_set_debug(chat->io, chat->debugf, chat->debug_data);
      g_at_io_set_read_handler(chat->io, new_bytes, chat);
 
+    /* Prevent garbage that arrives from the late data connection to
+     * switch the AT syntax parser to string mode (when it contains a

doublequote) */

gatchat.c (a3cb2b2) renamed from gatchat.c (f83233d) +3 -0
+    if (chat->syntax->set_hint)
+        chat->syntax->set_hint(chat->syntax, G_AT_SYNTAX_EXPECT_GARBAGE);
+
      if (g_queue_get_length(chat->command_queue) > 0)
          chat_wakeup_writer(chat);
  }
gatsyntax.c (a3cb2b2) renamed from gatsyntax.c (359f790) +19 -0
@@ -57,6 +57,8 @@
      GSM_PERMISSIVE_STATE_PROMPT,
      GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT,
      GSM_PERMISSIVE_STATE_SHORT_PROMPT,
+    GSM_PERMISSIVE_STATE_GUESS_GARBAGE,
+    GSM_PERMISSIVE_STATE_GARBAGE,
  };
 
  static void gsmv1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint)
@@ -270,6 +272,8 @@
          syntax->state = GSM_PERMISSIVE_STATE_GUESS_PDU;
      else if (hint == G_AT_SYNTAX_EXPECT_SHORT_PROMPT)
          syntax->state = GSM_PERMISSIVE_STATE_GUESS_SHORT_PROMPT;
+    else if (hint == G_AT_SYNTAX_EXPECT_GARBAGE)
+        syntax->state = GSM_PERMISSIVE_STATE_GUESS_GARBAGE;
  }
 
  static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax,
@@ -358,6 +362,21 @@
              syntax->state = GSM_PERMISSIVE_STATE_RESPONSE;
              return G_AT_SYNTAX_RESULT_UNSURE;
 
+        case GSM_PERMISSIVE_STATE_GUESS_GARBAGE:
+            if (byte != '\r' && byte != '\n')
+                syntax->state = GSM_PERMISSIVE_STATE_GARBAGE;
+            break;
+
+        case GSM_PERMISSIVE_STATE_GARBAGE:
+            if (byte == '\r') {
+                syntax->state = GSM_PERMISSIVE_STATE_IDLE;
+
+                i += 1;
+                res = G_AT_SYNTAX_RESULT_GARBAGE;
+                goto out;
+            }
+            break;
+
          default:
              break;
          };
gatsyntax.h (a3cb2b2) renamed from gatsyntax.h (21f9da9) +3 -1
@@ -30,7 +30,8 @@
      G_AT_SYNTAX_EXPECT_PDU,
      G_AT_SYNTAX_EXPECT_MULTILINE,
      G_AT_SYNTAX_EXPECT_PROMPT,
-    G_AT_SYNTAX_EXPECT_SHORT_PROMPT
+    G_AT_SYNTAX_EXPECT_SHORT_PROMPT,
+    G_AT_SYNTAX_EXPECT_GARBAGE,
  };
 
  typedef enum _GAtSyntaxExpectHint GAtSyntaxExpectHint;
@@ -42,6 +43,7 @@
      G_AT_SYNTAX_RESULT_MULTILINE,
      G_AT_SYNTAX_RESULT_PDU,
      G_AT_SYNTAX_RESULT_PROMPT,
+    G_AT_SYNTAX_RESULT_GARBAGE,
  };
 
  typedef enum _GAtSyntaxResult GAtSyntaxResult;
Quoted 4 lines

Our opinion is that the modem should only switch its mode once it really received the NO CARRIER signal (or something in this manner).

Correct. However, we currently expect all atom drivers to cleanup immediately (e.g. at_gprs_context_remove), so doing this cleanly is tricky.

Quoted 3 lines

P.S. We would also like to post a patch regarding oFono. How can we do this?

git send-email.

Regards,
-Denis