Software
.NET programming languages
(c) Spectrum GmbH
51
.NET programming languages
Library
For using the driver with a .NET based language Spectrum delivers a special library that encapsulates the driver in a .NET object. By adding
this object to the project it is possible to access all driver functions and constants from within your .NET environment.
There is one small console based example for each supported .NET language that shows how to include the driver and how to access the
cards. Please combine this example with the different standard examples to get the different card functionality.
Declaration
The driver access methods and also all the type, register and error declarations are combined in the object Spcm and are located in the DLL
SpcmDrv.NET.dll delivered with the .NET examples. Spectrum also delivers the source code of the DLL as a C# project. Theses sources are
located in the directory SpcmDrv.NET.
Using C#
The SpcmDrv.NET.dll needs to be included within the Solution Explorer in the References section. Please use right mouse and select „AddRef-
erence“. After this all functions and constants of the driver object are available.
Please see the example in the directory CSharp as a start:
Example for digitizerNETBOX and remotely installed cards:
namespace Spcm
{
public class Drv
{
[DllImport("spcm_win32.dll")]public static extern IntPtr spcm_hOpen (string szDeviceName);
[DllImport("spcm_win32.dll")]public static extern void spcm_vClose (IntPtr hDevice);
...
public class CardType
{
public const int TYP_M2I2020 = unchecked ((int)0x00032020);
public const int TYP_M2I2021 = unchecked ((int)0x00032021);
public const int TYP_M2I2025 = unchecked ((int)0x00032025);
...
public class Regs
{
public const int SPC_M2CMD = unchecked ((int)100);
public const int M2CMD_CARD_RESET = unchecked ((int)0x00000001);
public const int M2CMD_CARD_WRITESETUP = unchecked ((int)0x00000002);
...
// ----- open card -----
hDevice = Drv.spcm_hOpen("/dev/spcm0");
if ((int)hDevice == 0)
{
Console.WriteLine("Error: Could not open card\n");
return 1;
}
// ----- get card type -----
dwErrorCode = Drv.spcm_dwGetParam_i32(hDevice, Regs.SPC_PCITYP, out lCardType);
dwErrorCode = Drv.spcm_dwGetParam_i32(hDevice, Regs.SPC_PCISERIALNR, out lSerialNumber);
// ----- open card -----
hDevice = Drv.spcm_hOpen("TCPIP::192.168.169.14::INST0::INSTR");