Ejemplo n.º 1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_SolenoidJNI
 * Method:    initializeSolenoidPort
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort
  (JNIEnv *env, jclass, jlong port_pointer)
{
	SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
	
	SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)port_pointer;
	char *aschars = (char *)port_pointer;
	SOLENOIDJNI_LOG(logDEBUG) << '\t' << (int)aschars[0] << '\t' << (int)aschars[1] << std::endl;
	
	int32_t status = 0;
	void* solenoid_port_pointer = initializeSolenoidPort((void*)port_pointer, &status);
	
	SOLENOIDJNI_LOG(logDEBUG) << "Status = " << status;
	SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << solenoid_port_pointer;
	
	int *asints = (int *)solenoid_port_pointer;
	SOLENOIDJNI_LOG(logDEBUG) << '\t' << asints[0] << '\t' << asints[1] << std::endl;

	CheckStatus(env, status);
	return (jlong)solenoid_port_pointer;
}
Ejemplo n.º 2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_SolenoidJNI
 * Method:    initializeSolenoidPort
 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
 */
JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort
  (JNIEnv *env, jclass, jobject port_pointer, jobject status)
{
	SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
	
	VoidPointer *port_pointer_pointer = (VoidPointer *)env->GetDirectBufferAddress(port_pointer);
	SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << *port_pointer_pointer;
	char *aschars = (char *)(*port_pointer_pointer);
	SOLENOIDJNI_LOG(logDEBUG) << '\t' << (int)aschars[0] << '\t' << (int)aschars[1] << std::endl;
	
	jint *status_pointer = (jint*)env->GetDirectBufferAddress(status);
	SOLENOIDJNI_LOG(logDEBUG) << "Status Ptr = " << status_pointer;
	
	VoidPointer *solenoid_port_pointer = new VoidPointer;
	*solenoid_port_pointer = initializeSolenoidPort(*port_pointer_pointer, status_pointer);
	
	SOLENOIDJNI_LOG(logDEBUG) << "Status = " << *status_pointer;
	SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << *solenoid_port_pointer;
	
	int *asints = (int *)(*solenoid_port_pointer);
	SOLENOIDJNI_LOG(logDEBUG) << '\t' << asints[0] << '\t' << asints[1] << std::endl;
	
	return env->NewDirectByteBuffer(solenoid_port_pointer, 4);
}