SunSPOT API V6.0


com.sun.spot.sensorboard.peripheral
Class EDemoSerial

java.lang.Object
  extended by com.sun.spot.resources.Resource
      extended by com.sun.spot.peripheral.Serial
          extended by com.sun.spot.sensorboard.peripheral.EDemoSerial
All Implemented Interfaces:
ISerial, ITimeoutableConnection, IResource, Connection, InputConnection, OutputConnection, StreamConnection

public class EDemoSerial
extends Serial
implements ITimeoutableConnection

EDemoSerial - provides access to the serial port of the eDemoboard.

It is possible to append parameters to control the serial port settings. For example:

"edemoserial://usart?baudrate=115200&databits=8&parity=even&stopbits=0"

Allowed values for parity are even, odd, mark and none.


Constructor Summary
EDemoSerial()
           
 
Method Summary
 int available()
           
 void close()
          Close the connection.
 long getTimeout()
          Get the timeout for receiving information on this connection
 int read()
           
 int read(byte[] b, int off, int len)
           
 void setTimeout(long timeout)
          Set the timeout for receiving information on this connection
 void setUSARTParams(int baudrate, int databits, String parity, float stopbits)
          Set the eDemo's USART line parameteres.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class com.sun.spot.peripheral.Serial
cleanUpOldIsolates, closeInputStream, closeOutputStream, inUseByOtherIsolate, openDataInputStream, openDataOutputStream, openInputStream, openOutputStream
 
Methods inherited from class com.sun.spot.resources.Resource
addTag, getTags, getTagValue, hasTag, removeTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.resources.IResource
addTag, getTags, getTagValue, hasTag, removeTag
 

Constructor Detail

EDemoSerial

public EDemoSerial()
Method Detail

setUSARTParams

public void setUSARTParams(int baudrate,
                           int databits,
                           String parity,
                           float stopbits)
                    throws IOException
Set the eDemo's USART line parameteres.

Specified by:
setUSARTParams in interface ISerial
Overrides:
setUSARTParams in class Serial
Parameters:
baudrate - baud speed to set module to
databits - supported values are 5,6,7,8
parity - supported options are none, odd & even
stopbits - supported options are 1 or 2
Throws:
IOException

setTimeout

public void setTimeout(long timeout)
Set the timeout for receiving information on this connection

Specified by:
setTimeout in interface ITimeoutableConnection
Parameters:
timeout - Timeout period in milliseconds. Set this to 0 to turn off timeouts (infinite wait), or to > 0 to wait that long for data before throwing a TimeoutException.

getTimeout

public long getTimeout()
Get the timeout for receiving information on this connection

Specified by:
getTimeout in interface ITimeoutableConnection
Returns:
Timeout period in milliseconds. (= 0 for infinite wait)

read

public int read()
         throws IOException
Specified by:
read in interface ISerial
Overrides:
read in class Serial
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Specified by:
read in interface ISerial
Overrides:
read in class Serial
Throws:
IOException

available

public int available()
              throws IOException
Specified by:
available in interface ISerial
Overrides:
available in class Serial
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in interface ISerial
Overrides:
write in class Serial
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Specified by:
write in interface ISerial
Overrides:
write in class Serial
Throws:
IOException

close

public void close()
Description copied from interface: Connection
Close the connection.

When a connection has been closed, access to any of its methods that involve an I/O operation will cause an IOException to be thrown. Closing an already closed connection has no effect. Streams derived from the connection may be open when method is called. Any open streams will cause the connection to be held open until they themselves are closed. In this latter case access to the open streams is permitted, but access to the connection is not.

Specified by:
close in interface Connection
Overrides:
close in class Serial

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.