31 int ret = CPhidget_open(
handle_, serial_number);
32 if (ret != EPHIDGET_OK)
37 return CPhidget_waitForAttachment(
handle_, timeout);
48 const char *deviceptr = a;
49 CPhidget_getDeviceType(
handle_, &deviceptr);
50 return std::string(deviceptr);
56 const char *deviceptr = a;
57 CPhidget_getDeviceName(
handle_, &deviceptr);
58 return std::string(deviceptr);
64 const char *deviceptr = a;
65 CPhidget_getDeviceType(
handle_, &deviceptr);
66 return std::string(deviceptr);
72 const char *deviceptr = a;
73 CPhidget_getLibraryVersion(&deviceptr);
74 return std::string(deviceptr);
80 CPhidget_getSerialNumber(
handle_, &sernum);
87 CPhidget_getDeviceVersion(
handle_, &version);
94 const char *errorPtr = a;
95 CPhidget_getErrorDescription(errorCode, &errorPtr);
96 return std::string(errorPtr);
111 printf(
"Phidget error [%d]: %s\n", error,
117 ((
Phidget *)userptr)->attachHandler();
123 ((
Phidget *)userptr)->detachHandler();
128 int ErrorCode,
const char * )
130 ((
Phidget *)userptr)->errorHandler(ErrorCode);
int openAndWaitForAttachment(int serial_number, int timeout)
Open a connection to a Phidget.
static int DetachHandler(CPhidgetHandle handle, void *userptr)
static int AttachHandler(CPhidgetHandle handle, void *userptr)
int getDeviceSerialNumber()
Get the Phidget's serial number.
virtual void detachHandler()
static int ErrorHandler(CPhidgetHandle handle, void *userptr, int ErrorCode, const char *unknown)
static std::string getErrorDescription(int errorCode)
Lookup the string for a CPhidget Error Code.
int close()
Close the connection to the phidget.
virtual void errorHandler(int error)
virtual void attachHandler()
std::string getDeviceType()
Get the device type string.
std::string getDeviceLabel()
Get the device label string.
std::string getLibraryVersion()
Get the library version string.
int getDeviceVersion()
Get the Phidget's version.
void init(CPhidgetHandle handle)
std::string getDeviceName()
Get the device name string.