Added names for S registers.

This commit is contained in:
Chris Osborn 2016-05-26 08:46:59 -07:00
parent d4819e2435
commit 395ad3001a
3 changed files with 33 additions and 19 deletions

View File

@ -340,7 +340,7 @@ void *run_bridge(void *arg)
if (cfg->pre_break_delay == FALSE || cfg->break_len == 3) { if (cfg->pre_break_delay == FALSE || cfg->break_len == 3) {
LOG(LOG_ALL, "Setting timer for break delay"); LOG(LOG_ALL, "Setting timer for break delay");
timer.tv_sec = 0; timer.tv_sec = 0;
timer.tv_usec = cfg->s[12] * 20000; timer.tv_usec = cfg->s[SRegisterGuardTime] * 20000;
ptimer = &timer; ptimer = &timer;
} }
else if (cfg->pre_break_delay == TRUE && cfg->break_len > 0) { else if (cfg->pre_break_delay == TRUE && cfg->break_len > 0) {

View File

@ -80,20 +80,20 @@ void mdm_init_config(modem_config *cfg)
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
cfg->s[i] = 0; cfg->s[i] = 0;
} }
cfg->s[2] = 43; cfg->s[SRegisterBreak] = 43;
cfg->s[3] = 13; cfg->s[SRegisterCR] = 13;
cfg->s[4] = 10; cfg->s[SRegisterLF] = 10;
cfg->s[5] = 8; cfg->s[SRegisterBackspace] = 8;
cfg->s[6] = 2; cfg->s[SRegisterBlindWait] = 2;
cfg->s[7] = 50; cfg->s[SRegisterCarrierWait] = 50;
cfg->s[8] = 2; cfg->s[SRegisterCommaPause] = 2;
cfg->s[9] = 6; cfg->s[SRegisterCarrierTime] = 6;
cfg->s[10] = 14; cfg->s[SRegisterCarrierLoss] = 14;
cfg->s[11] = 95; cfg->s[SRegisterDTMFTime] = 95;
cfg->s[12] = 50; cfg->s[SRegisterGuardTime] = 50;
cfg->crlf[0] = cfg->s[3]; cfg->crlf[0] = cfg->s[SRegisterCR];
cfg->crlf[1] = cfg->s[4]; cfg->crlf[1] = cfg->s[SRegisterLF];
cfg->crlf[2] = 0; cfg->crlf[2] = 0;
cfg->dial_type = 0; cfg->dial_type = 0;
@ -466,10 +466,10 @@ int mdm_parse_cmd(modem_config *cfg)
cfg->s[num] = atoi(tmp); cfg->s[num] = atoi(tmp);
switch (num) { switch (num) {
case 3: case 3:
cfg->crlf[0] = cfg->s[3]; cfg->crlf[0] = cfg->s[SRegisterCR];
break; break;
case 4: case 4:
cfg->crlf[1] = cfg->s[4]; cfg->crlf[1] = cfg->s[SRegisterLF];
break; break;
} }
break; break;
@ -572,7 +572,7 @@ int mdm_handle_char(modem_config *cfg, char ch)
if (cfg->echo == TRUE) if (cfg->echo == TRUE)
mdm_write_char(cfg, (ch | parbit)); mdm_write_char(cfg, (ch | parbit));
if (cfg->cmd_started == TRUE) { 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) { if (cfg->cur_line_idx == 0 && cfg->echo == TRUE) {
mdm_write(cfg, "T", 1); mdm_write(cfg, "T", 1);
} }
@ -580,7 +580,7 @@ int mdm_handle_char(modem_config *cfg, char ch)
cfg->cur_line_idx--; cfg->cur_line_idx--;
} }
} }
else if (ch == (char) (cfg->s[3])) { else if (ch == (char) (cfg->s[SRegisterCR])) {
// we have a line, process. // we have a line, process.
cfg->cur_line[cfg->cur_line_idx] = 0; cfg->cur_line[cfg->cur_line_idx] = 0;
strncpy(cfg->last_cmd, cfg->cur_line, sizeof(cfg->last_cmd) - 1); 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]; ch = data[i];
if (cfg->parity) if (cfg->parity)
ch &= 0x7f; ch &= 0x7f;
if (ch == (char) cfg->s[2]) { if (ch == (char) cfg->s[SRegisterBreak]) {
LOG(LOG_DEBUG, "Break character received"); LOG(LOG_DEBUG, "Break character received");
cfg->break_len++; cfg->break_len++;
if (cfg->break_len > 3) { // more than 3, considered invalid if (cfg->break_len > 3) { // more than 3, considered invalid

View File

@ -85,6 +85,20 @@ typedef struct dce_config {
int ip232_iac; int ip232_iac;
} dce_config; } 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 { typedef struct modem_config {
// master configuration information // master configuration information