robot clothes About Us Projects News
return to lablog homepage
 
 
 

« Arm R&D (Lablog4-25-05) | Main | Open Studios »

April 25, 2005

Setting up a Java Environment (Lablog4-25-05 #2)

I am designing the software for InsideOut in Java. James usually uses C code with some C++ libraries for this kind of project. I feel more comfortable working in Java and I think the robots are suited to object-oriented design.

First I set up a Java environment on my computer. I installed the Java 1.4 SDK and the Eclipse SDK. I had not used Eclipse before, but it makes tasks like creating getters and setters and compiling easier. Eventually, I think I will need to install Apache and Tomcat to run the code on my machine.

I found some robot code on a CMU web site. It includes an example of implementing a serial port interface in Java via a C dll. This might make sense because we already have serial code in C. Here’s part of the Java code:

public synchronized class serialPort
extends java.lang.Object
{
// open serial port at specified baud with other
// appropriate parameters. returns:
// 0 on success
// -1 on failure to open serial port
// -2 on failure to read port state
// -3 on failure to set port state
// coms are: 1 = "COM1"; 2 = "COM2" et cetera
// baud rates are: 1 = 9600; 2=19200; 3=38400;
// 4=57600; 5=115200; 6=230400
public native int openSerial(int comNum, int baudSpec);
public native int closeSerial();
// returns 0 on success or -1 on failure to send byte
public native int sendByte(int theByte);
// initialTimeout is measured in milliseconds //
// returns -6 on failure to set timeout, 0 on success
public native int setReadTimeout(int initialTimeout);
// returns -1 in error or timeout, else returns int
// between 0 and 255
public native int readByte();

static {
System.loadLibrary("sserial");
}

}

sserial is the name of the dll.

Apparently, Java has come out with a javax.comm package for serial communication. That might be a little more efficient than loading a C dll.

Posted by michelle at April 25, 2005 08:47 PM

Comments

James pointed out that all of our previous Java code used serial so I will have to go back and look at it. I still thought it was cool that you can load a Dll from Java.

Posted by: Michelle at April 26, 2005 05:27 PM

I've always liked java and serial -- but lately, i'm more into tea and scones.

Posted by: Joanna at April 29, 2005 10:17 AM

Post a comment




Remember Me?


 
Creative Commons License
This work is licensed under a Creative Commons License.

Powered by Movable Type