1,8 → 1,28 |
#include <ansi_c.h> |
#include "wienvme_dll.h" |
#include <stdlib.h> |
#include <stdio.h> |
|
#ifdef _CVI_ |
#include <utility.h> |
#endif |
|
#ifdef LINUX |
#include <dlfcn.h> |
#define LoadLibrary(x) dlopen( (x), RTLD_NOW ); |
#define GetProcAddress(x,y) dlsym((x),(y)) |
static int GetCurrentPlatform(void ){return 0;}; |
#define __stdcall |
#define UCHAR unsigned char |
#define HINSTANCE void * |
#define _VI_FUNC |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdint.h> |
#include <string.h> |
#endif |
|
#include "wienvme_dll.h" |
//----------- DEFINES ----------------------------------------------------- |
#define DEVICENAME_LINUX "/dev/pcivme_0" // a device name 'template' for WINNT |
#define DEVICENAME_NT "\\\\.\\PCIVME:\\VMEMMxx" // a device name 'template' for WINNT |
#define DEVICENAME_9X "\\\\.\\C:\\windows\\system\\VWIENVMED.vxd" // the same for WIN95/98 |
#define MODULE_NUMBER 1 // number of connected CC32 module |
21,8 → 41,10 |
int hHandle24, hHandle32; |
int VMEmodule; |
|
static HINSTANCE DLLHandle; |
void WIENVME_load (char* module_path) |
{ |
/* |
int stat; |
|
if (module_path == NULL) |
30,12 → 52,28 |
("c:\\home\\CVI\\instr\\WIENVME_DLL\\pcivme_ni.lib"); |
else |
VMEmodule = LoadExternalModule (module_path); |
|
|
vme_init = GetExternalModuleAddr (VMEmodule, "VMEinit", &stat); |
vme_read = GetExternalModuleAddr (VMEmodule, "VMEread", &stat); |
vme_write = GetExternalModuleAddr (VMEmodule, "VMEwrite", &stat); |
vme_reset = GetExternalModuleAddr (VMEmodule, "VMEreset", &stat); |
vme_close = GetExternalModuleAddr (VMEmodule, "VMEclose", &stat); |
*/ |
if (module_path == NULL) { |
DLLHandle = LoadLibrary("c:\\home\\CVI\\instr\\WIENVME_DLL\\pcivme_ni.lib"); |
} else { |
DLLHandle = LoadLibrary(module_path); |
} |
if (!DLLHandle) { |
printf ("\n\nFailed to Open libxxusb.dll \n"); |
return; |
} |
|
vme_init = (void *) GetProcAddress (DLLHandle , "VMEinit"); |
vme_read = (void *) GetProcAddress (DLLHandle , "VMEread"); |
vme_write =(void *) GetProcAddress (DLLHandle , "VMEwrite"); |
vme_reset =(void *) GetProcAddress (DLLHandle , "VMEreset"); |
vme_close =(void *) GetProcAddress (DLLHandle , "VMEclose"); |
|
return; |
} |
49,6 → 87,8 |
if (device_name == NULL) |
switch (GetCurrentPlatform ()) |
{ |
case 0: |
device_name = DEVICENAME_LINUX; |
case 2: |
device_name = DEVICENAME_9X; |
break; |
87,7 → 127,7 |
|
void WIENVME_unload () |
{ |
UnloadExternalModule (VMEmodule); |
//UnloadExternalModule (VMEmodule); |
return; |
} |
|
143,7 → 183,7 |
/* D8 read */ |
result = VMEread(hHandle, at, 1, n, buff); |
if (result) { |
printf("D8 read at 0x%X failed!\n", at); |
printf("D8 read at 0x%lX failed!\n", at); |
} |
// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
return (result); |
156,7 → 196,7 |
/* D16 read */ |
result = VMEread(hHandle, at, 2, n, buff); |
if (result) { |
printf("D16 read at 0x%X failed!\n", at); |
printf("D16 read at 0x%lX failed!\n", at); |
} |
// printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
return (result); |
169,7 → 209,7 |
/* D32 read */ |
result = VMEread(hHandle, at, 4, n, buff); |
if (result) { |
printf("D32 read at 0x%X failed!\n", at); |
printf("D32 read at 0x%lX failed!\n", at); |
} |
//printf("0x%X, 0x%X, 0x%X, 0x%X\n", hHandle, at, n, * (unsigned short *) buff); |
return (result); |
182,7 → 222,7 |
/* D8 write */ |
result = VMEwrite(hHandle, at, 1, n, buff); |
if (result) { |
printf("D8 write at 0x%X failed!\n", at); |
printf("D8 write at 0x%lX failed!\n", at); |
} |
return (result); |
} |
194,7 → 234,7 |
/* D16 write */ |
result = VMEwrite(hHandle, at, 2, n, buff); |
if (result) { |
printf("D16 write at 0x%X failed!\n", at); |
printf("D16 write at 0x%lX failed!\n", at); |
} |
return (result); |
} |
206,7 → 246,7 |
/* D32 write */ |
result = VMEwrite(hHandle, at, 4, n, buff); |
if (result) { |
printf("D32 write at 0x%X failed!\n", at); |
printf("D32 write at 0x%lX failed!\n", at); |
} |
//printf("D32 write at 0x%X buff=0x%X\n", at,((int*) buff)[0]); |
return (result); |