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

Log errors with comGetModemStatus.

parent 408d2c7d
No related branches found
No related tags found
No related merge requests found
...@@ -675,7 +675,8 @@ BOOL modem_command(COM_HANDLE com_handle, const char* cmd) ...@@ -675,7 +675,8 @@ BOOL modem_command(COM_HANDLE com_handle, const char* cmd)
char resp[128]; char resp[128];
if(!modem_send(com_handle, cmd)) { 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; return FALSE;
} }
...@@ -742,6 +743,7 @@ BOOL wait_for_call(COM_HANDLE com_handle) ...@@ -742,6 +743,7 @@ BOOL wait_for_call(COM_HANDLE com_handle)
char* p; char* p;
BOOL result=TRUE; BOOL result=TRUE;
DWORD events=0; DWORD events=0;
int mdm_status;
ZERO_VAR(cid_name); ZERO_VAR(cid_name);
ZERO_VAR(cid_number); ZERO_VAR(cid_number);
...@@ -806,7 +808,10 @@ BOOL wait_for_call(COM_HANDLE com_handle) ...@@ -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 */ 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; break;
} }
...@@ -1179,6 +1184,7 @@ BOOL handle_call(void) ...@@ -1179,6 +1184,7 @@ BOOL handle_call(void)
int result; int result;
int rd; int rd;
int wr; int wr;
int mdm_status;
fd_set socket_set; fd_set socket_set;
struct timeval tv = {0, 0}; struct timeval tv = {0, 0};
...@@ -1199,10 +1205,17 @@ BOOL handle_call(void) ...@@ -1199,10 +1205,17 @@ BOOL handle_call(void)
while(!terminated) { while(!terminated) {
if(!dcd_ignore && (comGetModemStatus(com_handle)&COM_DCD) == 0) { 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"); lprintf(LOG_WARNING,"Loss of Carrier Detect (DCD) detected");
break; break;
} }
}
#if 0 #if 0
if(comReadByte(com_handle, &ch)) { if(comReadByte(com_handle, &ch)) {
lprintf(LOG_DEBUG,"read byte: %c", ch); lprintf(LOG_DEBUG,"read byte: %c", ch);
...@@ -1258,8 +1271,14 @@ BOOL hangup_call(COM_HANDLE com_handle) ...@@ -1258,8 +1271,14 @@ BOOL hangup_call(COM_HANDLE com_handle)
{ {
time_t start; time_t start;
int attempt; 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; return TRUE;
lprintf(LOG_DEBUG,"Waiting for transmit buffer to empty"); lprintf(LOG_DEBUG,"Waiting for transmit buffer to empty");
...@@ -1270,10 +1289,15 @@ BOOL hangup_call(COM_HANDLE com_handle) ...@@ -1270,10 +1289,15 @@ BOOL hangup_call(COM_HANDLE com_handle)
lprintf(LOG_ERR,"ERROR %u lowering DTR", COM_ERROR); lprintf(LOG_ERR,"ERROR %u lowering DTR", COM_ERROR);
continue; continue;
} }
lprintf(LOG_INFO,"Waiting for loss of Carrier Detect (DCD)"); lprintf(LOG_DEBUG,"Waiting for loss of Carrier Detect (DCD)");
start=time(NULL); start=time(NULL);
while(time(NULL)-start <= dcd_timeout) { 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; return TRUE;
SLEEP(1000); SLEEP(1000);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment