All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.internal.io.NativeDevice Maven / Gradle / Ivy

Go to download

leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.

The newest version!
package lejos.internal.io;

import java.io.IOError;
import com.sun.jna.Pointer;

/**
 * This class provides access from Java to Linux character devices. It is intended
 * to allow access from Java to the Lego kernel modules which provide access to
 * EV3 hardware features.
 * 

* TODO: Find a better way to return memory mapped data for use by Java. * @author andy * */ public class NativeDevice extends NativeFile { /** * Create a native device to provide access to the specified character device * @param dname name of the character device */ public NativeDevice(String dname) { super(); try { open(dname, O_RDWR, 0); } catch(Exception e) { throw new IOError(e); } } /** * Map a portion of the device into memory and return a pointer which can be * used to read/write the device. * @param len number of bytes to map * @return a pointer that can be used to access the device memory */ public Pointer mmap(long len) { return super.mmap(len, PROT_READ | PROT_WRITE, MAP_SHARED, 0); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy