From 395ad3001a95a06d78a96a4b923f7979133a518e Mon Sep 17 00:00:00 2001 From: Chris Osborn Date: Thu, 26 May 2016 08:46:59 -0700 Subject: [PATCH] Added names for S registers. --- src/bridge.c | 2 +- src/modem_core.c | 36 ++++++++++++++++++------------------ src/modem_core.h | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/bridge.c b/src/bridge.c index 1f3c999..0ee0103 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -340,7 +340,7 @@ void *run_bridge(void *arg) if (cfg->pre_break_delay == FALSE || cfg->break_len == 3) { LOG(LOG_ALL, "Setting timer for break delay"); timer.tv_sec = 0; - timer.tv_usec = cfg->s[12] * 20000; + timer.tv_usec = cfg->s[SRegisterGuardTime] * 20000; ptimer = &timer; } else if (cfg->pre_break_delay == TRUE && cfg->break_len > 0) { diff --git a/src/modem_core.c b/src/modem_core.c index 015558d..bb8234d 100644 --- a/src/modem_core.c +++ b/src/modem_core.c @@ -80,20 +80,20 @@ void mdm_init_config(modem_config *cfg) for (i = 0; i < 100; i++) { cfg->s[i] = 0; } - cfg->s[2] = 43; - cfg->s[3] = 13; - cfg->s[4] = 10; - cfg->s[5] = 8; - cfg->s[6] = 2; - cfg->s[7] = 50; - cfg->s[8] = 2; - cfg->s[9] = 6; - cfg->s[10] = 14; - cfg->s[11] = 95; - cfg->s[12] = 50; + cfg->s[SRegisterBreak] = 43; + cfg->s[SRegisterCR] = 13; + cfg->s[SRegisterLF] = 10; + cfg->s[SRegisterBackspace] = 8; + cfg->s[SRegisterBlindWait] = 2; + cfg->s[SRegisterCarrierWait] = 50; + cfg->s[SRegisterCommaPause] = 2; + cfg->s[SRegisterCarrierTime] = 6; + cfg->s[SRegisterCarrierLoss] = 14; + cfg->s[SRegisterDTMFTime] = 95; + cfg->s[SRegisterGuardTime] = 50; - cfg->crlf[0] = cfg->s[3]; - cfg->crlf[1] = cfg->s[4]; + cfg->crlf[0] = cfg->s[SRegisterCR]; + cfg->crlf[1] = cfg->s[SRegisterLF]; cfg->crlf[2] = 0; cfg->dial_type = 0; @@ -466,10 +466,10 @@ int mdm_parse_cmd(modem_config *cfg) cfg->s[num] = atoi(tmp); switch (num) { case 3: - cfg->crlf[0] = cfg->s[3]; + cfg->crlf[0] = cfg->s[SRegisterCR]; break; case 4: - cfg->crlf[1] = cfg->s[4]; + cfg->crlf[1] = cfg->s[SRegisterLF]; break; } break; @@ -572,7 +572,7 @@ int mdm_handle_char(modem_config *cfg, char ch) if (cfg->echo == TRUE) mdm_write_char(cfg, (ch | parbit)); if (cfg->cmd_started == TRUE) { - if (ch == (char) (cfg->s[5])) { + if (ch == (char) (cfg->s[SRegisterBackspace])) { if (cfg->cur_line_idx == 0 && cfg->echo == TRUE) { mdm_write(cfg, "T", 1); } @@ -580,7 +580,7 @@ int mdm_handle_char(modem_config *cfg, char ch) cfg->cur_line_idx--; } } - else if (ch == (char) (cfg->s[3])) { + else if (ch == (char) (cfg->s[SRegisterCR])) { // we have a line, process. cfg->cur_line[cfg->cur_line_idx] = 0; strncpy(cfg->last_cmd, cfg->cur_line, sizeof(cfg->last_cmd) - 1); @@ -644,7 +644,7 @@ int mdm_parse_data(modem_config *cfg, char *data, int len) ch = data[i]; if (cfg->parity) ch &= 0x7f; - if (ch == (char) cfg->s[2]) { + if (ch == (char) cfg->s[SRegisterBreak]) { LOG(LOG_DEBUG, "Break character received"); cfg->break_len++; if (cfg->break_len > 3) { // more than 3, considered invalid diff --git a/src/modem_core.h b/src/modem_core.h index 21ee1e1..e3e2430 100644 --- a/src/modem_core.h +++ b/src/modem_core.h @@ -85,6 +85,20 @@ typedef struct dce_config { int ip232_iac; } dce_config; +enum { + SRegisterBreak = 2, + SRegisterCR = 3, + SRegisterLF = 4, + SRegisterBackspace = 5, + SRegisterBlindWait = 6, + SRegisterCarrierWait = 7, + SRegisterCommaPause = 8, + SRegisterCarrierTime = 9, + SRegisterCarrierLoss = 10, + SRegisterDTMFTime = 11, + SRegisterGuardTime = 12, +}; + typedef struct modem_config { // master configuration information