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

lejos.remote.nxt.NXTConnection 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.remote.nxt;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public abstract class NXTConnection implements StreamConnection {

    /**
     * Lego Communications Protocol (LCP) I/O mode. The LCP is defined by The Lego Company to allow limited remote 
     * command control of a NXT brick. 
     * 
     * See the Lego Mindstorms Site. Look for the Bluetooth Developer Kit in Support |
     * Files | Advanced
     */
    public static final int LCP = 1;
    /**
     * PACKET I/O mode. This is default and  is probably the best mode to use if you are talking to a
     * NXT using the leJOS classes. Headers are included for each packet of data sent and received.
     */
    public static final int PACKET = 0;
    /**
     * RAW I/O mode. This mode is just that and omits any headers. It is used normally for connections to non-NXT 
     * devices such as cell phones, etc.
     */
    public static final int RAW = 2;
    
	@Override
	public DataInputStream openDataInputStream() {
		return new DataInputStream(openInputStream());
	}

	@Override
	public InputStream openInputStream() {
		return new NXTInputStream(this, 256);
	}

	@Override
	public abstract void close() throws IOException;

	@Override
	public DataOutputStream openDataOutputStream() {
		return new DataOutputStream(openOutputStream());
	}

	@Override
	public OutputStream openOutputStream() {
		return new NXTOutputStream(this, 256);
	}

	public abstract int read(byte[] buf, int length);

	public abstract int write(byte[] buffer, int numBytes);

	public abstract int read(byte[] buf, int length, boolean b);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy