NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to specify in TS unsigned long? unsigned short?

Hi,
 
I'm lusing a c/c++ step type from TestStand.
I need to use a structure whose fields according to the h file of the dll are:
unsigned char
unsigned long
unsigned short
 
Now, when I define a container in TestStand (to interface with the dll structure) my options are:
integer
unsigned integer
etc...
 
What am I supposed to do ?  what is the appropriate numeric format? 
 
Thanks
 
0 Kudos
Message 1 of 14
(6,909 Views)
Rafi,

8-bit integer = char
16-bit integer = short
32-bit integer = long

So use the unsigned versions of those in TestStand.

Allen P.
NI
0 Kudos
Message 2 of 14
(6,907 Views)

Hi Allan and thanks,

The only options in TS for numeric variables (that I can see) are integer and unsigned integer (and of course real..).

Therefore, I'm still confused as to what to use to match the dll variables:  unsigned char, unsigned short and unsigned long.

Please clarify

Thanks

Rafi

0 Kudos
Message 3 of 14
(6,888 Views)
The numeric format of a variable is purely for display purposes (unsigned int will probably be fine for all of the types you care about, or even leaving the default numeric format is probably fine too).

However, the important place to get the setting right is in your module specification. In you module specification use:

unsigned 8-bit integer - for unsigned char
unsigned 16-bit integer - for unsigned short
unsigned 32-bit integer - for unsigned long or int

The module specification is the important part because that tells teststand how to convert the number to the way teststand internally stores them. TestStand really stores all of these data types the same way, the numeric format just shows the number a different way for display purposes.

Hope this helps,

-Doug


Message Edited by dug9000 on 05-08-2008 12:57 PM
0 Kudos
Message 4 of 14
(6,851 Views)
Hi Doug
 
just one more question.
 
How does Teststand internally stores the numbers ?
On one hand they can be floating points on the other interger.
 
Greetings
 
Juergen
 
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 5 of 14
(6,834 Views)
In TestStand number variables everything is currently stored as a double (64-bit floating point number). A double has enough precision to store 32-bit integers (both signed and unsigned). This might change at some point in the future, but that is the current internal representation. That is why, through the API, when you call GetValNumber and SetValNumber you are always dealing with doubles.

Hope this helps,
-Doug
Message 6 of 14
(6,822 Views)

Hi Doug,

I'm given the dll and load of h files.  The definitions you mentioned are not shown...

Suppose I want to creat in TS a container to match variable FCPortConfig.  This variable structure is given here....

typedef struct tagFCPortConfig
{
 unsigned char  ucTopology;    /* For Point-To-Point use TOPOLOGY_PT_2_PT
              and for LOOP Topology use TOPOLOGY_LOOP */
 unsigned char  ucSpeed;     /* SPEED_1GHZ, SPEED_2GHZ       */
 unsigned char  ucDisableTimer;  /* (Not Currently Used) enable or disable
              timeout timer          */
 unsigned long  ulRRDYGap;    /* (Not Currently Used) up to a 27-bit val */
 unsigned long  ulRRDYGapRandomEnable;/* (Not Currently Used)enable/disable   */
 unsigned long  ulRRDYGapSeed;   /* (Not Currently Used) If random set;
              a 27-bit val          */
 unsigned long  ulRRDYGapMin;   /* (Not Currently Used) If random set;
              a 27-bit val          */
 unsigned long  ulRRDYGapMax;   /* (Not Currently Used) If random set;
              a 27-bit val          */
 unsigned char  ucAutoNegotiate;  /* (Not Currently Used) enable or disable
              auto negotiation         */
 unsigned short uiBBCreditConfigRx; /* BB_credit this port will advertise   */
 unsigned char  ucStatsMode;   /* Determines weather or not to retrieve
                                          the extended stats counters, use
                                          STATS_MODE_NORMAL & STATS_MODE_EXTENDED */
 unsigned char  ucReserved[15];  /* Reserved */
} FCPortConfig;

 

 

1) Is there a way to find out how they define unsigned char, unsigned short and unsigned long?

2) Can I still use the TS default numeric type?

 

Thanks

Rafi

0 Kudos
Message 7 of 14
(6,801 Views)
Hi again,
 
The only thing close to what we're looking for that I could find is....
 
typedef  unsigned char  BYTE;    /*  8-bit byte */
typedef  unsigned short WORD;    /* 16-bit word */
typedef  unsigned long  DWORD;   /* 32-bit double word */
It's really a definition of BYTE, WORD and DWORD, but we can see that the dll uses usigned long as 32-bit, unsigned short as 16-bit and unsigned char as 8-bit.
Is that enough for my purpose?
I defined all number types to unsigned integer for now
 
What do you think?
 
Thanks
Rafi
0 Kudos
Message 8 of 14
(6,799 Views)
To specify the size of the struct members in TestStand, you have to use the C Struct Passing Tab on the Type Properties Dialog Box. For each Number property in the container, you specify one of the numeric types (signed 8-bit integer, unsigned 8-bit integer, etc.). As Allen mentioned, char is 8-bit integer, short is 16-bit integer and long is 32-bit integer.
0 Kudos
Message 9 of 14
(6,779 Views)
Ok, Rafi. I didn't realize you were trying to specify types for a structure definition. Follow Erik's instructions to create a custom type that is equivalent to your structure.

Let me add a little to those instructions.

1) You need to create an equivalent custom data type in teststand for your structure.
2) Using the type properties dialog (NOT the numeric format dialog) turn on structure passing for your type and specifiy the equivalent C/C++ data type for each field.
3) Create an instance of this custom type as a local variable or where ever you want it.
4) pass that instance into your dll.
5) Again, this is completely separate from the numeric format. Leaving the numeric format with its default setting is fine.

-Doug


Message Edited by dug9000 on 05-12-2008 10:31 AM
0 Kudos
Message 10 of 14
(6,772 Views)