Forum / MIFARE and NFC Reader IC`s / Using unmanaged NxpRdLib DLL
Tagged: unmanaged dll nxprdlib
-
I am trying to control a NXP RD701 Reader from a C# program with the NxpRdLib.dll.
When I launch the code below, the message box shows every time "288" and all variables of balRd70x have the value as initially. Can someone help me?
public static phbalReg_Rd70xUsbWin_DataParams_t balRd70x;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct phbalReg_Rd70xUsbWin_DataParams_t
{
internal ushort wId;
internal byte ucTxSeq;
[MarshalAs(UnmanagedType.LPStr)]
internal string pDeviceName;
internal IntPtr pDeviceHandle;
internal IntPtr pPipeOut;
internal IntPtr pPipeIn;
internal ushort wTimeoutWrMs;
internal ushort wTimeoutRdMs;
}
[DllImport("NxpRdLib.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "phbalReg_Rd70xUsbWin_Init")]
public static extern ushort phbalReg_Rd70xUsbWin_Init (ref phbalReg_Rd70xUsbWin_DataParams_t pDataParams, ushort wSizeOfDataParams);
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(connectToPegoda().ToString());
}
public static unsafe ushort connectToPegoda()
{
balRd70x = new phbalReg_Rd70xUsbWin_DataParams_t();
ushort wSizeOfDataParams = (ushort)Marshal.SizeOf(typeof(phbalReg_Rd70xUsbWin_DataParams_t));
return phbalReg_Rd70xUsbWin_Init(ref balRd70x, wSizeOfDataParams);
}
+ 0 | - 0
I forgot to join the definition of phbalReg_Rd70xUsbWin_DataParams_t
+ 0 | - 0
Hi Gaëtan,
I have never used the library from C#. But for me it seems that you do not initialize the library correct. As a recommendation you should test the functionality first with the enclosed test program and if everything works, go and move your code to C#.
Kind regards,
The MIFARE Team
+ 0 | - 0
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.