🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8263

Re: Port Scans

#8263
From: Pete Fraser
Date: Mon, 08 Nov 2004 09:10
43 lines
2445 bytes
After using CreateFile to open the port, connect at 19200.
If this fails, change baud rate to 9600 and connect again.
Don't forget to CloseHandle on the handle returned by CreateFile after 
opening.
The port must be closed before changing baud rates - but may still have been 
created.
So psuedo code is:
CreateFile
  Set baud rate to 19200
  openPort
  try to find device
  if it fails
    close port
    set baud rate to 19200
    try to find device
    if it fails
      close port

HTH Pete

"Max Blank" <MaxBlank@MaxBlank-Institute.net> wrote in message 
news:418ebc0d@newsgroups.borland.com...
>I need to automatically find a device connected to one of a computer's 
>serial ports. This is no big deal: Simply create a file handle for each com 
>port (using CreateFile), try to connect, pass the key phrase and wait for 
>the correct response.
>
> Some systems, unfortunately, use USB<->Serial adapters that work with 
> 19200 instead of 9600 baud. So I have to scan each port twice, don't I ?
>
> I first try to connect at 19200 baud and fail, because no device is 
> attached to this port and no handle is being created. If I try to connect 
> again at 9600 baud, CreateFile cannot create a handle; however, if I do 
> not try to connect at 19200, or - even more strange - when I set a 
> breakpoint, stop the program's execution for less than a second, and 
> continue the program, the handle is being created and the port can be 
> opened !!!
>
> So where's the problem ??
>
>
> Max
> 
Technical Details
Message-ID: <418f380f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <418ebc0d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9fcab49b7cf126f6
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Pete Fraser" <pete._no_spam_fraser@frasersoft.nospam.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <418ebc0d@newsgroups.borland.com>
Subject: Re: Port Scans
Date: Mon, 8 Nov 2004 09:10:38 -0000
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 195.12.18.1
Message-ID: <418f380f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1099905039 195.12.18.1 (8 Nov 2004 01:10:39 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail