Electronics > Beginners
CH340 / CH330 for commercial crowdfunding product
<< < (4/4)
Rick Law:

--- Quote from: DDunfield on April 28, 2019, 11:30:09 am ---
--- Quote from: madires on April 28, 2019, 10:18:40 am ---Isn't it the default behaviour of Windows to assign the COM port number based on the USB port? There aren't much users playing with the registry to attach a fixed COM port ID to a specific device.

--- End quote ---

Windows assigns USB->COM ports on the USB port AND the serial number of the device.
Plug one device into one USB then another, you will have two serial ports reserved.
Plug a different device into the same two USB ports, you will have two more (4) serial ports reserved.

Windows allows a max. 256 COM ports, so if you are in an application where you attached a lot of devices, you need to clear them out from time to time.
I recently did a windows based tester which interfaces to the DUT via the maintenance port (USB->Serial) and at startup and every 50 units tested, I go in and clear out all USB->Serial devices of the particular PID/VID we are using.

Dave

--- End quote ---

That serial number for CH340 is apparently missing or not available with the standard Windows drivers.

You can do quite a bit with the registry.  With the FTDI (and driver), one could use PXE (pre-boot environment) to RegEDIT to give it a good friend user name,"permanent" port number, default speed/parity, (and anything else RegEdit can get to) and it will follow that specific card regardless of which USB socket you plug it in -- but you can't do that with CH340.  You are tied to "the hole" you plug it into.

Given the price delta between FTDI and CH340, I gave up and just accept the fact that it will ID itself based on which USB port I plug it into and keep rolling with CH340's.

The "floating" com port assignment is more problematic than as first appears (think switching between PC's).  Besides causing confusion at times, it does cause a good bit of inconvenience:  On the PC side, you cannot have it hard code to a particular com port even for "quick and dirty" little things for experimentation.  Powering down and switching plugs around doesn't always work because there may be port number conflict.  So, codes on the PC side must carry the extra code needed to soft-select the port number, speed, parity, etc.

When my old PC died, my whole load of "quick and dirty" tests codes went out the window.  I retrofit some to have port selection dialog, but some test codes were just left dead till I really have a need for it.
oPossum:
CH340B does support an optional 8 character serial number using an external EEPROM. The other versions do not support a serial number by any means.
Rick Law:
For an end user product, one will need to think about how much inconvenience the user will need to endure and minimize that as much as possible.

As an end user, I probably would not think "com 3" vs "com 7" (or whatever).   I would like the product to work whether I plug it into the left side of the laptop or the right side of the laptop.   So, if I started off with plugging it into the "first USB socket on the right side" and got it all set-up for my liking...  There needs to be an easy way for me the user if next time I plugged it into the left side of the laptop.  I would found it very annoying if I have to go through the entire setup process again - particularly if I have multiple devices and/or multiple laptops.  And then, God forbid, I went and purchased a couple of USB Hubs...  Now I have to go through the whole darn thing again...

A simple drop-down on port selection probably wont work unless it is for technical users since typical users wont think ports.  So, I think a way is for the codes to self-identifies - it scans the ports for the presence of the device.  It tries to start using the same port as last time.  If it is not found, then the user is given a choice to select port number or to scan for the device.

I am sure many of you could think of a better way than what I just proposed.  Any good way will do.  As designer of the product, you just need to remember, each time I plug it into somewhere else, the port setting is different.  Make it easy for the user when it happens.
DDunfield:

--- Quote from: Rick Law on April 28, 2019, 08:33:12 pm ---As an end user, I probably would not think "com 3" vs "com 7" (or whatever).   I would like the product to work whether I plug it into the left side of the laptop or the right side of the laptop.   So, if I started off with plugging it into the "first USB socket on the right side" and got it all set-up for my liking...  There needs to be an easy way for me the user if next time I plugged it into the left side of the laptop.  I would found it very annoying if I have to go through the entire setup process again - particularly if I have multiple devices and/or multiple laptops.  And then, God forbid, I went and purchased a couple of USB Hubs...  Now I have to go through the whole darn thing again...

--- End quote ---

That's pretty much how seems to work under Windows ... every time you put the same device into a new USB socket, it gets assigned a new COM port.

It would be nice if the OS just used the VID/PID/serial# as a unique identifier assigning it the same COM port no matter what USB socket it happens to be plugged in to. Although this would cause problem with CH340's which seem have default serial# == 0.

I recently did a update program for a product using a USB serial port. When the user launches the update program, it tells him to connect the USB cable, and that if it is already connected he should disconnect it, and also that he should not connect/disconnect anything else while the update program is running. It then waits for a change in the serial ports configuration.

If I see a serial port "go away", I issue a message that he should now reconnect it.

If I see a serial port of the correct PID/VID show up, I configure it and attempt to do the update.

This works quite well for in-frequent operations (such as updating), however it would become a PITA if you had to disconnect/connect the cable every time for more frequent functions. Perhaps default to the last COM port used, and offer a "Find my COM port" button doing the above when that COM port does not exist or does not respond as the expected device.

A fully automatic way would be on application startup to scan the USB serial ports and try any that are the correct VID/PID ... but I don't like software automatically communicating with random COM ports unless I've activated a function documented to do that. The disconnect/connect method is nice because it does not actually communicate with a port unless it appears during discovery.

Dave
Rick Law:

--- Quote from: DDunfield on April 28, 2019, 09:10:41 pm ---...
It would be nice if the OS just used the VID/PID/serial# as a unique identifier assigning it the same COM port no matter what USB socket it happens to be plugged in to. Although this would cause problem with CH340's which seem have default serial# == 0.
...
Dave

--- End quote ---

Yeah, that is THE PROBLEM, may be merely annoying but a problem none the less, that is why I pointed it out...


--- Quote from: DDunfield on April 28, 2019, 09:10:41 pm ---... but I don't like software automatically communicating with random COM ports unless I've activated a function documented to do that. The disconnect/connect method is nice because it does not actually communicate with a port unless it appears during discovery.

Dave

--- End quote ---

Good that you brought it up.  I forgot...  Some devices (such as Arduino) would reboot even when you merely close and then reopen the COM port to it.  That would annoy me a great deal if the Ardunio is running something like data collection.

I like an auto scan, but I wish (yeah cold day in hell) that there is a non-disruptive method to scan for just a device ID.
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod