delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/19/12:55:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: 1.57 on Win2k or WinXP. Not more than 16 com ports. Differences between //./comX and /dev/comX
Date: Mon, 19 Apr 2004 17:52:00 +0100
MIME-Version: 1.0
In-Reply-To: <C2F0FC2A5C4B3E44ADF4327E699486A509F528@mail2.de.thorlabs.local>
Message-ID: <NUTMEG7HzspfEhmkIl6000004fd@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 19 Apr 2004 16:52:00.0734 (UTC) FILETIME=[A25977E0:01C4262E]
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i3JGt7Il023402

> -----Original Message-----
> From: cygwin-owner On Behalf Of Lutz Hörl
> Sent: 19 April 2004 17:29

> Hello,
> 
> I want to use (Windows-) COM port numbers greater
> than 16, but when I use open() to get a file
> descriptor for the devices I get the behaviour:
> 
> ---1.case-----------------------------------------
> 
> errno = 0;
> fd = open("/dev/com8", O_RDWR | O_NONBLOCK);
> -> fd = 3, errno = 0
> -> everything is OK,
>    I can use the opened COM port
>
> ---2.case-----------------------------------------
> 
> errno = 0;
> fd = open("\\.\com8", O_RDWR | O_NONBLOCK);
> 
> -> fd = 3, errno = 20 = ERROR_BAD_UNIT
>    = "The system cannot find the device specified"
> -> I can not use the opened COM port. The port
>    number 1...16 versus 17...255 does NOT matter.

  You got this one wrong.  The backslashes inside the quotes need to be
escaped, otherwise the first two will be parsed as a single escaped
backslash, and the second as '\c', which isn't a valid control char in C, so
you're likely to end up actually trying to open a device called "\.com8".
You must have ignored a warning message from the compiler when you tried
this.  WHY???!?

dk AT mace /davek/test> cat testslash.c

#include <stdio.h>

int main (int argc, const char **argv)
{
  printf ("\\.\com8\n");
  return 0;
}

dk AT mace /davek/test> gcc -o testslash testslash.c
testslash.c:6:11: warning: unknown escape sequence '\c'
dk AT mace /davek/test> ./testslash.exe
\.com8
dk AT mace /davek/test>

> ---3.case-----------------------------------------
> 
> errno = 0;
> fd = open("/dev/com23", O_RDWR | O_NONBLOCK);
> 
> -> fd = -1, errno = 2 = ERROR_FILE_NOT_FOUND
>    = "The system cannot find the file specified"
> -> I can not use the opened COM port. The port
>    number 1...16 (OK) 17...255 (not OK) DOES matter.
> 
> ---end cases------------------------------------

  It's a dos/windoze limitation that only the low few com ports actually
have dos devices created for them.  8 is the upper limit, IIRC.  So you can
just open com1....com8 from an ordinary DOS program, and so cygwin creates 8
com devices under /dev, because that's all it finds windoze has listed.  If
you want to use the others, you have to use the \\.\comX notation.
 
> Is there a workaround?

  Yep.  Use the \\.\comX notation and get it correct.  That should work.

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019