khepera
Class SerialConnection

java.lang.Object
  |
  +--khepera.KheperaConnection
        |
        +--khepera.SerialConnection

public class SerialConnection
extends KheperaConnection

Allows communication with the Khepera robot via the serial-port using the via the KheperaConnection class. Serial ports on the system are reffered to by name which is system dependent. Use minicom to find out which port you are using.

IMPORTANT
Since Java has no native support for the serial ports this class uses Java Communications API to communicate with the robot. This API must therefore be installed in the system you use this class on.

Version:
1.2
Author:
Pär Spjuth

Constructor Summary
SerialConnection()
          Creates a connection to the Khepera via the serial port using the default port name on the lab computers at Lunds Department of Computer Sience ie.
SerialConnection(int portSpeed)
          Creates a connection to the Khepera via the serial port using the default port name on the lab computers at Lunds Department of Computer Sience ie.
SerialConnection(java.lang.String portName)
          Creates a connection to the Khepera via the serial port using the default speed ie. 19200 baud.
SerialConnection(java.lang.String portName, int portSpeed)
          Creates a connection to the Khepera via the serial port.
 
Method Summary
 void close()
          Disconnects the robot releasing the serial port.
 void open(java.lang.String robotName)
          Opens a connection to the serial port as specified by the constructor call.
 java.lang.String send(java.lang.String command)
          Sends the given command and waits for the robot response, which is then returned.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialConnection

public SerialConnection(java.lang.String portName,
                        int portSpeed)
Creates a connection to the Khepera via the serial port.
Parameters:
robotName - The name of your robot.
portName - Name of the serial port connected to the robot (see above for a list of port names).
portSpeed - The speed of the port. Use the jumpers on the Khepera to match the speed of your systems serial port. The higher the better.

SerialConnection

public SerialConnection(java.lang.String portName)
Creates a connection to the Khepera via the serial port using the default speed ie. 19200 baud.
Parameters:
robotName - The name of your robot.
portName - Name of the serial port connected to the robot (see above for a list of port names).

SerialConnection

public SerialConnection(int portSpeed)
Creates a connection to the Khepera via the serial port using the default port name on the lab computers at Lunds Department of Computer Sience ie. /dev/modem.
Parameters:
robotName - The name of your robot.
portSpeed - The speed of the port. Use the jumpers on the Khepera to match the speed of your systems serial port. The higher the better.

SerialConnection

public SerialConnection()
Creates a connection to the Khepera via the serial port using the default port name on the lab computers at Lunds Department of Computer Sience ie. /dev/modem and the default port speed ie. 19200 baud.
Parameters:
robotName - The name of your robot.
Method Detail

open

public void open(java.lang.String robotName)
          throws KheperaException
Opens a connection to the serial port as specified by the constructor call.
Overrides:
open in class KheperaConnection
Parameters:
robotName - The name of the robot.
Throws:
KheperaException - If a problem occurs when setting up the serial port.

close

public void close()
Disconnects the robot releasing the serial port.
Overrides:
close in class KheperaConnection
Following copied from class: khepera.KheperaConnection
Throws:
KheperaCommunicationException - When a communications error occurs.

send

public java.lang.String send(java.lang.String command)
                      throws KheperaException
Sends the given command and waits for the robot response, which is then returned.
Overrides:
send in class KheperaConnection
Returns:
The robot response.
Throws:
KheperaException - If an error occurs while reading from the serial port.