Ejemplo n.º 1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_DIOJNI
 * Method:    allocateDIO
 * Signature: (JZ)Z
 */
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
  (JNIEnv * env, jclass, jlong id, jboolean value)
{
	DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
	DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
	int32_t status = 0;
	jboolean returnValue = allocateDIO((void*)id, value, &status);
	DIOJNI_LOG(logDEBUG) << "Status = " << status;
	DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
	CheckStatus(env, status);
	return returnValue;
}
Ejemplo n.º 2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_DIOJNI
 * Method:    allocateDIO
 * Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)B
 */
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
{
    DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
    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 = allocateDIO(*javaId, value, statusPtr);
    DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
    DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
    return returnValue;
}
Ejemplo n.º 3
0
/**
 * Create an instance of a DigitalInput.
 * Creates a digital input given a channel. Common creation routine for all
 * constructors.
 */
void DigitalInput::InitDigitalInput(uint32_t channel)
{
	m_table = NULL;
	char buf[64];

	if (!CheckDigitalChannel(channel))
	{
		snprintf(buf, 64, "Digital Channel %d", channel);
		wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
		return;
	}
	m_channel = channel;

	int32_t status = 0;
	allocateDIO(m_digital_ports[channel], true, &status);
	wpi_setErrorWithContext(status, getHALErrorMessage(status));

	LiveWindow::GetInstance()->AddSensor("DigitalInput", channel, this);
	HALReport(HALUsageReporting::kResourceType_DigitalInput, channel);
}
InterruptSource::InterruptSource(uint32_t channel) : m_channel(channel) {
  int32_t status = 0;
  allocateDIO(m_digital_ports[channel], true, &status);
  wpi_setErrorWithContext(status, getHALErrorMessage(status));
}