07-21-2012 03:26 PM
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,
Solved! Go to Solution.
07-21-2012 04:28 PM
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?
07-22-2012 01:29 AM
Hi,
thanks for your reply, yes it is an U16. this is my code :
I joined the dll (renamed in .txt.)
07-22-2012 02:53 AM
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();
07-22-2012 07:51 AM
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.
07-22-2012 09:04 AM
Hi,
it's of course the rf_M1_authentication2 function.
I tried with others comunucation speeds, but this doesn't change anything...
07-22-2012 09:20 AM
http://www.ni.com/white-paper/4877/en#toc4
may be useful
07-25-2012 09:10 AM
07-25-2012 09:10 AM - edited 07-25-2012 09:12 AM
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 :
Thanks to all !