Skip to content
Snippets Groups Projects
Commit d34ce6d9 authored by tzhang74's avatar tzhang74
Browse files

initial

parents
Branches master
No related tags found
No related merge requests found
Showing
with 377 additions and 0 deletions
// VM-USB test program
// WIENER, Plein & Baus Corp. 01/2014
// Revision 2.0 - 01/22/14 tested with VM-DBA
// Andreas Ruben, aruben@wiener-us.com
/* Simple program to demonstrate VM_USB in EASY mode
*
* Copyright (C) 2005-2009 WIENER, Plein & Baus, Ltd (thoagland@wiener-us.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*
*
*
*/
#include <libxxusb.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <cstdlib>
#include <string.h>
int main (int argc, char *argv[])
{
int ret, i;
xxusb_device_type devices[100];
int VM_reg [20];
struct usb_device *dev;
usb_dev_handle *udev; // Device Handle
long data_w, data_r, adr;
int errors =0;
int Address_Modifier= 0x09;
//Find XX_USB devices and open the first one found
xxusb_devices_find(devices);
dev = devices[0].usbdev;
udev = xxusb_device_open(dev);
// Make sure VM_USB opened OK
if(!udev) {
printf ("\n\nFailed to Open VM_USB \n\n");
return 0;
} else {
printf("Device open\n");
}
// Prepare and READ VM-USB Registers for display and log file
for (i=0; i<=15; i++)
{
ret = VME_register_read(udev, i, &data_r);
VM_reg[i]= data_r;
}
printf("VM-USB Register:\n");
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[0],VM_reg[1],VM_reg[2],VM_reg[3],VM_reg[4]);
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[5],VM_reg[6],VM_reg[7],VM_reg[8],VM_reg[10]);
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[11],VM_reg[12],VM_reg[13],VM_reg[14],VM_reg[15]);
// write / read back 32 data VME window (Address 0 to 0x1FFE as words in Std_NoPriv_Data)
for (i =0x0; i < 0xFFFF; i+=0x4)
{
data_w = i/4+i/4*0x10000; // write and increment word address
adr = i+i*0x10000;
ret = VME_write_32(udev,Address_Modifier, adr, data_w);
ret = VME_read_32(udev,Address_Modifier, adr, &data_r);
if (data_w != data_w)
errors++;
}
printf("VME bus test errors: %i \n", errors);
return errors;
// Close the Device
xxusb_device_close(udev);
printf("\n\n\n");
return 0;
}
File added
# basic makefile
here=$(shell pwd)
.LIBPATTERNS ="'lib%.so lib%.a' "
CXX = g++
FC = g77
F90 = f90
RM = rm -f
CC = g++
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
CXXLIBDIRS = -L./../../lib/
CXXLIBS = -lxx_usb -lm -lusb -Wl,"-rpath=$(here)/../../lib"
INCLUDEDIRS = -I./../../include/
CXXFLAGS = -O -Wall -fPIC -g $(INCLUDEDIRS)
CFLAGS += $(INCLUDEDIRS) $(SOFLAG)
CFLAGS += $(CXXLIBDIRS) $(CXXLIBS)
LDFLAGS = $(CXXFLAGS)
OBJ = ./vmetest
main:
$(CXX) $(CXXFLAGS) VM-USB_test.cpp \
$(CXXLIBS) $(CXXLIBDIRS) -o $(OBJ)
@echo "Done"
clean:
$(RM) $(OBJ)
# basic makefile
here=$(shell pwd)
.LIBPATTERNS ="'lib%.so lib%.a' "
CXX = g++
FC = g77
F90 = f90
RM = rm -f
CC = g++
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
CXXLIBDIRS = -L./../../lib/
CXXLIBS = -lxx_usb -lm -lusb -Wl,"-rpath=$(here)/../../lib"
INCLUDEDIRS = -I./../../include/
CXXFLAGS = -O -Wall -fPIC -g $(INCLUDEDIRS)
CFLAGS += $(INCLUDEDIRS) $(SOFLAG)
CFLAGS += $(CXXLIBDIRS) $(CXXLIBS)
LDFLAGS = $(CXXFLAGS)
OBJ = ./CC-DAQ2249
main:
$(CXX) $(CXXFLAGS) CC-DAQ_2249.cpp \
$(CXXLIBS) $(CXXLIBDIRS) -o $(OBJ)
@echo "Done"
clean:
$(RM) $(OBJ)
// VM-USB test program
// WIENER, Plein & Baus Corp. 01/2014
// Revision 2.0 - 01/22/14 tested with VM-DBA
// Andreas Ruben, aruben@wiener-us.com
/* Simple program to demonstrate VM_USB in EASY mode
*
* Copyright (C) 2005-2014 WIENER, Plein & Baus, Corp.)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*
*
*
*/
#include <libxxusb.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <cstdlib>
#include <string.h>
int main (int argc, char *argv[])
{
int ret, i;
xxusb_device_type devices[100];
int VM_reg [20];
struct usb_device *dev;
usb_dev_handle *udev; // Device Handle
long data_w, data_r, adr;
int errors =0;
int Address_Modifier= 0x09;
//Find XX_USB devices and open the first one found
xxusb_devices_find(devices);
dev = devices[0].usbdev;
udev = xxusb_device_open(dev);
// Make sure VM_USB opened OK
if(!udev) {
printf ("\n\nFailed to Open VM_USB \n\n");
return 0;
} else {
printf("Device open\n");
}
// Prepare and READ VM-USB Registers for display and log file
for (i=0; i<=15; i++)
{
ret = VME_register_read(udev, i, &data_r);
VM_reg[i]= data_r;
}
printf("VM-USB Register:\n");
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[0],VM_reg[1],VM_reg[2],VM_reg[3],VM_reg[4]);
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[5],VM_reg[6],VM_reg[7],VM_reg[8],VM_reg[10]);
printf("%x \t%x \t%x \t%x \t%x \n",VM_reg[11],VM_reg[12],VM_reg[13],VM_reg[14],VM_reg[15]);
// write / read back 32 data VME window (Address 0 to 0x1FFE as words in Std_NoPriv_Data)
for (i =0x0; i < 0xFFFF; i+=0x4)
{
data_w = i/4+i/4*0x10000; // write and increment word address
adr = i+i*0x10000;
ret = VME_write_32(udev,Address_Modifier, adr, data_w);
ret = VME_read_32(udev,Address_Modifier, adr, &data_r);
if (data_w != data_w)
errors++;
}
printf("VME bus test errors: %i \n", errors);
return errors;
// Close the Device
xxusb_device_close(udev);
printf("\n\n\n");
return 0;
}
// VM-USB test program
// WIENER, Plein & Baus Corp. 01/2014
// Revision 2.0 - 01/22/14 tested with VM-DBA
// Andreas Ruben, aruben@wiener-us.com
/* Simple program to demonstrate VM_USB in EASY mode
*
* Copyright (C) 2005-2009 WIENER, Plein & Baus, Ltd (thoagland@wiener-us.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*
*
*
*/
#include <libxxusb.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <cstdlib>
#include <string.h>
int main (int argc, char *argv[])
{
int WriteMode;
long buf[1000];
int ret, i;
int debug = 0, eclose = 0, eread = 0;
xxusb_device_type devices[100];
struct usb_device *dev;
usb_dev_handle *udev; // Device Handle
long data_w, data_r, adr;
int errors =0;
int Address_Modifier= 0x09;
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-' && argv[i][1] == 'd')
debug = 1;
else if (strncmp(argv[i], "-e", 2) == 0)
eclose = 1;
else if (strncmp(argv[i], "-r", 2) == 0)
eread = 1;
else if (argv[i][0] == '-') {
if (i + 1 >= argc || argv[i + 1][0] == '-')
goto usage;
// if (strncmp(argv[i], "-w", 2) == 0)
// delta_time = 1000 * (atoi(argv[++i]));
//else if (strncmp(argv[i], "-f", 2) == 0)
// strcpy(svpath, argv[++i]);
//else if (strncmp(argv[i], "-e", 2) == 0)
// strcpy(expt_name, argv[++i]);
//else if (strncmp(argv[i], "-h", 2) == 0)
// strcpy(host_name, argv[++i]);
} else {
usage:
printf("usage: -e (close) -r (read) \n");
return 0;
}
}
//Find XX_USB devices and open the first one found
xxusb_devices_find(devices);
dev = devices[0].usbdev;
udev = xxusb_device_open(dev);
// Make sure VM_USB opened OK
if(!udev) {
printf ("\n\nFailed to Open CC_USB \n\n");
return 0;
} else {
printf("Device open\n");
}
// write / read back 32 data VME window (Address 0 to 0x1FFE as words in Std_NoPriv_Data)
for (i =0x0; i < 0xFFFF; i+=0x4)
{
data_w = i/4+i/4*0x10000; // write and increment word address
adr = i+i*0x10000;
ret = VME_write_32(udev,Address_Modifier, adr, data_w);
ret = VME_read_32(udev,Address_Modifier, adr, &data_r);
if (data_w != data_w)
errors++;
}
return errors;
ccclose:
// Close the Device
xxusb_device_close(udev);
printf("\n\n\n");
return 0;
}
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
# basic makefile
.LIBPATTERNS ="'lib%.so lib%.a' "
CXX = g++
RM = rm -f
LDLIBS = -lusb
INCLUDEDIRS = -I./../include/
CXXFLAGS = -Wall -fPIC
LDFLAGS = -shared
SOURCES = libxxusb.c
OBJECTS = $(SOURCES:.c=.o)
LIB = libxx_usb.so
library:
$(CXX) $(CXXFLAGS) $(INCLUDEDIRS) -c $(SOURCES)
$(LD) $(LDFLAGS) $(LDLIBS) $(INCLUDEDIRS) $(OBJECTS) -o $(LIB)
@chmod 755 $(LIB)
[ -d ./../lib ] || mkdir ./../lib
cp $(LIB) ./../lib
@echo "Done"
clean:
$(RM) $(OBJECTS) $(LIB)
libxxusb.c
This is the source file for the Linux XX_USB library for using the WIENER CC_USB or VM_USB under linux. It contains general function for both the CC_USB and VM_USB as well specific functions for each unit. Complete documentation is available in the Manual for the XX_USB.
To Compile:
- Simply typing "make" will compile and make the library file.
- Typing "make install" will copy the library made by "make" into the /usr/lib directory.
This Linux library was tested by and this file written by:
Tim Hoagland / Andreas Ruben
of
WIENER, Plein & Baus, Corp.
If you have any questions or problems with this library, please contact us at:
support@wiener-us.com
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment