codeskin.serial
Class SocketPort

java.lang.Object
  extended by codeskin.serial.SocketPort
All Implemented Interfaces:
ManagedSerialPort, SerialPortClient

public class SocketPort
extends java.lang.Object
implements ManagedSerialPort, SerialPortClient


Constructor Summary
SocketPort(java.lang.String host, int port, java.lang.String protocol)
           
 
Method Summary
 void close()
          Closes port.
 boolean isOpen()
          Checks if port is open.
 void logWriteLn(java.lang.String line)
           
static void main(java.lang.String[] args)
           
 void open(int b, int d, int s, int p, SerialPortClient client)
          Opens serial port (unless already open).
 boolean overflowOccured()
          Checks if buffer overflow occurred.
 void sendBreak(int duration)
          Sends break signal for certain duration.
 boolean serialPortInputParser(int d)
           
 void setDTR(boolean set)
          Sets DTR (data terminal ready) line.
 void setRTS(boolean set)
          Sets RTS (ready to send) line.
 void test()
           
 void write(byte[] b)
          Writes (sends) array of bytes to port.
 void write(int b)
          Writes (sends) 8-bit integer to port.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketPort

public SocketPort(java.lang.String host,
                  int port,
                  java.lang.String protocol)
Method Detail

logWriteLn

public void logWriteLn(java.lang.String line)

open

public void open(int b,
                 int d,
                 int s,
                 int p,
                 SerialPortClient client)
          throws java.io.IOException
Description copied from interface: ManagedSerialPort
Opens serial port (unless already open).

Specified by:
open in interface ManagedSerialPort
Parameters:
b - baudrate
d - number of data bits
s - number of stop bits
p - parity
Throws:
java.io.IOException - - if open fails

isOpen

public boolean isOpen()
Description copied from interface: ManagedSerialPort
Checks if port is open.

Specified by:
isOpen in interface ManagedSerialPort
Returns:
true if port is open

close

public void close()
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Closes port.

Specified by:
close in interface ManagedSerialPort
Throws:
java.io.IOException - if unable to perform close

write

public void write(int b)
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Writes (sends) 8-bit integer to port.

Specified by:
write in interface ManagedSerialPort
Parameters:
b - 8-bit integer
Throws:
java.io.IOException - if unable to write

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from interface: ManagedSerialPort
Writes (sends) array of bytes to port.

Specified by:
write in interface ManagedSerialPort
Parameters:
b - array of bytes
Throws:
java.io.IOException - if unable to write

overflowOccured

public boolean overflowOccured()
Description copied from interface: ManagedSerialPort
Checks if buffer overflow occurred.

Specified by:
overflowOccured in interface ManagedSerialPort
Returns:
true if overflow occurred

setDTR

public void setDTR(boolean set)
            throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sets DTR (data terminal ready) line.

Specified by:
setDTR in interface ManagedSerialPort
Parameters:
set - true for asserting line
Throws:
java.io.IOException - if unable to control line

setRTS

public void setRTS(boolean set)
            throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sets RTS (ready to send) line.

Specified by:
setRTS in interface ManagedSerialPort
Parameters:
set - true for asserting line
Throws:
java.io.IOException - if unable to control line

sendBreak

public void sendBreak(int duration)
               throws java.io.IOException
Description copied from interface: ManagedSerialPort
Sends break signal for certain duration.

Specified by:
sendBreak in interface ManagedSerialPort
Parameters:
duration - time in ms
Throws:
java.io.IOException

serialPortInputParser

public boolean serialPortInputParser(int d)
Specified by:
serialPortInputParser in interface SerialPortClient

test

public void test()

main

public static void main(java.lang.String[] args)