Serial Port Programming

by Scott Preston - 2010-08-19 00:00:00

I am going to talk about accessing the serial port via Java or via an HTTP/Serial Bridge. Accessing serial ports is the preferred method of communication to microcontrollers like the Basic Stamp 2, or Arduino.

This should allow you to access the serial port via a web or high-level language rather than having to use C or C++.

The Java Media Framework

The Java Media Framework, by Oracle (formerly Sun Microsystems), provices native access to the serial port via JNI (Java’s Native Interface). There are two versions of this, one for Windows 2.x and one for Linux 3.x.

You can download both of these here:

Installing On Windows

To install on Windows you will need to do the following:

  1. Unzip the file.
  2. Copy win32com.dll to your \bin directory.
  3. Copy comm.jar to and javax.comm.properties your \lib directory.
  4. Add comm.jar to your CLASSPATH

Installing On Linux

  1. Untar the file.
  2. Copy cp libLinuxSerialParallel.so to /usr/lib
  3. Copy comm.jar and javax.comm.properties to your /jre/lib directory
  4. Add comm.jar to your CLASSPATH

An HTTP Bridge

  1. Follow the instructions for Windows or Linux above.
  2. Email me for the java-bridge client
  3. Run the following program in command line: java -cp scottsbots-bridge.jar com.scottsbots.javabridge 5050, where 5050 is the TCP/IP Port number the bridge will run.

Poll Of The Day

My Books

Robotics Programming 101

Robotics Programming 101

Robotics Programming 101 shows how program a real robot, speech, vision, more...

Ubuntu Robotics - A Robotics Programming 101 Extra

Ubuntu Robotics - A Robotics Programming 101 Extra

This extra highlights all of the Ubuntu specific robotics configuration details in Robotics Programming 101.

Only $0.99 on Amazon.Com

Motion Detection - A Robotics Programming 101 Extra

Motion Detection - A Robotics Programming 101 Extra

This extra shows you how to write a motion detector for your robot with a network or web camera.

Only $0.99 on Amazon.Com

The Definitive Guide To Building Java Robots

The Definitive Guide to Building Java Robots

This was my first book on robotics and using the Java Language to interface between sensors, motors and microcontrollers with a PC capable of doing speech and vision.