Ir al contenido principal

Entradas

Implode / Explode

LabVIEW lacks native implode/explode functions for strings, to split a string into an array and vice versa. This is easily feasible thanks to the Spreadsheet String To Array function and its opposite Array to Spreadsheet String, but it's useful having a couple of VIs ready to do the work.Download explode.vi (VI for LabVIEW 2016)The explode function is pretty straightforward, but imploding is a little harder since the parallel function puts a carriage return / line feed at the end of the resulting string, and we need to remove it applying a trim. Trim is not the best function in performance and could add more problems (for example if the last chunk has a white space at the end), so I have implemented an alternative simple for-loop mechanism.Download implode.vi (VI for LabVIEW 2016)Check the code and select the mode you are mor confortable with.
Entradas recientes

SNMP library for LabVIEW

SNMP (Simple Network Management Protocol) is a fairly common protocol for communicating with network equipment. It's fast, lightweight and standardized. Unfortunately it's not quite as simple as its name implies and LabVIEW doesn't support it natively.Some years ago I was in the necessity of using SNMP from a LabVIEW system to control some hardware. I started looking for already implemented solutions and found a library developed by Mark Yedinak (great work!). It was useful since it demonstrated it could be done and how, but I needed more control over the operations, so I had to read the protocol down to the low level bytes and implement what I need by myself. Yeah, pretty hard and with time constraints no less. Anyway, here it is.Download (Library in LLB file for LabVIEW 2016)See the examples folder to grasp the basic use. Probably you'll need no more than these sets of VIs to send and retrieve data and to get traps sent by your equipment. To integrate in a program, u…

Release current directory

This is not mine, it's a tip I found years ago in a LabVIEW forum and still works like a charm (thanks to the genious that got it!).When the user selects a file to work with (signal data you want to analyze, for example) your LabVIEW application "grabs" its path, so you can't delete it or its directory, or unmount the unit if you're using an external drive, even if you are not reading that file anymore and you clear any path controls. But we can use Kernel32.dll method SetCurrentDirectoryA to release it (obviously, this only works in Windows systems).No downloadable code today, it's better if you link the call library function node by yourself, so you're sure it finds the dll. You can find more info about this method here: SetCurrentDirectory function at MSDN.

Variant to XML

Converting to XML format is a good way of exporting data in a standard, human-readable way. I have used it to pass and receive data from other languages, for example, or if you need to dump data to a log file.As you may know, LabVIEW includes its own functions for converting to and from XML, called Flatten To XML and Unflatten From XML. Unfortunately, it's a raw conversion that just gives a node with the data type and two child nodes, name and value. So, to find a field you must recover first all the name nodes, locate the one you need and then find its value sibling. Too crude for a lot of scenarios:So I developed my own library to do this conversion in a more convenient way. Check the differences in the next image:As you can see the field names are now used as tag names, resulting in a shorter and cleaner XML text. The reverse conversion (from XML to LabVIEW data) is shown in the bottom of the image, and works the same.In the block diagram, these functions are used directly, jus…

CIDR to netmask

To begin with, something basic but useful, a LabVIEW VI for converting CIDR suffix to a standard IP mask. As you know, in CIDR format the number after the IP indicates the bits that address uses. If you need to convert to a tradicional subnet mask, this VI comes handy.So, a CIDR of 24 will return a 255.255.255.0 mask, 28 is 255.255.255.240, etc. Pretty simple, but a lot of applications demand netmasks in this format.Download (VI for LabVIEW 2016)LabVIEW still only supports IPv4, so I haven't delved into the complexities of IPv6 (we'd need a U128 data type for that).

Welcome

Welcome to Solar Code, a personal blog by Aitor Solar (yeah, the blog's name is just a bad pun on my surname). Here I will post my programming tips and solutions, mainly for LabVIEW (though some JavaScript is foreseen). All the code and tips in this blog come with no warranty, you use it at your own risk. Any questions regarding it should be directed to Aitor Solar at aitor.solar@gmail.com.