Skip to content

Commit

Permalink
Merge pull request #2 from keenanlang/master
Browse files Browse the repository at this point in the history
2016 Argonne Open House Changes
  • Loading branch information
prjemian committed May 6, 2016
2 parents d396340 + d834ec1 commit 9275d37
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 146 deletions.
7 changes: 7 additions & 0 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/Db/AnalogAxis.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
record(ai, "$(P)$(R)")
{
field(DTYP, "asynInt32")
field(SCAN, "I/O Intr")
field(INP, "@asyn($(PORT), 0, 0)$(PARAM)")
field(FLNK, "$(FLNK)")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
record(bi, "$(P)$(R)")
{
field(DTYP, "asynInt32")
field(SCAN, "I/O Intr")
field(INP, "@asyn($(PORT), 0, 0)$(PARAM)")
field(FLNK, "$(FLNK)")
}
41 changes: 40 additions & 1 deletion edgeRoboArmIOC/support/usb-1-0/usbApp/src/devUSB.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,27 @@ bool checkInterfaceArgs(const iocshArgBuf* args)
return true;
}

bool checkTransArgs(const iocshArgBuf* args)
{
if (args[0].sval == NULL)
{
printf("Error: no input given.\n");
return false;
}
else if (not port_used(args[0].sval))
{
printf("Error: couldn't find port specified.\n");
return false;
}
else if (args[1].ival < 0)
{
printf("Error: input cannot be negative.\n");
return false;
}

return true;
}


static void parse(const char* filename, DataLayout& spec)
{
Expand Down Expand Up @@ -336,6 +357,10 @@ void usbSetFrequency( const char* port_name, double frequency)
get_driver(port_name)->setFrequency(timing);
}

void usbShowIO(const char* port_name, int tf)
{
get_driver(port_name)->setIOPrinting(tf);
}


extern "C"
Expand Down Expand Up @@ -365,6 +390,9 @@ extern "C"
static const iocshArg inter_arg0 = {"portName", iocshArgString};
static const iocshArg inter_arg1 = {"interfaceNum", iocshArgInt};

static const iocshArg trans_arg0 = {"portName", iocshArgString};
static const iocshArg trans_arg1 = {"print_io_data", iocshArgInt};



static const iocshArg* cx_args[] = {&cx_arg0, &cx_arg1, &cx_arg2, &cx_arg3, &cx_arg4};
Expand All @@ -374,6 +402,7 @@ extern "C"
static const iocshArg* delay_args[] = {&delay_arg0, &delay_arg1};
static const iocshArg* debug_args[] = {&debug_arg0, &debug_arg1};
static const iocshArg* inter_args[] = {&inter_arg0, &inter_arg1};
static const iocshArg* trans_args[] = {&trans_arg0, &trans_arg1};



Expand All @@ -384,6 +413,7 @@ extern "C"
static const iocshFuncDef delay_func = {"usbSetDelay", 2, delay_args};
static const iocshFuncDef debug_func = {"usbSetDebugLevel", 2, debug_args};
static const iocshFuncDef inter_func = {"usbSetInterface", 2, inter_args};
static const iocshFuncDef trans_func = {"usbShowIO", 2, trans_args};



Expand Down Expand Up @@ -444,7 +474,14 @@ extern "C"
}
}


static void call_trans_func(const iocshArgBuf* args)
{
if (checkTransArgs(args))
{
usbShowIO(args[0].sval, args[0].ival);
}
}


static void usbConnectRegistrar(void) { iocshRegister(&cx_func, call_cx_func); }
static void usbDriverRegistrar(void) { iocshRegister(&driver_func, call_driver_func); }
Expand All @@ -453,6 +490,7 @@ extern "C"
static void usbDelayRegistrar(void) { iocshRegister(&delay_func, call_delay_func); }
static void usbDebugRegistrar(void) { iocshRegister(&debug_func, call_debug_func); }
static void usbInterRegistrar(void) { iocshRegister(&inter_func, call_inter_func); }
static void usbTransRegistrar(void) { iocshRegister(&trans_func, call_trans_func); }



Expand All @@ -463,4 +501,5 @@ extern "C"
epicsExportRegistrar(usbDelayRegistrar);
epicsExportRegistrar(usbDebugRegistrar);
epicsExportRegistrar(usbInterRegistrar);
epicsExportRegistrar(usbTransRegistrar);
}
14 changes: 8 additions & 6 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/src/hidDriver.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class hidDriver : public asynPortDriver

void printDebug(int level, std::string format, ...);
void setDebugLevel(int amt);
void setIOPrinting(int tf);

asynStatus writeInt32(asynUser* pasynuser, epicsInt32 value);
asynStatus writeFloat64(asynUser* pasynuser, epicsFloat64 value);
Expand Down Expand Up @@ -75,18 +76,18 @@ class hidDriver : public asynPortDriver
std::string SERIAL_NUM;
unsigned INTERFACE;

int TRANSFER_LENGTH_IN;
int ENDPOINT_ADDRESS_IN;
unsigned int TRANSFER_LENGTH_IN;
unsigned int ENDPOINT_ADDRESS_IN;

int TRANSFER_LENGTH_OUT;
int ENDPOINT_ADDRESS_OUT;
unsigned int TRANSFER_LENGTH_OUT;
unsigned int ENDPOINT_ADDRESS_OUT;

int DEBUG_LEVEL;
unsigned int DEBUG_LEVEL;

DataLayout input_specification;
DataLayout output_specification;

int TIMEOUT;
unsigned int TIMEOUT;
double FREQUENCY;
double TIME_BETWEEN_CHECKS;

Expand All @@ -101,6 +102,7 @@ class hidDriver : public asynPortDriver
epicsMutexId device_state;

bool need_init;
bool print_transfer;
};

#endif
6 changes: 4 additions & 2 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/src/hidDriverConnect.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ void hidDriver::findDevice()

if (this->isMatch(dev) and not contains(dev))
{
claimed.push_back(dev);
libusb_open(dev, &DEVICE);
int stat = libusb_open(dev, &DEVICE);

if (! stat) { claimed.push_back(dev); }

break;
}
}
Expand Down
10 changes: 10 additions & 0 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/src/hidDriverInput.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ void hidDriver::update_thread()

void hidDriver::updateParams()
{
if (this->print_transfer)
{
for (unsigned index = 0; index < this->TRANSFER_LENGTH_IN; index += 1)
{
printf("%02X ", this->state[index]);
}

printf("\n");
}

/*
* Iterate through the asyn params and assign them to their
* registers.
Expand Down
7 changes: 7 additions & 0 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/src/hidDriverStatus.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ void hidDriver::setInterface(int interface_in)
this->claimInterface();
epicsMutexUnlock(this->device_state);
}

void hidDriver::setIOPrinting(int tf)
{
this->printDebug(10, "Setting IO Printing: %d -> %d\n", this->print_transfer, tf);

this->print_transfer = tf;
}
1 change: 1 addition & 0 deletions edgeRoboArmIOC/support/usb-1-0/usbApp/src/usbSupport.dbd
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ registrar(usbFrequencyRegistrar)
registrar(usbDelayRegistrar)
registrar(usbDebugRegistrar)
registrar(usbInterRegistrar)
registrar(usbTransRegistrar)
15 changes: 12 additions & 3 deletions edgeRoboArmIOC/support/xxx-5-6/iocBoot/iocLinux/st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ iocxxxLinux_registerRecordDeviceDriver(pdbbase)
drvAsynUSBPortConfigure("USB1", "Robotic Arm", 0x1267, 0, 0, 0, 0, 1)
asynOctetConnect("USB1", "USB1")

usbCreateDriver("JOYSTICK", "$(USB)/usbApp/Db/LogitechExtreme3DPro.in")
usbConnectDevice("JOYSTICK", 0, 0x046D, 0xC215)
#usbCreateDriver("LOGITECH", "$(USB)/usbApp/Db/LogitechATKIII.in")
#usbConnectDevice("LOGITECH", 0, 0x046D, 0xC214)
#dbLoadTemplate("./substitutions/LogitechATKIII.substitutions")

dbLoadRecords("../../xxxApp/Db/roboArm.db", "P=xxx:, A=A1:, INPORT=JOYSTICK, OUTPORT=USB1")
usbCreateDriver("LOGITECH", "$(USB)/usbApp/Db/LogitechExtreme3DPro.in")
usbConnectDevice("LOGITECH", 0, 0x046D, 0xC215)
dbLoadTemplate("./substitutions/LogitechExtreme3DPro.substitutions")

#usbCreateDriver("LOGITECH", "$(USB)/usbApp/Db/LogitechDualAction.in")
#usbConnectDevice("LOGITECH", 0, 0x046D, 0xC216)
#dbLoadTemplate("./substitutions/LogitechDualAction.substitutions")

dbLoadRecords("../../xxxApp/Db/roboArm.db", "P=xxx:, A=A1:, OUTPORT=USB1")
###############################################################################
###############################################################################
###############################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
record(calcout, "$(P)$(R)")
{
field(INPA, "$(LOCK)")
field(INPB, "$(AXIS)")
field(CALC, "A ? 0 : 2 * (B < $(DEAD_LOW)) + (B > $(DEAD_HIGH))")
field(OUT, "$(OUT) PP")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
record(calcout, "$(P)$(R)")
{
field(INPA, "$(LOCK)")
field(INPB, "$(BUTTONA)")
field(INPC, "$(BUTTONB)")
field(CALC, "A ? 0 : 2 * B + C")
field(OUT, "$(OUT) PP")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
record(calcout, "$(P)$(R)")
{
field(INPA, "$(LOCK) NPP")
field(INPB, "$(AXIS) NPP")
field(CALC, "A ? 0 : (B = $(VALB)) + 2 * (B = $(VALA))")
field(OUT, "$(OUT) PP")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
file "$(USB)/usbApp/Db/AnalogAxis.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Vertical VERTICAL_STATE LOGITECH xxx:A1:shoulder}
{xxx: A1:Switch SWITCH_STATE LOGITECH xxx:A1:move_lock}
}

file "$(USB)/usbApp/Db/DigitalButton.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Trigger TRIGGER_PRESSED LOGITECH xxx:A1:led}
{xxx: A1:Button2 BUTTON2_PRESSED LOGITECH xxx:A1:wrist}
{xxx: A1:Button3 BUTTON3_PRESSED LOGITECH xxx:A1:wrist}
{xxx: A1:Button4 BUTTON4_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:Button5 BUTTON5_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:Button6 BUTTON6_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button7 BUTTON7_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button8 BUTTON8_PRESSED LOGITECH xxx:A1:base}
{xxx: A1:Button9 BUTTON9_PRESSED LOGITECH xxx:A1:base}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/AxisMove.template"
{
pattern
{P R LOCK AXIS DEAD_LOW DEAD_HIGH OUT}
{xxx: A1:move_lock 0 xxx:A1:Switch 0 126 ""}
{xxx: A1:shoulder xxx:A1:move_lock xxx:A1:Vertical 100 150 xxx:A1:shoulder_move}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/ButtonMove.template"
{
pattern
{P R LOCK BUTTONA BUTTONB OUT}
{xxx: A1:led 0 0 xxx:A1:Trigger xxx:A1:led_onoff}
{xxx: A1:grip xxx:A1:move_lock xxx:A1:Button4 xxx:A1:Button5 xxx:A1:grip_move}
{xxx: A1:elbow xxx:A1:move_lock xxx:A1:Button6 xxx:A1:Button7 xxx:A1:elbow_move}
{xxx: A1:base xxx:A1:move_lock xxx:A1:Button8 xxx:A1:Button9 xxx:A1:base_move}
{xxx: A1:wrist xxx:A1:move_lock xxx:A1:Button2 xxx:A1:Button3 xxx:A1:wrist_move}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
file "$(USB)/usbApp/Db/AnalogAxis.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Vertical LSTICK_UD_STATE LOGITECH xxx:A1:shoulder}
{xxx: A1:Rotation LSTICK_LR_STATE LOGITECH xxx:A1:base}
}

file "$(USB)/usbApp/Db/DigitalButton.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Button1 BUTTON1_PRESSED LOGITECH xxx:A1:led}
{xxx: A1:Button2 BUTTON2_PRESSED LOGITECH xxx:A1:move_lock}
{xxx: A1:Button3 BUTTON3_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:Button4 BUTTON4_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:Button5 BUTTON5_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button7 BUTTON7_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button6 BUTTON6_PRESSED LOGITECH xxx:A1:wrist}
{xxx: A1:Button8 BUTTON8_PRESSED LOGITECH xxx:A1:wrist}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/AxisMove.template"
{
pattern
{P R LOCK AXIS DEAD_LOW DEAD_HIGH OUT}
{xxx: A1:move_lock 0 xxx:A1:Button2 1 1 ""}
{xxx: A1:base xxx:A1:move_lock xxx:A1:Rotation 100 150 xxx:A1:base_move}
{xxx: A1:shoulder xxx:A1:move_lock xxx:A1:Vertical 100 150 xxx:A1:shoulder_move}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/ButtonMove.template"
{
pattern
{P R LOCK BUTTONA BUTTONB OUT}
{xxx: A1:led 0 0 xxx:A1:Button1 xxx:A1:led_onoff}
{xxx: A1:elbow xxx:A1:move_lock xxx:A1:Button7 xxx:A1:Button5 xxx:A1:elbow_move}
{xxx: A1:grip 0 xxx:A1:Button3 xxx:A1:Button4 xxx:A1:grip_move}
{xxx: A1:wrist xxx:A1:move_lock xxx:A1:Button8 xxx:A1:Button6 xxx:A1:wrist_move}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
file "$(USB)/usbApp/Db/AnalogAxis.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Vertical VERTICAL_STATE LOGITECH xxx:A1:shoulder}
{xxx: A1:Rotation ROTATION_STATE LOGITECH xxx:A1:base}
{xxx: A1:Switch SWITCH_STATE LOGITECH xxx:A1:move_lock}
{xxx: A1:Hat HAT_STATE LOGITECH xxx:A1:wrist}
}

file "$(USB)/usbApp/Db/DigitalButton.template"
{
pattern
{P R PARAM PORT FLNK}
{xxx: A1:Trigger TRIGGER_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:LButton LBUTTON_PRESSED LOGITECH xxx:A1:grip}
{xxx: A1:Button3 BUTTON3_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button5 BUTTON5_PRESSED LOGITECH xxx:A1:elbow}
{xxx: A1:Button11 BUTTON11_PRESSED LOGITECH xxx:A1:led}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/AxisMove.template"
{
pattern
{P R LOCK AXIS DEAD_LOW DEAD_HIGH OUT}
{xxx: A1:move_lock 0 xxx:A1:Switch 0 126 ""}
{xxx: A1:base xxx:A1:move_lock xxx:A1:Rotation 50 200 xxx:A1:base_move}
{xxx: A1:shoulder xxx:A1:move_lock xxx:A1:Vertical 50 600 xxx:A1:shoulder_move}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/ButtonMove.template"
{
pattern
{P R LOCK BUTTONA BUTTONB OUT}
{xxx: A1:led 0 0 xxx:A1:Button11 xxx:A1:led_onoff}
{xxx: A1:elbow xxx:A1:move_lock xxx:A1:Button3 xxx:A1:Button5 xxx:A1:elbow_move}
{xxx: A1:grip xxx:A1:move_lock xxx:A1:LButton xxx:A1:Trigger xxx:A1:grip_move}
}

file "$(TOP)/iocBoot/$(IOC)/substitutions/DiscreteMove.template"
{
pattern
{P R LOCK AXIS VALA VALB OUT}
{xxx: A1:wrist xxx:A1:move_lock xxx:A1:Hat 4 0 xxx:A1:wrist_move}
}

0 comments on commit 9275d37

Please sign in to comment.