diff --git a/src/sexpots/sexpots.c b/src/sexpots/sexpots.c index 7415d7500699c8e939c30ea1599ade2a157cb082..8b7b232bea7c5b3d632d64ed3bf3fb720de8a650 100644 --- a/src/sexpots/sexpots.c +++ b/src/sexpots/sexpots.c @@ -675,7 +675,8 @@ BOOL modem_command(COM_HANDLE com_handle, const char* cmd) char resp[128]; if(!modem_send(com_handle, cmd)) { - lprintf(LOG_ERR,"ERROR %u sending modem command", COM_ERROR_VALUE); + lprintf(LOG_ERR,"ERROR %u sending modem command (%s)" + ,COM_ERROR_VALUE, cmd); return FALSE; } @@ -742,6 +743,7 @@ BOOL wait_for_call(COM_HANDLE com_handle) char* p; BOOL result=TRUE; DWORD events=0; + int mdm_status; ZERO_VAR(cid_name); ZERO_VAR(cid_number); @@ -806,7 +808,10 @@ BOOL wait_for_call(COM_HANDLE com_handle) } continue; /* don't check DCD until we've received all the modem msgs */ } - if(comGetModemStatus(com_handle)&COM_DCD) + if((mdm_status=comGetModemStatus(com_handle)) == COM_ERROR) + lprintf(LOG_ERR,"Error %u getting modem status (line %u)" + ,COM_ERROR_VALUE, __LINE__); + else if(mdm_status&COM_DCD) break; } @@ -1179,6 +1184,7 @@ BOOL handle_call(void) int result; int rd; int wr; + int mdm_status; fd_set socket_set; struct timeval tv = {0, 0}; @@ -1199,9 +1205,16 @@ BOOL handle_call(void) while(!terminated) { - if(!dcd_ignore && (comGetModemStatus(com_handle)&COM_DCD) == 0) { - lprintf(LOG_WARNING,"Loss of Carrier Detect (DCD) detected"); - break; + if(!dcd_ignore) { + if((mdm_status = comGetModemStatus(com_handle)) == COM_ERROR) { + lprintf(LOG_ERR,"Error %u getting modem status (line %u)" + ,COM_ERROR_VALUE, __LINE__); + break; + } + if((mdm_status&COM_DCD) == 0) { + lprintf(LOG_WARNING,"Loss of Carrier Detect (DCD) detected"); + break; + } } #if 0 if(comReadByte(com_handle, &ch)) { @@ -1256,10 +1269,16 @@ BOOL handle_call(void) /****************************************************************************/ BOOL hangup_call(COM_HANDLE com_handle) { - time_t start; + time_t start; int attempt; + int mdm_status; - if((comGetModemStatus(com_handle)&COM_DCD)==0) /* DCD already low */ + if((mdm_status=comGetModemStatus(com_handle)) == COM_ERROR) { + lprintf(LOG_ERR,"Error %u getting modem status (line %u)" + ,COM_ERROR_VALUE, __LINE__); + return TRUE; + } + if((mdm_status&COM_DCD)==0) /* DCD already low */ return TRUE; lprintf(LOG_DEBUG,"Waiting for transmit buffer to empty"); @@ -1270,10 +1289,15 @@ BOOL hangup_call(COM_HANDLE com_handle) lprintf(LOG_ERR,"ERROR %u lowering DTR", COM_ERROR); continue; } - lprintf(LOG_INFO,"Waiting for loss of Carrier Detect (DCD)"); + lprintf(LOG_DEBUG,"Waiting for loss of Carrier Detect (DCD)"); start=time(NULL); while(time(NULL)-start <= dcd_timeout) { - if((comGetModemStatus(com_handle)&COM_DCD)==0) + if((mdm_status=comGetModemStatus(com_handle)) == COM_ERROR) { + lprintf(LOG_ERR,"Error %u getting modem status (line %u)" + ,COM_ERROR_VALUE, __LINE__); + return TRUE; + } + if((mdm_status&COM_DCD)==0) return TRUE; SLEEP(1000); }