NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing char type variables from TS3.5 to C/C++ dlls

Hi,

I am using TS 3.5 and i am calling a dll which has an input type of char. according to dll's datasheet i need to enter a character like 'n' . But TS doesn't accept it. I tried to enter 116 (Ascii code of 'n') but it didn't work either.

I am really confused while defining type of char type variables. I found out that TS assumes integer type variables as char but what about char variables.

Any help is appreciated generously 🙂

0 Kudos
Message 1 of 6
(3,436 Views)

You will want to check out the following article:

 

How Can I Get the Character Representation of an ASCII Number in TestStand?

http://digital.ni.com/public.nsf/allkb/534E7A7C52D6223586256B9200543A83?OpenDocument

0 Kudos
Message 2 of 6
(3,424 Views)

In C/C++ a variable of type char is just a 1-byte integer. It's a matter of interpretation of that integer whether or not it indicates a particular letter.

 

The ascii code for n is 110. Perhaps this is the problem you are having? Also there is a TestStand expression function you can use instead if you prefer as follows:

 

Asc("n")

 

Hope this helps,

-Doug

0 Kudos
Message 3 of 6
(3,422 Views)

Unfortunately this is not what i am looking for. The dll prototype requests char type variables. So i cannot define it as a String (const *char) in TS, dll doesn't work with this method. Somehow i have to send 'n' character. I tried to send 116 which is the ascii number of n but even it didn't work

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

Note: My previous reply was for Online Courses not Doug also another update i didn't write 116 for 'n', i tried 110 as Doug adviced

0 Kudos
Message 5 of 6
(3,420 Views)

Both 110 and Asc("n") should work. What is the exact prototype of your C function and what do you have it specified as in the Dll/C++ adapter?

 

If you have a parameter like the following:

 

void myfunc(char mycharparam)

 

You should specify it as a Number, by value, signed 1-byte integer.

 

-Doug

0 Kudos
Message 6 of 6
(3,411 Views)