NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluating binary strings with "Don't care" conditions

I frequently have to evaluate binary strings or register values for particular bits. Does anyone have a better way? And if not, perhaps this is a suggestion for NI.

 

To this point I've used two methods:

 

1. I turn the data into an actual string in my CVI code and inject X's in the necessary positions. I then perform a string evaluation for equivalence, the string now consisting of '1's '0's and 'x's.

 

2. Bring the data into the teststep and applying an expression to the data source, masking the appropriate bits. Then evaluate as a numeric with a value that assumes the offended bits "zeroness" or "oneness" depending on how I've implemented.

 

The first was one requires specialized code, but allows for a little more visibility (in the code at least) of which bits are designated as DCs. But translating a multiple byte and variable length of amount of information into a string is cumbersome. Sure the code is reusable, but I'm not convinced the translation is necessary or best.

 

The second buries the mask in a window that is, seemingly, infrequently used. I've had colleagues work on a project behind me trying to figure out where the value was being manipulated because I've applied a mask via the source. My original explanation of "ninjas" wasn't well taken...

 

It seems like it would be ideal for the limits window to allow the use of "X"s when defining a "binary" type comparison so that the mask is clearly defined in the limit itself, and the data as it's passed to and from teststand remains untouched. Also, if this were to be implemented I would hope the property loader would support it.

 

Am I missing a much easier way to do this? Anyone have a better way?

 

Thanks in advance!

Colt.

 

P.S. Why isn't "NI" and "CVI" built into the spell checker?

0 Kudos
Message 1 of 6
(4,722 Views)

Hello Colt,

 

Can you clarify whether you are trying to use the X's as "dont-cares" in your binary string or whether instead you are trying to bring attention to the particular bit(s) wthin the entire string that you wish to compare?  Thanks in advance!

0 Kudos
Message 2 of 6
(4,693 Views)

So in that first case where I am using CVI to "insert" I am building a string type vector that contains ASCII '1's '0's and 'x's. Where the Xs are in the binary position for what I am considering as "don't care".

 

So say for instance I was converting a piece of data that was 0xEB, with bit 0 being considered a DC for evaluation, I would build a string like "1110 101X" . This string is what I would pass back to teststand. In teststand I would then perform an equivalence test between the two strings.

 

For the second question about an implementation for the limit, say I open the test step, click on "Edit Limits" then from the drop down in the bottom right I select "Binary". I could then compose a limit in a similar form as described above. Where the limit box could contain something like "0b1110101X". But as for the data I hand to teststand, it would still be just a scalar value, with no masks applied. In the code, or in teststand.

 

Sorry if I'm not making any sense! I hardly ever do...

Colt.

 

0 Kudos
Message 3 of 6
(4,690 Views)

I would handle the binaries as numbers and just set the "don't cares" to a fixed value ob both sides of the comparison with a bitwise OR.

Something like: (value | dont_care_mask) == ( comparison | dont_care_mask)

 

0 Kudos
Message 4 of 6
(4,674 Views)

That's a good idea, but it seems like this would limit your method of evaluation to be done soley in pass/fail type steps, which I don't would provide you with the same type of visibility in report generation that you'd get from other step types. At least not without doing something special. But, you're right in that it would make the mask move visible for maintenance purposes.

 

That was reaally the goal for the string conversion is that for report generation purposed everything used in the evaluation was easily reported.

0 Kudos
Message 5 of 6
(4,662 Views)

Hello Colt,

 

Have you contemplated creating a custom step type based off of the pass/fail step but which incorporates the report visibility you are desiring?  This might be one way to achieve the functionality you are looking for.

0 Kudos
Message 6 of 6
(4,632 Views)