mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-29 23:32:14 +02:00
Merge branch 'wip/a-wai/clear-command-queue' into 'master'
at: clear command queue before configuring modem Closes #24 See merge request mobian1/devices/eg25-manager!34
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char command[256];
|
||||
@@ -137,16 +152,7 @@ void at_next_command(struct EG25Manager *manager)
|
||||
{
|
||||
struct AtCommand *at_cmd = manager->at_cmds ? g_list_nth_data(manager->at_cmds, 0) : NULL;
|
||||
|
||||
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);
|
||||
manager->at_cmds = g_list_remove(manager->at_cmds, at_cmd);
|
||||
|
||||
at_free_command(at_cmd, manager);
|
||||
at_send_command(manager);
|
||||
}
|
||||
|
||||
@@ -389,6 +395,13 @@ void at_destroy(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++) {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user