Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Before ending the application, the handles should be closed again, using the corresponding close functions.

...

x86 versus x64

The application or the wrapper can be compiled for both (64bit and 32bit) systems.

Depending on the target system, it's only needed to load the correct DLL of the CIFX driver. Both DLL versions are provided in the CIFX driver package.

Performance & PLC

...

functions

In principle, the PLC functions are intended for high-performance applications with high timing requirements. The use of .NET itself is less suitable for such requirements.
Windows is not real-time capable by default and does not offer the possibility of influencing the time behavior of a process sufficiently.

...

The use of .NET is not recommended for applications in this context. Accordingly, the PLC functions of the CIFX API are not supported in the C # framework.

Hilscher - C#

...

Packet

Hilscher provides a VisualStudio project that implements the P/Invoke frame.

Link to Demo Project:

C#.NET Demo


Within the cifXUser class, all CIFX API functions are made usable in the project. In addition, some standard structures of the CIFX API and constants are available.

...

Using an example project, the demo also shows the integration of the wrapper DLL into an application.

Info
titleHinweisNote

With .NET or VisualStudio it is possible to use both C # .NET and VB.NET projects within a VisualStudio solution.

To do this, a project of the corresponding type can simply be added: File → Add → New Project.

...

"In .NET there is an integral data type, not widely known, that is specifically designated to hold 'pointer' information: IntPtr whose size is dependent on the platform (eg, 32-bit or 64-bit) it is running on. "

Code Block
titleBeispielExample
public void SizeOfIntPtr() {Console.WriteLine( "SizeOf IntPtr is: {0}", IntPtr.Size );}

...

On a 64-bit platform the output looks like this:

SizeOf IntPtr is: 8"

...

Solution

In the old code, some function parameters were set as 32-bit parameters.

In the new version, the pointers described above are used instead, in order to work for both 32-bit and 64-bit applications.

Code Block
titleAltOld
[DllImport("cifx32dll.dll", EntryPoint = "xChannelOpen")] 

private static extern UInt32 _xChannelOpen(

UInt32 hDriver,

[MarshalAs(UnmanagedType.LPStr)] string szBoard,

UInt32 ulChannel,

[MarshalAs(UnmanagedType.U4)] ref UInt32 phChannel);


Code Block
titleNeuNew
[DllImport("cifx32dll.dll",EntryPoint = "xChannelOpen")]

private static extern Int32 _xChannelOpen (

IntPtr hDriver,

[MarshalAs(UnmanagedType.LPStr)] string szBoard,

UInt32 ulChannel,

ref IntPtr phChannel);

...