ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll function not working

Solved!
Go to solution

Hi all,
I'm trying to use dlls function, and one of them always returns 1 (error), and I don't know if i'm doing womething wrong.

the datasheet of the dll says :

 

Prototype: int WINAPI rf_M1_authentication2 ( unsigned short icdev,

unsigned char model,

unsigned char block,

unsigned char *pKey)

Parameter: icdev: [IN] Device ID

model: [IN] key validate mode

block: [IN] block absolute address

pKey: [IN]

6 bytes password

Return: return 0 if successful

Explanation:model = 0x60: via KeyA

model = 0x61: via KeyB

 

The prototype of my function is :

int32_t rf_M1_authentication2(uint8_t icdev, uint8_t model, uint8_t block, uint8_t *pKey);

 

Any idea ?

 

Thanks,

V-F
0 Kudos
Message 1 of 9
(4,530 Views)

A short int is usually 16 bits (2 bytes), not a U8.  Can you share your LabVIEW code demonstrating how you're calling the DLL?

0 Kudos
Message 2 of 9
(4,524 Views)

Hi,

thanks for your reply, yes it is an U16.  this is my code :
dll.png

 

I joined the dll (renamed in .txt.)

V-F
0 Kudos
Message 3 of 9
(4,508 Views)

P.S. The VB code (which works) is :

state = rf_init_com(3,115200);

WORD icdev = 0x0000;

unsignedchar mode = 0x60;

unsignedchar secnr = 0x00;

// int state;

CString strKey;

unsignedchar pData[MAX_RF_BUFFER];

unsignedchar cLen;

 

 

strKey ="ÿÿÿÿÿÿ";

secnr = 0;

state = rf_M1_authentication2(icdev,mode,(secnr/4)*4,(unsignedchar*)strKey.GetBuffer(strKey.GetLength()));

state = rf_M1_read(icdev,secnr,pData,&cLen);

rf_ClosePort();

V-F
0 Kudos
Message 4 of 9
(4,504 Views)

You said one of the them always returns a 1. Which one? I don't know if this makes any difference in your specific case, but the baud rate in your LabVIEW code does not match the baud rate in the VB code.

0 Kudos
Message 5 of 9
(4,486 Views)

Hi,

it's of course the  rf_M1_authentication2 function.

I tried with others comunucation speeds, but this doesn't change anything...

V-F
0 Kudos
Message 6 of 9
(4,481 Views)
0 Kudos
Message 7 of 9
(4,479 Views)
Hi,
V-F
0 Kudos
Message 8 of 9
(4,448 Views)
Solution
Accepted by ramses64

Hi,

I finally found the solution by using Labview calls to place my array in a memory area, and transmit the pointer to my dll. Here is the code :


Capture.PNG

 

Thanks to all !

 

V-F
0 Kudos
Message 9 of 9
(4,448 Views)