/** * Get the value from a digital input channel. * Retrieve the value of a single digital input channel from the FPGA. */ bool DigitalInput::Get() { int32_t status = 0; bool value = getDIO(m_digital_ports[m_channel], &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); return value; }
/* * Class: edu_wpi_first_wpilibj_hal_DIOJNI * Method: getDIO * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO (JNIEnv * env, jclass, jlong id) { //DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO"; //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id; int32_t status = 0; jboolean returnValue = getDIO((void*)id, &status); //DIOJNI_LOG(logDEBUG) << "Status = " << status; //DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue; CheckStatus(env, status); return returnValue; }
/* * Class: edu_wpi_first_wpilibj_hal_DIOJNI * Method: getDIO * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B */ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO (JNIEnv * env, jclass, jobject id, jobject status) { //DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO"; void ** javaId = (void**)env->GetDirectBufferAddress(id); //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; jbyte returnValue = getDIO(*javaId, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; //DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue; return returnValue; }