NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Text From .csv File

We use TestStand 2014 for all of our development. We have 1000's of files which have 1 line of text which goes something like this:

 

Gain1, 0x111, Offset1, 0x01,Gain2, 0xA12, Offset2, 0x0F......

 

I know the name of the file and so I must find it and parse it. There are 24 separate elements which go like the aforementioned line. I want to pull in the contents of this 1 line file and fill the 12 hex numbers into TestStand numeric variables. How can I solve this problem?

0 Kudos
Message 1 of 12
(4,547 Views)

I've done something similar where we call the files "recipes".  They were in JSON.  We read them in and generate a sequence which we can execute using the limits and parameters from the "recipes".  You need some sort of mapping capability to map each element to a lookup string for the step.  In your case though you might be able to get away with assuming things are always in the same order.

 

The question is: How do you know which variable you want to map the offset or gain value to?

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 12
(4,518 Views)

You can import the content of a .csv file to Teststand using the Property Loader step. The detail is that to use this feature you need to give the .csv file a certain format for Teststand to recognize where to place the input parameters (destination step and variable).

 

To obtain the format necessary for the sequence you are using, you can export a .csv file first where you specify the destination variables and use it as a template where you can write the parameters you are planning to import. In this article you can find more details about it:

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019RPoSAM&l=en-US

 

Since you have multiple files that require this treathment, you could create a script that gives all of the files the required format (it could be in LabVIEW or another programming language).

 

Also, to convert a String variable that contains an hexadecimal number to its numeric counterpart, you could use the Teststand expression:

 

Val("0x" + Locals.Value_Read)

 

I hope that helps.

Message 3 of 12
(4,513 Views)

The order is always the same with a name starting with Gain1, 0x??? followed by an Offset1, 0x???, where ? = a hex number, until the last Gain12, 0x???,Offset12,0x???. In my actual file, each gain has a unique name like LTA_Gain or LTA_Offset or AA_Gain or AA_Offset etc. But the order and names are always the same. Only the hex numbers will be different. 

0 Kudos
Message 4 of 12
(4,504 Views)

I understood that part, the detail is that Teststand needs you to format the file in certain way to be able to import the parameters directly to the variables of a step. Now, alternatively you could create a VI in LabVIEW (or a little program in another programming language) that processes the .csv files in such a way that you can manipulate the data from the file as an output of such program. Then you can import it to Teststand in an action step and save the values to the type of variable that you see fit for your sequence.

 

I believe that could be easier.

0 Kudos
Message 5 of 12
(4,496 Views)

@TonyJ wrote:

The order is always the same with a name starting with Gain1, 0x??? followed by an Offset1, 0x???, where ? = a hex number, until the last Gain12, 0x???,Offset12,0x???. In my actual file, each gain has a unique name like LTA_Gain or LTA_Offset or AA_Gain or AA_Offset etc. But the order and names are always the same. Only the hex numbers will be different. 


What do you want to do with these values?  Are you using them as limits for a step or as parameters to something?  I guess my question is why do you need them in TestStand and where do you want to put them?

 

Cheers,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 6 of 12
(4,494 Views)

At the beginning of my sequence I save the PCBA Gains and Offsets to a .csv file via a DOS batch file. During the flash process if a failure is detected  (bootloader or app) the board switches to default values and the original values from a previous process (functional test) are lost. I want to pass those values in the textfile and rewrite the Gains and Offsets after the board fails. This occurs in a post flash process after the board is passed thru a repair loop. Once a board fails flash its ability to communicate via CAN is no longer possible. Each Gain and Offset once passed after the repair loop and a successful flash will have it's original Gains and Offsets rewritten. 

0 Kudos
Message 7 of 12
(4,483 Views)

How are you going to write the values back to the flash?

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 8 of 12
(4,471 Views)

I actually will write the values to EEPROM. Once the product software is rewritten there is a safety feature on the final product which blanks out the Gains/Offsets and place defaults there. I guess I'm confusing you because of the flash operation. I will reflash these failed boards and after a power cycle the internal firmware will load default values in EEPROM. Each flash operation before I do anything I save the Gains/Offsets to a .csv file. Only boards which failed flash will be reflashed and loaded with their original Gains/Offsets. I have 2 test sequences. The second of which will only test failed boards, read the .csv file and write the Gains/Offsets using CAN. I want to copy .csv file values into local variables of which I can then build my CAN messages. Thanks for your patience. 

0 Kudos
Message 9 of 12
(4,461 Views)

If it were me I would just create a VI in LabVIEW that reads in the text file and pushes it out to flash through CAN.  That way I wouldn't need to put them in a TestStand Variable.

 

However, if that is not an option then you need to use a code module to read in the file and then assign the variables to the output of the code modules.  Which programming language are you using to do your CAN or is it all through IVI steps or some other custom step?

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 10 of 12
(4,455 Views)