com.dalsemi.shell.server.serial
Class SerialServer
java.lang.Object
|
+--java.lang.Thread
|
+--com.dalsemi.shell.server.Server
|
+--com.dalsemi.shell.server.serial.SerialServer
- public class SerialServer
- extends Server
A server that uses a serial port to listen for user connections. For each connection made,
a Serial session is created. All command processing is handled by the session, not this server.
Constructor Summary |
SerialServer(String portName,
int speed,
int dataBits,
int stopBits,
int parity)
Prepares the server to listen on an arbitrary port. |
Method Summary |
protected Session |
acceptNewSession()
Listens on the serial port for connection requests. |
void |
broadcast(String sendThis)
Displays this message to all sessions initiated by this server. |
void |
closeAllPorts()
Closes and releases ownership of this server's serial port. |
Methods inherited from class java.lang.Thread |
activeCount,
checkAccess,
countStackFrames,
currentThread,
destroy,
dumpStack,
enumerate,
getName,
getPriority,
getThreadGroup,
interrupt,
interrupted,
isAlive,
isDaemon,
isInterrupted,
join,
join,
join,
resume,
setDaemon,
setName,
setPriority,
sleep,
sleep,
start,
stop,
stop,
suspend,
toString,
yield |
SerialServer
public SerialServer(String portName,
int speed,
int dataBits,
int stopBits,
int parity)
throws Exception
- Prepares the server to listen on an arbitrary port. The server will not
be started and no connections will be accepted until its
run()
method is executed.
- Parameters:
portName
- the name of the serial portspeed
- the baud rate for the serial port communicationsdataBits
- the data bits used by the serial port communicationsstopBits
- the stop bits used by the serial port communicationsparity
- the parity of the serial port communications- Throws:
- Exception - if the serial port could not be opened or any of the
specified parameters are invalid
acceptNewSession
protected Session acceptNewSession()
- Listens on the serial port for connection requests. Once a
request is made, it creates, initializes, and returns a new
SerialSession to handle that request. This method will block until
a connection is made. Since only one connection is allowed at any
time on the serial server, if a connection already exists, this
method suspends the server. The server will be resumed when the
current connection terminates.
- Overrides:
- acceptNewSession in class Server
- Returns:
- a new
SerialSession
closeAllPorts
public void closeAllPorts()
throws IOException
- Closes and releases ownership of this server's serial port.
- Overrides:
- closeAllPorts in class Server
broadcast
public void broadcast(String sendThis)
- Displays this message to all sessions initiated by this server.
- Overrides:
- broadcast in class Server
- Parameters:
sendThis
- the message to display