
Software
Driver functions
(c) Spectrum Instrumentation GmbH
47
Linux Gnu C/C++ 32/64 Bit
Include Driver
The interface of the linux drivers does not differ from the windows interface. Please include the spcm_linux.lib library in your makefile to have
access to all driver functions. A makefile may look like this:
Examples
The Gnu C/C++ examples share the source with the Visual C++ examples. Please see above chapter for a more detailed documentation of
the examples. Each example directory contains a makefile for the Gnu C/C++ examples.
C++ for .NET
Please see the next chapter for more details on the .NET inclusion.
Other Windows C/C++ compilers 32 Bit
Include Driver
To access the driver, the driver functions must be loaded from the 32 bit driver DLL. Most compilers offer special tools to generate a matching
library (e.g. Borland offers the implib tool that generates a matching library out of the windows driver DLL). If such a tool is available it is
recommended to use it. Otherwise the driver functions need to be loaded from the dll using standard Windows functions. There is one exam
-
ple in the example directory /examples/c_cpp/dll_loading that shows the process.
Example of function loading:
Other Windows C/C++ compilers 64 Bit
Include Driver
To access the driver, the driver functions must be loaded from the 64 bit the driver DLL. Most compilers offer special tools to generate a match
-
ing library (e.g. Borland offers the implib tool that generates a matching library out of the windows driver DLL). If such a tool is available it
is recommended to use it. Otherwise the driver functions need to be loaded from the dll using standard Windows functions. There is one
example in the example directory /examples/c_cpp/dll_loading that shows the process for 32 bit environments. The only line that needs to
be modified is the one loading the DLL:
Example of function loading:
Driver functions
The driver contains seven main functions to access the hardware.
Own types used by our drivers
To simplify the use of the header files and our examples with different platforms and compilers and to avoid any implicit type conversions we
decided to use our own type declarations. This allows us to use platform independent and universal examples and driver interfaces. If you
do not stick to these declarations please be sure to use the same data type width. However it is strongly recommended that you use our defined
COMPILER = gcc
EXECUTABLE = test_prg
LIBS = -lspcm_linux
OBJECTS = test.o\
test2.o
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(COMPILER) $(CFLAGS) -o $(EXECUTABLE) $(LIBS) $(OBJECTS)
%.o: %.cpp
$(COMPILER) $(CFLAGS) -o $*.o -c $*.cpp
hDLL = LoadLibrary ("spcm_win32.dll"); // Load the 32 bit version of the Spcm driver
pfn_spcm_hOpen = (SPCM_HOPEN*) GetProcAddress (hDLL, "_spcm_hOpen@4");
pfn_spcm_vClose = (SPCM_VCLOSE*) GetProcAddress (hDLL, "_spcm_vClose@4");
hDLL = LoadLibrary ("spcm_win64.dll"); // Modified: Load the 64 bit version of the Spcm driver here
pfn_spcm_hOpen = (SPCM_HOPEN*) GetProcAddress (hDLL, "spcm_hOpen");
pfn_spcm_vClose = (SPCM_VCLOSE*) GetProcAddress (hDLL, "spcm_vClose");
Содержание M2p.59 Series
Страница 190: ......