LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a Flattened String to a DAQmx Channel Description

Solved!
Go to solution

Hello all,

 

I have an application in which I have both a main VI and a configuration VI.  The latter configures how the the front panel will look as well as how the data acquisition system (that is driven by the main VI) will operate.  In the configuration VI, the user selects the channels as well as the appropriate description of the channel (which is contained in a cluster of enums, booleans and numerics).  I am able to write the description of each channel into the DAQmx channel description property as a string (example below) and then read the string back and reformat as some type of delimited string in which I understand the structure and can decode it appropriately using various string functions (such as the string tokenizer, string to numeric, etc).  I thought that I would get a little bit more clever about this and simply flatten the clusters to string and write these binary strings to the description.  However, when I read these back from the description, I get error 74 - memory or data structure corrupt.  Has anyone tried something like this before?  Is there a better way of doing this?  What might I be doing wrong?  Any help is appreciated.  Peace, Matt

 

Build Tasks_BD.png 

0 Kudos
Message 1 of 5
(3,498 Views)

Hi Matt,

 

DAQmx string properties treat null characters as an end-of-string marker, so your strings are probably getting truncated. You will have to encode the data in a format that does not contain embedded null characters. Base64 is one example of such a format, but there are many others that would work.

 

Here's a snippet that shows the truncation:

 

Descr embedded null character truncation.png

 

Descr embedded null character truncation output.png

 

Brad

---
Brad Keryan
NI R&D
Message 2 of 5
(3,478 Views)

Thanks for the reply, Brad.  Based on what I am seeing, that actually makes a lot of sense.  However, I still don't understand the conversion to Base64 (computer science is not my first area of study).  Simply for my edification, do you have a short example of this?  I already decided that I would just stick to the string based way that I did it before.

 

Cheers, Matt

0 Kudos
Message 3 of 5
(3,436 Views)
Solution
Accepted by topic author cirrusio

Hi Matt,

 

There are some LabVIEW VIs for Base64 encoding/decoding: http://decibel.ni.com/content/docs/DOC-5544

 

I haven't tried them, but I would expect that you could flatten to string, convert the binary string to a Base64 string, then set the Base64 string on the DAQmx Channel property node's Descr property. Retrieving the data would be the exact reverse.

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 4 of 5
(3,429 Views)

Thanks, Brad.  Probably would be overkill for this application, but it is nice to know they are out there.

 

Peace, Matt

0 Kudos
Message 5 of 5
(3,420 Views)