void initialize() { int result; const char *err; //create the RFID object CPhidgetRFID_create(&rfid); //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error. CPhidget_set_OnAttach_Handler((CPhidgetHandle)rfid, AttachHandler, NULL); CPhidget_set_OnDetach_Handler((CPhidgetHandle)rfid, DetachHandler, NULL); CPhidget_set_OnError_Handler((CPhidgetHandle)rfid, ErrorHandler, NULL); //Registers a callback that will run if an output changes. //Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL). CPhidgetRFID_set_OnOutputChange_Handler(rfid, OutputChangeHandler, NULL); //Registers a callback that will run when a Tag is read. //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL). CPhidgetRFID_set_OnTag2_Handler(rfid, TagHandler, NULL); //Registers a callback that will run when a Tag is lost (removed from antenna read range). //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL). CPhidgetRFID_set_OnTagLost2_Handler(rfid, TagLostHandler, NULL); //open the RFID for device connections CPhidget_open((CPhidgetHandle)rfid, -1); //get the program to wait for an RFID device to be attached printf("Waiting for RFID to be attached....\n"); if((result = CPhidget_waitForAttachment((CPhidgetHandle)rfid, 100))) { CPhidget_getErrorDescription(result, &err); printf("Problem waiting for attachment: %s\n", err); } else { CPhidgetRFID_setAntennaOn(rfid, 1); } }
JNIEXPORT void JNICALL Java_com_phidgets_RFIDPhidget_enableTagLossEvents (JNIEnv * env, jobject obj, jboolean b) { jlong gr = updateGlobalRef (env, obj, nativeTagLossHandler_fid, b); CPhidgetRFIDHandle h = (CPhidgetRFIDHandle) (uintptr_t) (*env)->GetLongField (env, obj, handle_fid); CPhidgetRFID_set_OnTagLost2_Handler (h, b ? tagLoss_handler : 0, (void *) (uintptr_t) gr); } static int CCONV