07-28-2017 12:27 PM
Hi everyone,
I have been trying to develop a COM port serial number vi for batch tests. I want this interface to continually scan for new COM ports, and when it finds a new one, add it to the array on the front panel and move key focus to the Serial Number member in the cluster. This way the tester can plug in a COM port and then scan the board serial number with a barcode scanner to automatically fill out the Serial Number (without having to click the Serial number box).
I have the first part mostly working, but I am unable to set keyfocus onto the Serial number of the last cluster in the array. I have tried resizing the array to 1, setting the index to the last member and then setting the Keyfocus, but the keyfocus is lost when I resize the array back to what it was before.
Does anybody have any advice on how I can do this?
Solved! Go to Solution.
07-28-2017 01:26 PM
In the registry, you could monitor
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\FTDIBUS\Enum
and read the value of Count. That will tell you the number of COM port devices detected currently on the system. To determine the actual port number, you would need to read in the numeric values up to (Count-1) for their location information. This information uses the base location within the registry of:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS
then append the Count information less the first directory. (Shortcut, otherwise we would go to the actual interface to get redirected back to FTDIBUS) Now go down another level to the Count for that interface and select the FriendlyName. The COM port is listed within the parenthesis. (Most of today's device use the FTDIBUS - however, there may be some older devices that may need to be accounted for in your code)
07-28-2017 01:31 PM
Thanks Minions, I'll change my COM port scan code using your suggestions. However, the main problem I am having is setting the Key Focus onto the Serial Number box in the array in MultipleCOMSandSerials.vi when a new COM port is found and added to the array. Any thoughts?
07-28-2017 02:17 PM
You could add a U8 variable to your main vi called COMs and when this value changes from the received scan of the ports, either you can inform the user that a change has occurred with a Boolean or reset the multicolumn selector to request user input due to configuration changes. Make sure that the port scanner vi runs independently from the event structure.
07-28-2017 02:30 PM
I'm already doing this in MultipleCOMsandSerials.vi
I think you're misunderstanding the problem... My problem is that I can't move key focus to the "Serial Number" box in the Array within MultipleCOMsandSerials.vi. It works for the first COM port, but if I plug in another, it doesn't focus.
For example:
COM12 is the first device plugged in. Immediately after it is plugged in, the cursor is focused on the "Serial Number" box next to it. This is the first element in the array of COM Port/SerialNumber clusters. The user can then scan a barcode and fill out this box without having to click in the Serial Number box (it is already selected).
Now I plug in another device, COM14. The cursor is not focused on the Serial Number box next to COM14. This is my problem. I can't figure out a way to set the key focus to this second element's Serial Number.
07-28-2017 06:15 PM
Couple of questions:
Why not use something like the following for finding COM ports? Does it not work for your COM ports?
As far as changing you key focus you have do something like the following
mcduff
07-31-2017 02:56 PM
Hi mcduff,
Your COM port scan works, but it requires a bit more work. I will be constantly calling this VI as the tester plugs in the devices. The VISA Open and Close commands seem a bit unnecessary when I can just scan the registry for changes.
I tried implementing your code, but you only have NumRows set to 1. I have always been able to get it to Key Focus on the Serial Number member of the first row, but my problem is that I can't focus it on any other row. In my picture above, I can plug in one device and it will focus. When I plug in a second one, I can focus it, but then when I resize my array (change NumRows back to 2), the Key Focus is lost and I cannot type.
I honestly don't think that there is any way to get it to work. It's pretty ridiculous that you can't select the index of the array in the property node. Do you have any other ideas?
07-31-2017 03:00 PM
If the key focus stays locked on the first element, then why not insert the new element into the beginning of the array rather than appending to the end? Alternatively, continue to append to the array then invert it.
07-31-2017 03:20 PM
Hah, yeah I guess that that works! Thanks for the suggestion!