mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-29 15:22:20 +02:00
at: clear command queue before configuring modem
In some cases, there might be an issue with `eg25-manager` trying to reset the modem while it's being configured. This leads to infinite boot loops where the modem is constantly reset soon after it booted. Fixes #24
This commit is contained in:
33
src/at.c
33
src/at.c
@@ -47,6 +47,21 @@ static int configure_serial(const char *tty)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void at_free_command(struct AtCommand *at_cmd, struct EG25Manager *manager)
|
||||||
|
{
|
||||||
|
if (!at_cmd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free(at_cmd->cmd);
|
||||||
|
g_free(at_cmd->subcmd);
|
||||||
|
g_free(at_cmd->value);
|
||||||
|
g_free(at_cmd->expected);
|
||||||
|
g_free(at_cmd);
|
||||||
|
|
||||||
|
if (manager && manager->at_cmds)
|
||||||
|
manager->at_cmds = g_list_remove(manager->at_cmds, at_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean at_send_command(struct EG25Manager *manager)
|
gboolean at_send_command(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
char command[256];
|
char command[256];
|
||||||
@@ -139,16 +154,7 @@ void at_next_command(struct EG25Manager *manager)
|
|||||||
{
|
{
|
||||||
struct AtCommand *at_cmd = manager->at_cmds ? g_list_nth_data(manager->at_cmds, 0) : NULL;
|
struct AtCommand *at_cmd = manager->at_cmds ? g_list_nth_data(manager->at_cmds, 0) : NULL;
|
||||||
|
|
||||||
if (!at_cmd)
|
at_free_command(at_cmd, manager);
|
||||||
return;
|
|
||||||
|
|
||||||
g_free(at_cmd->cmd);
|
|
||||||
g_free(at_cmd->subcmd);
|
|
||||||
g_free(at_cmd->value);
|
|
||||||
g_free(at_cmd->expected);
|
|
||||||
g_free(at_cmd);
|
|
||||||
manager->at_cmds = g_list_remove(manager->at_cmds, at_cmd);
|
|
||||||
|
|
||||||
at_send_command(manager);
|
at_send_command(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,6 +394,13 @@ void at_destroy(struct EG25Manager *manager)
|
|||||||
|
|
||||||
void at_sequence_configure(struct EG25Manager *manager)
|
void at_sequence_configure(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* When configuring a new modem we should avoid processing an old
|
||||||
|
* command queue, so let's first clear the whole list
|
||||||
|
*/
|
||||||
|
if (manager->at_cmds)
|
||||||
|
g_list_foreach(manager->at_cmds, at_free_command, manager);
|
||||||
|
|
||||||
for (guint i = 0; i < configure_commands->len; i++) {
|
for (guint i = 0; i < configure_commands->len; i++) {
|
||||||
struct AtCommand *cmd = &g_array_index(configure_commands, struct AtCommand, i);
|
struct AtCommand *cmd = &g_array_index(configure_commands, struct AtCommand, i);
|
||||||
at_append_command(manager, cmd->cmd, cmd->subcmd, cmd->value, cmd->expected, at_process_result);
|
at_append_command(manager, cmd->cmd, cmd->subcmd, cmd->value, cmd->expected, at_process_result);
|
||||||
|
Reference in New Issue
Block a user