NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable Type Defined , no support "char" & "FILE *" ???

Hi
 
Execute me ~  May I ask some question about teststand4.0
 
I want to defined variable on teststand environment
 
but I don't find "char" & "FILE *" type
 
Don't support those types on teststand ?
 
 
I want to defined those types,  and pass those variable to external DLL(by address)
 
DLL be builded with Visual C++6.0 (use C language)
 
example in DLL process :
int  __declspec(dllexport) __stdcall  Function_BeCall_By_TestStand(FILE *fptr , char *word)
 
So, I must create the same type of variable on teststand,  to mach DLL function
 
 
Someone can give me some suggestion?!  thanks
 
best regards!!!!!
 
0 Kudos
Message 1 of 11
(5,254 Views)
An address is really a special kind of integer so you can use the TestStand Number data type and pass a 32-bit integer for that parameter into and out of your functions.

Is your char * parameter pointing to a string or just an array of bytes? If it's a string you should use a TestStand String with that parameter and configure the string passing options as appropriate when specifing your module. If it's not a string and just an array of bytes or a pointer to a single byte then you should use the Number data type or Array of Numbers data type instead.

Hope this helps,
-Doug


Message Edited by dug9000 on 02-15-2008 10:05 AM
0 Kudos
Message 2 of 11
(5,239 Views)

thnaks for dug9000's answer

My idea :

(char *)  is pass a signal character's address to DLL

use Number type ?

Can you teach setting about this case

Singal character is 1 byte space

Following this window, How to seeting...

http://img183.imageshack.us/img183/5483/howtp7.jpg

 

thanks , best regards

0 Kudos
Message 3 of 11
(5,218 Views)
The numeric format doesn't matter as far as passing the data in or out of your code modules. For that you just need to configure your module specification correctly for the adapter. If in your module char * is just a pointer to a single character, since a single character is just stored as an 8-bit integer you need to set the module specification to be an 8-bit integer passed by pointer (see attached screenshot from dll adapter module setting).

Numeric format on the otherhand is just for display purposes. If you want the variable to display inside teststand as the actual character and not the numeric value that represents the character then you should check the Custom checkbox in the numeric format dialog and use %c.

Hope this helps,
-Doug
0 Kudos
Message 4 of 11
(5,181 Views)
Hi  Dug9000
 
thanks for your help
 
I try your way to run, but still have some questions.
 
Module on TestStand setting as below image :
I already done setting follow your suggestion
 
 
Numeric format dialog setting as below image :
 
but , I find a bug
I done some setting in  Numeric format dialog , then press "OK" button
After Numeric format dialog already close, I open Numeric format dialog again
Setting auto convert this status as below image :
 
Can you help me about this case ?!
 
though program can execute ,  but "wirte data(char type) into *.txt" is fail....
 
best regards
thanks ^_^
0 Kudos
Message 5 of 11
(5,168 Views)

Oh My God......

Sorry!!! is my mistake

I find a bug in DLL(C program)

so,  already can write char into *.txt correctly

thanks a lot !!!

by the way, if I want to write char , I need convert char to decimalization ???

example : 'M' = 77 , I must 77 to Sample space? 

0 Kudos
Message 6 of 11
(5,166 Views)


@stockton wrote:

Oh My God......

Sorry!!! is my mistake

I find a bug in DLL(C program)

so,  already can write char into *.txt correctly

thanks a lot !!!

by the way, if I want to write char , I need convert char to decimalization ???

example : 'M' = 77 , I must 77 to Sample space? 




I'm not sure I completely understand what you are asking, but I will try to explain. Numeric formats are purely for display purposes. If you want to manually set the value of the variable in teststand you will still need to enter 77 in the variables view for that variable if you want the character 'M'.

If you are asking about how to write data to a file, if you create the file as a text file and write the character to it, what's really happening is that you are writing a byte with the value 77 to the file. However when you view the file with a text editor or viewer, that program knows to interpret the bytes as text and therefore shows you 'M' instead of 77.

Hope this helps. Glad you got the parameter passing working. The screen shots look correct.

-Doug
0 Kudos
Message 7 of 11
(5,145 Views)

thnaks your response

Good answer of you

thanks you !!!

these suggestion help me more than more  ^^

0 Kudos
Message 8 of 11
(5,130 Views)
Hi dug9000
 
excuse me
 
over and above 'char' type , I clear solution about another 'FILE *' type not yet
 
I already try to ask NI engineer, but I still un-understand his answer
 
May I ask to you about this case?
 
in TestStand , setting as follow image :
define customer data type - unsigned 32 bits integer
and pass address to external DLL
 
Then
My DLL have two function , source cod as :
 
/* This Function's purpose is CREATE FILE */
int __declspec(dllexport) __stdcall TID_Fopen(int *fptr)        
{  
        FILE *localFilePtr = (FILE *)fptr;
        localFilePtr=fopen("test.txt","w+r");
        return 0;
}
 
/* This Function's purpose is WRITE STRING TO FILE , THIS FILE ALREADY BE OPEN BY ANOTHER DLL */
int __declspec(dllexport) __stdcall TID_Write1(int *fptr)
{  
         FILE *localFilePtr = (FILE *)fptr;
         fprintf(localFilePtr," TEST !!!!!!!! \n");
         return 0;
}
 
 
SO, I run this case
PASS during execute TID_Fopen DLL
but, FAIL during TID_Write1 DLL
 
I don't know how to debug....
Have you any suggestion for me?!
 
thanks ^^
best regards !!!
0 Kudos
Message 9 of 11
(5,111 Views)
Try the following:

int __declspec(dllexport) __stdcall TID_Fopen(DWORD *fptrAsIntegerOutput)       

        *fptrAsIntegerOutput = (DWORD) fopen("test.txt","w+r");
        return 0;
}
 
int __declspec(dllexport) __stdcall TID_Fclose(DWORD fptrAsInteger)       
{
        FILE *fptr = (FILE*)fptrAsInteger;
        return fclose(fptr);
}

int __declspec(dllexport) __stdcall TID_Write1(DWORD fptrAsInteger)

        FILE *fptr = (FILE*)fptrAsInteger;
        return fprintf(fptr, " TEST !!!!!!!! \n");
}

NOTE: Once there is a 64-bit version of TestStand and if you recompile your DLL as a 64-bit DLL, you will need to change the data type to a 64-bit integer rather than a 32-bit integer because in 64-bit code addresses are 64-bits.

Delete the FILE data type you created. You don't need that.

Hope this helps,
-Doug


Message Edited by dug9000 on 02-21-2008 11:28 AM
0 Kudos
Message 10 of 11
(5,096 Views)