FIRST Tech Challenge Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NXT Flatten to String Not Working with Clusters and Arrays

Hello,

My name is Joshua and I am from the FIRST Tech Challenge Team 4318, Green Machine. We are trying to write a program that will write to a configuration file and read it back. The idea is that we will be able to write to a config file from our computer that will be read by our autonomous program when it runs. This will define what the autonomous program does.

The easiest way to do this seems to be flattening a data structure to a string, saving it to a file, and then reading back and unflattening it. The issue is that the flatten to string and unflatten from string VIs don't seem to work with arrays and clusters on the NXT. It does work when running on the computer. We've tried arrays, clusters, clusters in arrays and arrays in clusters, none seem to work. Thinking it was something to do with reading the string from a file, we tried bypassing the file functionality, still not working. It does work with basic data types though, such as strings and numbers.

No error is thrown from what we can tell. All you get is a blank data structure out of the unflatten VI.

The program attached is a test program I've been working on to get this functionality to work. It will display the hex content of what is going into the file, coming out of the file, and then the resulting data from the unflatten string, as well as any errors that have been thrown. The data type we are using simulates what we would like to store. There is also a file length in and out counter. The out file is a little larger because the NXT write file VI adds a new line character on to the end (thus the use of the strip white space VI). This character was corrupting even basic data types saved to file.

I would like to know if there is a problem with what we are doing, or if it is simply not possible to flatten arrays on the NXT. Please ask if you have any questions about the code. Thank you in advanced!

Joshua

0 Kudos
Message 1 of 2
(3,808 Views)

Hi Joshua,

The Help documentation for the “Flatten to String” function states that it converts the string to a binary value. Although, the string indicator (File In) handles the fact that it is a binary value and displays the string correctly on the Front Panel, the NXT isn't able to interpret it, as you have shown.

However, we can workaround this issue by sending the actual string representation (i.e. normal display value of the indicator) to the NXT. I modified the code you posted earlier to show how you can do this.

In the modified code, I used a property node that is linked to the 'File In' indiciator to read the text and I sent this string to the NXT File. I attached the modified code to this post. Please let us know if this works for you.

Regards,

Tunde

Tunde S.
Applications Engineer
National Instruments
Message 2 of 2
(3,234 Views)