Skip to content
Snippets Groups Projects
Commit 3efb480e authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Change default PromptTimeout to 60 (seconds)

Also log a warning if a control character is received in response to the prompt, or log a notice if there's a timeout waiting for a response to the prompt. Change the non-control character response value to a debug-level log message.
parent b8dcc1e8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2611 passed
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
BOOL daemonize=FALSE; BOOL daemonize=FALSE;
BOOL cls=FALSE; BOOL cls=FALSE;
char prompt[INI_MAX_VALUE_LEN+1]; char prompt[INI_MAX_VALUE_LEN+1];
int prompt_timeout = 0; int prompt_timeout = 60; // seconds
char termtype[INI_MAX_VALUE_LEN+1] = NAME; char termtype[INI_MAX_VALUE_LEN+1] = NAME;
char termspeed[INI_MAX_VALUE_LEN+1] = "28800,28800"; /* "tx,rx", max length not defined */ char termspeed[INI_MAX_VALUE_LEN+1] = "28800,28800"; /* "tx,rx", max length not defined */
...@@ -1590,13 +1590,16 @@ service_loop(int argc, char** argv) ...@@ -1590,13 +1590,16 @@ service_loop(int argc, char** argv)
comWriteString(com_handle, prompt); comWriteString(com_handle, prompt);
char ch; char ch;
if(comReadBuf(com_handle, &ch, sizeof(ch), NULL, prompt_timeout * 1000)) { if(comReadBuf(com_handle, &ch, sizeof(ch), NULL, prompt_timeout * 1000)) {
lprintf(LOG_INFO, "Received character '%c' (%d) in response to prompt", ch, ch); if(IS_CONTROL(ch))
if(!IS_CONTROL(ch)) { lprintf(LOG_WARNING, "Received a control character (%d) in response to prompt", ch);
else {
lprintf(LOG_DEBUG, "Received character '%c' (%d) in response to prompt", ch, ch);
SAFEPRINTF(str, "TCP:%c", ch); SAFEPRINTF(str, "TCP:%c", ch);
iniGetExistingWord(ini, str, "Host", NULL, host); iniGetExistingWord(ini, str, "Host", NULL, host);
port = iniGetShortInt(ini, str, "Port", port); port = iniGetShortInt(ini, str, "Port", port);
} }
} } else
lprintf(LOG_NOTICE, "Timeout (%d seconds) waiting for response to prompt", prompt_timeout);
} }
if((sock=connect_socket(host, port)) == INVALID_SOCKET) { if((sock=connect_socket(host, port)) == INVALID_SOCKET) {
comWriteString(com_handle,"\7\r\n!ERROR connecting to TCP port\r\n"); comWriteString(com_handle,"\7\r\n!ERROR connecting to TCP port\r\n");
......
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