LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

virtual comport auto detect

Solved!
Go to solution

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

0 Kudos
Message 1 of 39
(6,082 Views)

@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.

0 Kudos
Message 2 of 39
(6,068 Views)

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?

0 Kudos
Message 3 of 39
(6,063 Views)

I am no regular expression expert.

the [0-9] means one digit 0 ... 9

the * means 0 or more times

 

 

0 Kudos
Message 4 of 39
(6,062 Views)

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...

 
0 Kudos
Message 5 of 39
(6,058 Views)

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

0 Kudos
Message 6 of 39
(6,053 Views)

@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.

0 Kudos
Message 7 of 39
(6,053 Views)

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 Smiley Wink

0 Kudos
Message 8 of 39
(6,038 Views)

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 Smiley Surprised

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 39
(6,037 Views)

@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 Smiley Surprised


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.

0 Kudos
Message 10 of 39
(6,038 Views)