‎09-29-2015 06:59 AM
HI
I am trying to comport auto detect,
i am uisng status = viFindRsrc (defaultRM, "ASRL[0-9]*::?*INSTR", &find_list, &retCnt, instrDesc); funtion to detect port , but its working upto port 9 after 9 it not detecting correct one . please give an idea how tp slove this issue. ( comport may be 1 to 255).
thanks
Solved! Go to Solution.
‎09-29-2015 07:56 AM
@patil1983 wrote:
HI
I am trying to comport auto detect,
i am uisng status = viFindRsrc (defaultRM, "ASRL[0-9]*::?*INSTR", &find_list, &retCnt, instrDesc); funtion to detect port , but its working upto port 9 after 9 it not detecting correct one . please give an idea how tp slove this issue. ( comport may be 1 to 255).
thanks
That's because you are telling it to look for com ports 0-9.
‎09-29-2015 08:12 AM
nyc, doesn't the * after the [0-9] mean zero or more occurrences of the preceding character or expression?
'or more' should include ports 10, 100, ..., no?
‎09-29-2015 08:19 AM
I am no regular expression expert.
the [0-9] means one digit 0 ... 9
the * means 0 or more times
‎09-29-2015 08:22 AM
so this means that 'That's because you are telling it to look for com ports 0-9.' is not correct... it should also find ports with numbers larger than 9...
‎09-29-2015
08:36 AM
- last edited on
‎06-09-2025
09:14 AM
by
Content Cleaner
I am not sure where the OP got his example code from.
The LabVIEW example VI at https://forums.ni.com/t5/Example-Code/Obtaining-a-List-of-Only-the-COM-Ports-as-VISA-Resource-Names/... uses the expression ASRL?*::INSTR which is very similar to what I used to find my USB scope.
It doesn't look like it is a real regular expression.
According to the LabVIEW Help,
? matches any one character
* matches any 0 or more occurences of the preceding character or expression.
[list] matches any one character from the enclosed list. You can use a hyphen to match a range of characters
‎09-29-2015 08:37 AM - edited ‎09-29-2015 08:39 AM
@Wolfgang wrote:
so this means that 'That's because you are telling it to look for com ports 0-9.' is not correct... it should also find ports with numbers larger than 9...
No, if it was a regular expression it will NOT find numbers greather than 9.
I suggest that you look up what [0-9] actually means for a true regular expression.
Brackets means a list and with the hyphen, you are looking 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9.
That is it.
‎09-29-2015 08:57 AM
if you say so...
all I can tell is that viFindRsrc ( resource_manager_handle, "ASRL[0-9]*::?*INSTR", &find_handle, &return_count, instrument_descriptor ); does find all my serial ports, and I do have more than 30 ![]()
‎09-29-2015 08:57 AM
Findind the correct search expression can be a challenge!
If I search with "ASRL[0-20]*::?*INSTR" function fails to recognize port 4, while "ASRL[0-24]*::?*INSTR" finds it; "ASRL[0-256]*::?*INSTR" fails too ![]()
However, the expression in brackets is not a simple list, since even "ASRL[0-4]*::?*INSTR" finds port 10 (for what is worth, "ASRL[1-4]*::?*INSTR" doesn't locate port 10).
I am not an expert on Visa and even less on regular expressions, but it seems to me that "ASRL?*INSTR" as mentioned before should be the best search string. Next he will need to discriminate the parallel port if it exists in the system, which is counted too by the call.
‎09-29-2015 09:01 AM - edited ‎09-29-2015 09:04 AM
@RobertoBozzolo wrote:
Findind the correct search expression can be a challenge!
If I search with "ASRL[0-20]*::?*INSTR" function fails to recognize port 4, while "ASRL[0-24]*::?*INSTR" finds it; "ASRL[0-256]*::?*INSTR" fails too
Roberto, I would assume that [0-2]* means 0,1,2,00,01,02, ... and accordingly it will not find port 4. The same is true for [0-256]*.
And, for the same reason, ASRL[0-4]* finds port 10 because 0-4 includes 0 and 1, and * means repetitive.