NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

c++ array of unsigned char from dll

Solved!
Go to solution

Hi TestStand Users, maybe somebody already had this issue and may help me 😉

 

I'm trying to get an unsigned char array out of my dll...

 

my function looks like that:

 

typedef unsigned char _U_BYTE;    /* 8 bit unsigned integer data type */

typedef unsigned long _U_DWORD;    /* 32 bit unsigned integer data type */

 

_BOOL Function1(  _U_DWORD *udwMCM, _U_DWORD *udwSCM, _U_BYTE *ubyINFSEL, _U_BYTE *aubyINFDATA[10], _U_BYTE *ubyEC )
{...
  gstorm_sCMD_0A_ACK_t *CMD_0A_ACK = (gstorm_sCMD_0A_ACK_t*)ReceiveItem->aubyTelegram;
  *udwMCM = _ean_fSwap4Byte(CMD_0A_ACK->udwMCM, _ean_Unknown);
  *udwSCM = _ean_fSwap4Byte(CMD_0A_ACK->udwSCM, _ean_Unknown);
  *aubyINFDATA = CMD_0A_ACK->aubyINFDATA;
  *ubyINFSEL = CMD_0A_ACK->ubyINFSEL;
  *ubyEC = gstorm_eEC_No_Error
}

 

 

my IDL:

 

[entry("")] _BOOL Function1(  [in, out] _U_DWORD *udwMCM, [in, out] _U_DWORD *udwSCM, [in, out] gstorm_eINFSEL_t *eINFSEL, [out] _U_BYTE *aubyINFDATA[10], [out] gstorm_eEC_t *eEC );

 

 

 

In Teststand brings up following Warning:

 

"...uses Types not recognized by TestStand"

"...aubyINFDATA is of an unsupported Type"

 

 

Do I have to use a different data type in the IDL? Like LPSTR for Strings (const char*)?

 

 

 

btw. : I am using VC++ and TestStand 2012

0 Kudos
Message 1 of 5
(4,284 Views)

I'm not sure what the right thing to put in the type library is, but the call will work if you specify the parameter as an array of 1-byte integers in teststand. You could maybe make the data type of the parameter be the following, but you will lose the information about the number of elements and that it's really an array:

 

_U_BYTE **aubyINFDATA
0 Kudos
Message 2 of 5
(4,272 Views)

Thx for the answer.

 

_U_BYTE **aubyINFDATA

 

still causes the same error.

 

Enough for today, next try tomorrow!

 

 

0 Kudos
Message 3 of 5
(4,263 Views)
Solution
Accepted by topic author dagger1987

I have to think over my Programming skills!

 

It hit me like a hammer Smiley Tongue

 

*aubyINFDATA = CMD_0A_ACK->aubyINFDATA;

 

wont work for an array copy *damnidiot*


the solution:

 

memcpy(*aubyINFDATA,CMD_0A_ACK->aubyINFDATA,sizeof(aubyINFDATA));

 

 

also, I thought every Output in an IDL needs to be a Pointer.

Arrays doesn't 😉 , but if I wanted i could use

 

[out] _U_BYTE (*aubyINFDATA)[10]

 

but

 

[out] _U_BYTE aubyINFDATA[10]

 

works fine!

 

 

At least my fault!

 

Thanks for help anyway!

Message 4 of 5
(4,246 Views)

Hi,

 

thank you for posting the solution 🙂

0 Kudos
Message 5 of 5
(4,231 Views)