25 #include <libphidgets/phidget21.h> 30 const char *deviceptr;
31 CPhidget_getDeviceType(phid, &deviceptr);
32 CPhidget_getSerialNumber(phid, &sernum);
33 CPhidget_getDeviceVersion(phid, &version);
35 printf(
"%s\n", deviceptr);
36 printf(
"Version: %8d SerialNumber: %10d\n", version, sernum);
43 printf(
"Detach handler ran!\n");
47 int IFK_ErrorHandler(CPhidgetHandle IFK,
void *userptr,
int ErrorCode,
const char *unknown)
49 printf(
"Error handler ran!\n");
55 printf(
"Output %d is %d\n", Index, Value);
61 printf(
"Input %d is %d\n", Index, Value);
67 printf(
"Sensor %d is %d\n", Index, Value);
74 CPhidgetInterfaceKit_setSensorChangeTrigger((CPhidgetInterfaceKitHandle)IFK, 0, 0);
75 printf(
"Attach handler ran!\n");
81 int numInputs, numOutputs, numSensors;
83 CPhidgetInterfaceKitHandle IFK = 0;
87 CPhidgetInterfaceKit_create(&IFK);
96 CPhidget_open((CPhidgetHandle)IFK, -1);
99 if((err = CPhidget_waitForAttachment((CPhidgetHandle)IFK, 5000)) != EPHIDGET_OK )
102 CPhidget_getErrorDescription(err, &errStr);
103 printf(
"Error waiting for attachment: (%d): %s\n",err,errStr);
108 CPhidgetInterfaceKit_getOutputCount((CPhidgetInterfaceKitHandle)IFK, &numOutputs);
109 CPhidgetInterfaceKit_getInputCount((CPhidgetInterfaceKitHandle)IFK, &numInputs);
110 CPhidgetInterfaceKit_getSensorCount((CPhidgetInterfaceKitHandle)IFK, &numSensors);
112 CPhidgetInterfaceKit_setOutputState((CPhidgetInterfaceKitHandle)IFK, 0, 1);
114 printf(
"Sensors:%d Inputs:%d Outputs:%d\n", numSensors, numInputs, numOutputs);
118 CPhidgetInterfaceKit_setOutputState(IFK, 7, 1);
119 CPhidgetInterfaceKit_setOutputState(IFK, 7, 0);
122 CPhidgetInterfaceKit_setOutputState(IFK, 0, 1);
124 CPhidgetInterfaceKit_setOutputState(IFK, 0, 0);
126 CPhidgetInterfaceKit_setOutputState(IFK, 0, 1);
128 CPhidgetInterfaceKit_setOutputState(IFK, 0, 0);
133 CPhidget_close((CPhidgetHandle)IFK);
134 CPhidget_delete((CPhidgetHandle)IFK);
139 int main(
int argc,
char* argv[])
int IFK_AttachHandler(CPhidgetHandle IFK, void *userptr)
int main(int argc, char *argv[])
int IFK_InputChangeHandler(CPhidgetInterfaceKitHandle IFK, void *userptr, int Index, int Value)
int IFK_OutputChangeHandler(CPhidgetInterfaceKitHandle IFK, void *userptr, int Index, int Value)
void display_generic_properties(CPhidgetHandle phid)
int IFK_DetachHandler(CPhidgetHandle IFK, void *userptr)
int IFK_ErrorHandler(CPhidgetHandle IFK, void *userptr, int ErrorCode, const char *unknown)
int IFK_SensorChangeHandler(CPhidgetInterfaceKitHandle IFK, void *userptr, int Index, int Value)