From: Ben Gardiner Date: Tue, 22 Sep 2020 03:10:08 +0000 (+0000) Subject: sp: clear HUPCL to preserve control lines on close X-Git-Tag: libserialport-0.1.2~15 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1b011060df5579c15bd4e103c2d8afc4d442fd72;p=libserialport.git sp: clear HUPCL to preserve control lines on close The comment and code are out of sync. The comments say "leave control lines alone on close." The HUPCL bit, when set, will "Lower modem control lines after last process closes the device (hang up)." To match the intent captured in the comment, the HUPCL bit should be cleared. Signed-off-by: Ben Gardiner --- diff --git a/serialport.c b/serialport.c index 1daba1c..d088398 100644 --- a/serialport.c +++ b/serialport.c @@ -633,7 +633,8 @@ SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags) data.term.c_cc[VTIME] = 0; /* Ignore modem status lines; enable receiver; leave control lines alone on close. */ - data.term.c_cflag |= (CLOCAL | CREAD | HUPCL); + data.term.c_cflag |= (CLOCAL | CREAD); + data.term.c_cflag &= ~(HUPCL); #endif #ifdef _WIN32