Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## josx.rcxcomm
Class RCXBean

    java.lang.Object
      josx.rcxcomm.RCXBean

All Implemented Interfaces:
  java.io.Serializable

    public class RCXBean

extends java.lang.Object
implements java.io.Serializable

Handles communication with a LEGO RCX Based on original code by the LEGO3 Team at DTU-IAU

Author:
  Brian Bagnall
See Also:
  Serialized Form

Constructor Summary
`RCXBean()` Creates new RCXBean

Method Summary
`void` | `close()` Close this RCX bean.
`void` | `finalize()`
`void` | `free(java.lang.Object o)` Make the RCX bean available for other threads.
`java.lang.String` | `getComPort()` Getter for the property "ComPort".
`void` | `lock(java.lang.Object o)` Create a lock of this the RCX bean.
`byte` | `receive()` Receive a byte from the RCX.
`byte[]` | `receive(int n)` Receive `n`bytes from the RCX.``
`int` | `receiveInt()` Receive a byte from the RCX.
`void` | `send(byte b)` Send a byte to the RCX.
`void` | `send(byte[] b)` Send a byte array to the RCX
`void` | `sendInt(int v)` Send an integer to the RCX.
`void` | `setComPort(java.lang.String value)` Change or set which comPort should be used for communication with the RCX

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RCXBean

    public RCXBean()

  Creates new RCXBean

Method Detail

### getComPort

    public java.lang.String getComPort()

  Getter for the property "ComPort".

  Returns:
    The name of the comPort used by the bean.

### setComPort

    public void setComPort(java.lang.String value)
                    throws java.io.IOException

  Change or set which comPort should be used for communication with the RCX

  Parameters:
    `value` - A identifier for the comPort e.g. `COM1` or `/dev/ttyS0`
  Throws:
    `java.io.IOException` - If the initialysation of the comPort goes wrong.

### sendInt

    public void sendInt(int v)
                 throws java.io.IOException

  Send an integer to the RCX. The integer is sent as four bytes.

  Parameters:
    `v` - The integer to be sent.
  Throws:
    `java.io.IOException` - If the integer can not be sent.

### send

    public void send(byte b)
              throws java.io.IOException

  Send a byte to the RCX.

  Parameters:
    `b` - The byte to send.
  Throws:
    `java.io.IOException` - If the byte can not be sent.

### send

    public void send(byte[] b)
              throws java.io.IOException

  Send a byte array to the RCX

  Parameters:
    `b` - The byte array to send.
  Throws:
    `java.io.IOException` - If the byte array can not be sent.

### receive

    public byte receive()
                 throws java.io.IOException

  Receive a byte from the RCX.

  Returns:
    A byte sent from the RCX.
  Throws:
    `java.io.IOException` - If the read times out, or something else goes wrong.

### receiveInt

    public int receiveInt()
                   throws java.io.IOException

  Receive a byte from the RCX.

  Returns:
    A byte sent from the RCX.
  Throws:
    `java.io.IOException` - If the read times out, or something else goes wrong.

### receive

    public byte[] receive(int n)
                   throws java.io.IOException

  Receive `n`bytes from the RCX.

  ``
  Parameters:
    `n` - The number of bytes to receive.
  Returns:
    A byte array with bytes from the RCX.
  Throws:
    `java.io.IOException` - If the read times out.

### lock

    public void lock(java.lang.Object o)
              throws java.io.IOException

  Create a lock of this the RCX bean. The RCX bean can not be locked by an other object, before the `free()` has bin run.
  Caution!! The lock does not prevent other thread from using the RCX bean!

  Parameters:
    `o` - The lock is bound to this object. It should therefore be unique for the thread.
  Throws:
    `java.io.IOException` - If an other object has allready locked the RCX bean.

### free

    public void free(java.lang.Object o)

  Make the RCX bean available for other threads.

  Parameters:
    `o` - The object which has the lock.

### close

    public void close()

  Close this RCX bean.

### finalize

    public void finalize()

  Overrides:
    `finalize` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD