VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

error 74 using unflatten to string in an Inline Hardware Interface custom device

Solved!
Go to solution

Hello,

 

I am creating an Inline Hardware Interface custom device to communicate over serial bus in Veristand. As I only want to communicate values of veristand channels over RS232, I am using flatten/unflatten to string to transfer my data. I choose it because VISA Write/Read uses strings, and it would use always the same size of string (Veristand channels = 64 bits double => 8 characters string).

 

But when it comes to try it with veristand, I have the error 74 : Memory or data structure corrupt. I saw this error comes from the "unflatten from string" function.

 

So I wired a "clear errors" vi just after "unflatten to string" function, so that my custom device runs but gives me false results. Then I used the NI TO Trace tool to see what I was writing to the RS232 bus. You can find attached the result of this. When we take a look at the viWriteasync functions, we can see that the data written on the bus is already wrong "?..W...M" which is translated by 0,000232195, even if the value I transmitted to the bus was above 1.

 

I wired the constant "false" to "prepend array or string size" of the "flatten to string" and "unflattend to string" functions.

 

Does anybody have any idea of what is wrong ?

 

Regards,

 

Maxime

0 Kudos
Message 1 of 5
(8,018 Views)

Hello MaximeD,

 

Welcome at National Instruments Discussion Forums.

 

Error 74 usualy happens when the input string of "Unflatten from String" function is not flattened. As it's mentionned in LabVIEW manual, this kind of format is obtained by using "Flatten to String" function.

 

Does-that solve your problem ?

 

Regards,

Mathieu P. | Certified LabVIEW Associate Developer
National Instruments France


Journées techniques : des fondamentaux aux dernières technologies pour la mesure et le contrôle/comm...

0 Kudos
Message 2 of 5
(7,991 Views)

Hello Mathieu,

 

Thank you for replying.

I am already using "Flatten to string" function when I write data to the RS232 bus, and I think the problem comes from this function when it is used in Veristand.

 

Maybe looking through my VI will help ?

 

Regards,

 

Maxime

0 Kudos
Message 3 of 5
(7,988 Views)
Solution
Accepted by topic author MaximeD
Is your visa serial session set up to terminate strings with the null character? It's been a while since I worked with serial but I seem to remember this could be the case. If so you'd have trouble sending flattened binary data since it would have lots of null characters in it. An alternative would be to format the doubles as text with a specified number of digits of precision, although this will be less accurate and can take more bytes to transfer.
Jarrod S.
National Instruments
Message 4 of 5
(7,977 Views)

Hello,

 

Thanks to your reply I realised the problem came from the termination character. I set it to the original value ('\n') and did not add any termination caracter to the string I sent.

 

Now I am using the null character as termination character which actually make things better instead of making things worse.

 

I also tried the other method (format doubles as text with specified precision) which is working perfectly ! But as you said it is less accurate and takes more bytes.

 

Thank you for your help.

 

Maxime

 

PS : As my problems are solved, I have a Serial Custom Device which is working (not perfect, but working), so should I post it somewhere ?

0 Kudos
Message 5 of 5
(7,960 Views)