Author Topic: Forcing Win7 to use a particular com port  (Read 3725 times)

0 Members and 1 Guest are viewing this topic.

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 887
  • Country: ca
Forcing Win7 to use a particular com port
« on: July 15, 2019, 01:02:29 pm »
I have a ST programmer setup to automatically program FLASH as part of a production test on an embedded PC running Win7.  This works fine most of the time, however from time to time after the PC has been re-booted Windows decides to use a different com port for the programmer.

I'm familiar with the right click and re-assign method using device manager, however after a re-boot any port could be assigned again by Windows.

Is there a way to force Windows to consistently use the same com port?
 

Offline Ampera

  • Super Contributor
  • ***
  • Posts: 2578
  • Country: us
    • Ampera's Forums
Re: Forcing Win7 to use a particular com port
« Reply #1 on: July 15, 2019, 01:32:28 pm »
as in logical COM1 is always the same port?

simple, use real COM ports, not USB ones, and ensure they aren't configured by plug and play.

besides that, it's quite possible the PnP manager will just throw resources at whatever controller it feels like at near random.
I forget who I am sometimes, but then I remember that it's probably not worth remembering.
EEVBlog IRC Admin - Join us on irc.austnet.org #eevblog
 
The following users thanked this post: Jester

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 887
  • Country: ca
Re: Forcing Win7 to use a particular com port
« Reply #2 on: July 15, 2019, 01:39:48 pm »
as in logical COM1 is always the same port?

simple, use real COM ports, not USB ones, and ensure they aren't configured by plug and play.

besides that, it's quite possible the PnP manager will just throw resources at whatever controller it feels like at near random.

I don't follow, can you translate in practical terms (I'm a hardware guy not a programmer). The ST programmer only has a USB interface.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4195
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Forcing Win7 to use a particular com port
« Reply #3 on: July 15, 2019, 01:40:22 pm »
Windows only gets confused about com port assignments when you have run out of all 255 of them.
Or your devices have a serial number conflict. Eg: counterfeit FTDI  or USB CDC example firmwares.

Try Ghostbuster Portable to remove unused drivers assigned to COM ports.
 
The following users thanked this post: Jester

Offline Ampera

  • Super Contributor
  • ***
  • Posts: 2578
  • Country: us
    • Ampera's Forums
Re: Forcing Win7 to use a particular com port
« Reply #4 on: July 15, 2019, 03:11:57 pm »
Real serial ports have access to specific standardized resources on PC compatibles. They are usually set by BIOS, but only real serial ports can use these resources.

USB serial ports, like what might be in your programmer, have to be provisioned with resources dedicated for USB devices, and then patched into the operating system's HAL as an abstracted serial port (which windows will identify as COM1, COM2, etc.) This means if you have multiple USB COM ports, which port gets which COM identification can change between boots, in whatever order the HAL decides to assign those values. "Real" serial ports always have the same resources, and the HAL will always assign the same COM designation based off what resources it's configured to use.

If your programmer runs off RS232 straight, find a computer (it's likely your computer already has one, many modern and semi-modern machines still do) that has a serial port on the machine, and use that to connect your programmer. Otherwise you'll have to dive into whatever nonsense Windows operates under in terms of COM port assignments in order to ensure that the same device always gets the same logical COM port assigned to it. If this is the case, the best thing to do is to unplug/disable all other serial (not USB) devices that are given a COM port identifier, so that only one ever exists on the machine (this is what your software will end up using).

I'd find it hard to believe that this is an issue, though, as surely your programming software allows you to change what COM port it uses, so when you reboot you can just manually tell it what port to use, no matter what it's switched to.
I forget who I am sometimes, but then I remember that it's probably not worth remembering.
EEVBlog IRC Admin - Join us on irc.austnet.org #eevblog
 
The following users thanked this post: Jester

Offline Bud

  • Super Contributor
  • ***
  • Posts: 7130
  • Country: ca
Re: Forcing Win7 to use a particular com port
« Reply #5 on: July 15, 2019, 03:59:29 pm »
It is an issue in that it is annoying to check every time in Device Manager which COM port it assigned to the hardware, before you can specify the corresponding setting in the software.
Facebook-free life and Rigol-free shack.
 
The following users thanked this post: Jester

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15439
  • Country: fr
Re: Forcing Win7 to use a particular com port
« Reply #6 on: July 16, 2019, 06:31:11 pm »
Well, I've found that Win7 tends to assign the same COM port number to a given USB peripheral if it's the same device AND you always connect it to the same USB port. This is my limited experience though - I don't use a ton of USB virtual serial devices. Maybe using a lot of different such devices on a regular basis could end up triggering such behavior.

Virtual serial devices are a complete anachronism these days anyway IMO. Good luck. ;D
 
The following users thanked this post: Jester

Offline nali

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: gb
Re: Forcing Win7 to use a particular com port
« Reply #7 on: July 16, 2019, 07:05:43 pm »
You could try the registry setting IgnoreHWSerNum if there is something screwy with the H/W serial numbers being reported. I've only used it with FTDI but apparently it works with other devices, although it doesn't seem to work with USB3.

See https://www.ftdichip.com/Support/Knowledgebase/index.html?ignorehardwareserialnumber.htm for details
 
The following users thanked this post: Jester

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 8070
  • Country: gb
Re: Forcing Win7 to use a particular com port
« Reply #8 on: July 16, 2019, 07:21:14 pm »
It is an issue in that it is annoying to check every time in Device Manager which COM port it assigned to the hardware, before you can specify the corresponding setting in the software.

https://helmpcb.com/software/serial-port-monitor
 
The following users thanked this post: Jester

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4195
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Forcing Win7 to use a particular com port
« Reply #9 on: July 17, 2019, 06:17:03 am »
Just check with https://www.nirsoft.net/utils/usb_devices_view.html what happens. Maybe the port/hub location changes on reboot, indicated cheap hub chips used instead of direct root hub connection.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3249
  • Country: ca
Re: Forcing Win7 to use a particular com port
« Reply #10 on: July 22, 2019, 08:51:54 pm »
Your software can read port mapping from HKLM\HARDWARE\DEVICEMAP\SERIALCOMM and find the com port number currently assigned to your device.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf