Skip to content
Snippets Groups Projects
Commit 55101029 authored by rswindell's avatar rswindell
Browse files

Retry hangup, default is up to 10 attempts before giving up

HangupAttempts is configurable in the [com] section of the sexpots.ini file.
parent 0f7e9a7e
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ ulong com_baudrate=0;
BOOL dcd_ignore=FALSE;
int dcd_timeout=10; /* seconds */
ulong dtr_delay=100; /* milliseconds */
int hangup_attempts=10;
BOOL terminated=FALSE;
BOOL terminate_after_one_call=FALSE;
......@@ -1256,24 +1257,29 @@ BOOL handle_call(void)
BOOL hangup_call(COM_HANDLE com_handle)
{
time_t start;
int attempt;
if((comGetModemStatus(com_handle)&COM_DCD)==0) /* DCD already low */
return TRUE;
lprintf(LOG_DEBUG,"Waiting for transmit buffer to empty");
SLEEP(dtr_delay);
lprintf(LOG_INFO,"Dropping DTR");
if(!comLowerDTR(com_handle))
return FALSE;
lprintf(LOG_INFO,"Waiting for loss of Carrier Detect (DCD)");
start=time(NULL);
while(time(NULL)-start <= dcd_timeout) {
if((comGetModemStatus(com_handle)&COM_DCD) == 0)
return TRUE;
SLEEP(1000);
for(attempt=0; attempt<hangup_attempts; attempt++) {
lprintf(LOG_INFO,"Dropping DTR (attempt #%d)", attempt+1);
if(!comLowerDTR(com_handle)) {
lprintf(LOG_ERR,"ERROR %u lowering DTR", COM_ERROR);
continue;
}
lprintf(LOG_INFO,"Waiting for loss of Carrier Detect (DCD)");
start=time(NULL);
while(time(NULL)-start <= dcd_timeout) {
if((comGetModemStatus(com_handle)&COM_DCD)==0)
return TRUE;
SLEEP(1000);
}
lprintf(LOG_ERR,"TIMEOUT waiting for DCD to drop (attempt #%d of %d)"
, attempt+1, hangup_attempts);
}
lprintf(LOG_ERR,"TIMEOUT waiting for DCD to drop");
return FALSE;
}
......@@ -1318,6 +1324,7 @@ void parse_ini_file(const char* ini_fname)
iniGetExistingString(list, section, "Device", NULL, com_dev);
com_baudrate = iniGetLongInt(list, section, "BaudRate", com_baudrate);
com_hangup = iniGetBool(list, section, "Hangup", com_hangup);
hangup_attempts = iniGetInteger(list, section, "HangupAttempts", hangup_attempts);
dcd_timeout = iniGetInteger(list, section, "DCDTimeout", dcd_timeout);
dcd_ignore = iniGetBool(list, section, "IgnoreDCD", dcd_ignore);
dtr_delay = iniGetLongInt(list, section, "DTRDelay", dtr_delay);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment