LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
PhillipBrooks

Add regex based termination string option to NI-VISA

Status: New

Extend on the concept of the termchar to include a multicharacter termination string for VISA reads.

 

Ideally, the termination string could be defined as a regex.

 

When I establish a connection with a linux based Device Under Test using a terminal server or TCP socket, the device ready prompt is the typical username@hostname:#

 

I currently read the VISA session in a tight loop a byte at a time and buffer the characters to compare to a regex of \n%s@.+?:[~|(/(\w)+)]+?# 

 

The time required depends on the length of the response from the device under test, so I have to keep track of the total time myself; I can't use the VISA timeout.

 

If NI-VISA supported a regex based multicharacter termination string, I could set my VISA session to look and wait for the prompt.

 

NI-VISA TermString.png

In the old days when VISA was first designed, I'm guessing that this sort of functionality would have been taxing on the memory and CPU. With today's 64 bit GHz multicore processors, abundant RAM and common regex libs, I don't hink this would affect timing.

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

4 Comments
PhillipBrooks
Active Participant

Please note that my regex string is something I use with Format Into String (%s) because I want to be able to specify the user name during my session. The image is obviously an example and my regex string shown isn't valid Smiley Embarassed


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

DavidBoyd
Active Participant

Phillip,

 

I've been wishing for this for so long, I'm afraid I'll be retiring about the same time it finally debuts Smiley LOL

 

Seriously, though, I think this would be a great and entirely natural extension to VISA's termination recognition behavior.  I can't begin to count the number of times I've been presented with custom serial protocols which are non-ASCII and have descriptors like "128 characters per packet, where each packet begins with the sequence blah, blah, blah..."


Invariably the LabVIEW implementation involves disabling termchar (it's arbitrary data, after all) and coding some variant of what I call "Loop 'n Scoop".  Over the years, I've gotten a little more efficient with regexes, and computing and shifting around the next expected readcount, etc, so my read loop gets "in sync" with the device; the goal is always to only execute a single VISA read of the message size and golly gee, there's a perfect packet.

 

But to push some of the message boundary recognition down into VISA... that would be nice.  You get the first kudo on this IE post from me.

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
PhillipBrooks
Active Participant

Thanks. My use case is a bunch of TeraTerm scripts that I would rewrite in LabVIEW. These use a wait function with a form of alternation that screams regex; I started writing a loop n/ scoop myself and banging away a character at a time and tracking the total time, then realized it would be great if VISA could do the regex and wait for me in one VISA READ call.

 

I've considered writing a teraterm macro interpreter. We use teraterm alot, but it doesn't have the types if conditional branching, looping and processing you might like to use.

 

I have some SSH requirements, and started to write a LV wrapper for the Renci SSH.NET library. This NET lib inludes a ShellStream class with a read timeout property and  standard .NET regex object to search for a termination pattern. What a great concept!

 

With the demise of the internet toolkit, no NI SSH solution after all these years and the move away from GPIB instrments, I find myself thinking that it's time for NI to rethink the role of VISA and character based messaging.

 

Years ago I posted on the LAVA forums promoting the idea of lossy queues.  My thought about the lack of such a feature applies to this idea as well:

VISA is proven to be efficient, I'm just hoping to get the most out of it. I feel as if I'm tacking CB antennas, bumper protectors, and deer whistles onto a Ferrari... :P 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

PhillipBrooks
Active Participant

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Modify-the-TCP-Read-primitive-to-terminate-a-read-on-a...

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness