From 0b006f257ac21731b09c389eec0062b8338450d6 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Mon, 7 Feb 2022 22:05:23 -0800
Subject: [PATCH] Setting IgnoreDCD=true causes wait_for_call() to immediate
 return

For Nelgin's null modem setup, putty doesn't raise DTR?

<nelgin> sexpots   1492                               root    3u      CHR               4,64        0t0         90 /dev/ttyS0
<nelgin> Well, it's listening, but when I connect with putty I get nothing.
<nelgin> DigitalMan, probably always assume a client is connected since I have my pc wired to my linux box.
---
 src/sexpots/sexpots.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/sexpots/sexpots.c b/src/sexpots/sexpots.c
index b09784291a..983c020c80 100644
--- a/src/sexpots/sexpots.c
+++ b/src/sexpots/sexpots.c
@@ -759,7 +759,7 @@ int modem_status(COM_HANDLE com_handle)
 /* Returns TRUE if DCD (Data Carrier Detect) is high */
 BOOL carrier_detect(COM_HANDLE com_handle)
 {
-	return (modem_status(com_handle)&COM_DCD) ? TRUE:FALSE;
+	return (dcd_ignore || (modem_status(com_handle)&COM_DCD)) ? TRUE:FALSE;
 }
 
 /****************************************************************************/
@@ -779,7 +779,7 @@ BOOL wait_for_call(COM_HANDLE com_handle)
 	if(!comRaiseDTR(com_handle))
 		lprintf(LOG_ERR,"ERROR %u raising DTR", COM_ERROR_VALUE);
 
-	if(com_alreadyconnected)
+	if(com_alreadyconnected || dcd_ignore)
 		return TRUE;
 
 	if(!mdm_null) {
@@ -1250,7 +1250,7 @@ BOOL handle_call(void)
 
 	while(!terminated) {
 
-		if(!dcd_ignore && !carrier_detect(com_handle)) {
+		if(!carrier_detect(com_handle)) {
 			lprintf(LOG_WARNING,"Loss of Carrier Detect (DCD) detected");
 			break;
 		}
@@ -1322,7 +1322,7 @@ BOOL hangup_call(COM_HANDLE com_handle)
 	int		attempt;
 	int		mdm_status;
 
-	if(!carrier_detect(com_handle))/* DCD already low */
+	if(dcd_ignore || !carrier_detect(com_handle))/* DCD already low */
 		return TRUE;
 
 	lprintf(LOG_DEBUG,"Waiting for transmit buffer to empty");
-- 
GitLab