X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14FE6385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=huarp.harvard.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=huarp.harvard.edu Message-ID: <5255058c-74e0-f351-3c91-e63a54a1e323@huarp.harvard.edu> Date: Thu, 13 Jan 2022 12:37:56 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US From: Norton Allen To: "cygwin AT cygwin DOT com" Subject: character device canonical mode X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 20DHcZJ1011418 Apparently Cygwin does not support canonical mode on serial devices. On input canonical mode will wait for a newline before returning from a read(). The bit is cleared/ignored by tcsetattr() as demonstrated by a subsequent tcgetattr() in the test program below. I am wondering if this is because of a fundamental difference between the Windows serial device model and POSIX or just because the appropriate mappings haven't been implemented. (I have studiously avoided Windows programming for decades, and Cygwin has been my enabler!) My test program: #include #include #include #include #include #include void check_rv(int rv, const char *where) {   if (rv) {     printf("Error %s: %d %s\n", where, errno, strerror(errno));     exit(1);   } } int main(int argc, char **argv) {   termios termios_p;   if (argc != 2) {     printf("Must specify a serial device\n");     exit(1);   }   int fd = open(argv[1], O_RDWR | O_NONBLOCK);   check_rv(fd == -1, "opening serial device");   check_rv(tcgetattr(fd, &termios_p), "from tcgetattr()");   printf("c_lflag = 0x%X after open\n", termios_p.c_lflag);   termios_p.c_lflag |= ICANON;   printf("c_lflag = 0x%X to pass to tcsetattr()\n", termios_p.c_lflag);   check_rv(tcsetattr(fd, TCSANOW, &termios_p), "from tcsetattr()");   check_rv(tcgetattr(fd, &termios_p), "from 2nd tcgetattr()");   printf("c_lflag = 0x%X after tcsetattr()\n", termios_p.c_lflag);   return 0; } -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple