Automatic Com port Select

For general Flowcode discussion that does not belong in the other sections.
Oscar_T
Posts: 89
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Automatic Com port Select

Post by Oscar_T »

Hello everybody

I'm looking for a way to automate an operation.

The purpose is that every time a user connects a device the program recognizes and enables the com port and consequently all the other functions.

In this way it will not be necessary to search for the port of the connected device or but just connect it

In this case I use an ftdi234xd which as vid / pid has the following values

USB Vendor ID (VID) 0403h
USB Product UD (PID) 6015h

I use the follow macros "scanfordeviceid" for chek the vid/pid "VID_0403h&PID6015h"
the question is, how do I pass the value to the next function ie opencom and then start the communication?

Kind Regards

BenR
Matrix Staff
Posts: 1756
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 446 times
Been thanked: 606 times

Re: Automatic Com port Select

Post by BenR »

Hello,

Here's a quick example for you.
AutoDetect COM Port.fcsx
(11.03 KiB) Downloaded 155 times

Oscar_T
Posts: 89
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Re: Automatic Com port Select

Post by Oscar_T »

Hi Ben

I am trying to use the program but it does not detect the com port. This is what I see from device manager


Kind Regards
Attachments
Port_serial.png
Port_serial.png (73.43 KiB) Viewed 4075 times

Oscar_T
Posts: 89
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Re: Automatic Com port Select

Post by Oscar_T »

Hi Ben

Do you have any idea why the com port is not recognized?

Kind Regards

Steve-Matrix
Matrix Staff
Posts: 1269
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 168 times
Been thanked: 285 times

Re: Automatic Com port Select

Post by Steve-Matrix »

Hello Oscar,

I've just tested Ben's program and it seems to be working fine for me. In device manager, I looked for the PID/VID under the "Events" tab for the COM port device (in my case, an Arduino Uno) and I found reference to this: USB\VID_2A03&PID_0043. I modified the search string in the program and it is detected fine when the program is run.

I have noticed that yours shows "VID_0403+PID_6015". Perhaps try that in the search string as in Ben's example a "&" is used instead of a "+". It could be this is because the OS language is different, or it could be because the FTDI device identifies itself in a different way.

Oscar_T
Posts: 89
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Re: Automatic Com port Select

Post by Oscar_T »

Hello Steve

i tried different combinations but can't find the com port. The id name from windows is VID_0403 & PID_6015.

the device in question is a very popular ft234xd

Kind Regards
Attachments
Port_serial.png
Port_serial.png (81.37 KiB) Viewed 4054 times

Steve-Matrix
Matrix Staff
Posts: 1269
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 168 times
Been thanked: 285 times

Re: Automatic Com port Select

Post by Steve-Matrix »

You could perhaps search through your registry for "VID_0403" and see what it there. It should be somewhere within "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum"

The "ScanForDeviceID" function in Flowcode calls the Windows API which effectively looks at this registry location for the VID/PID string in the "HardwareID" entries. It then returns the equivalent "FriendlyName" from the same location.

For example, when I tried to detect the Uno, the information was found here:

Code: Select all

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_2A03&PID_0043\85439303033351216280
In there are the following entries, which are used to detect the port:
vidpid.png
vidpid.png (9.07 KiB) Viewed 4052 times

Oscar_T
Posts: 89
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Re: Automatic Com port Select

Post by Oscar_T »

Hi Steve

It appears that "FriendlyName" is under the root FTDIBUS and not USB.
Attachments
Port_serial.png
Port_serial.png (245.48 KiB) Viewed 4047 times

Steve-Matrix
Matrix Staff
Posts: 1269
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 168 times
Been thanked: 285 times

Re: Automatic Com port Select

Post by Steve-Matrix »

I think that explains it. Our code specifically looks within the "USB" enumeration. Unfortunately, it looks like the FTDI device works differently to other virtual COM ports.

Oscar_T
Posts: 89
Joined: Wed Dec 02, 2020 10:06 am
Location: Italy
Has thanked: 37 times
Been thanked: 10 times

Re: Automatic Com port Select

Post by Oscar_T »

Thanks for the help Steve

I recommend making the function compatible, perhaps in a future update or in the next revision, with these devices because they are very used.

Kind regards

Post Reply