nl.tbdev.IR
Class Serial

java.lang.Object
  |
  +--nl.tbdev.IR.Serial
Direct Known Subclasses:
SerialTini

public class Serial
extends java.lang.Object

Implement the device independend part of the serial communications for IR usage. For IR internal use only!


Field Summary
protected  byte BOF
           
protected  byte CE
           
protected  byte[] data
           
protected  Frame dFrame
           
protected  boolean drainPort
           
protected  byte EOF
           
protected  int ESCREADING
           
protected  Fcs fcs
           
protected  byte[] garbage
           
protected  int GARBAGE
           
protected  byte[] lFrame
           
protected  int locBofs
           
protected  int num
           
protected  int offset
           
protected  int pos
           
protected  int READING
           
protected  int remBofs
           
protected  javax.comm.SerialPort serialPort
           
protected  java.io.InputStream serIn
           
protected  java.io.OutputStream serOut
           
protected  int state
           
protected  int SYNCING
           
protected  byte XBOF
           
protected  int XBOFSYNCING
           
protected  byte XVAL
           
 
Constructor Summary
Serial()
           
 
Method Summary
static void display(java.lang.String comment, byte[] data, int len)
          display is a helper function usefull during debugging.
 Frame readFrame()
          read frame from the serial stream, processing special characters
 void setLocBofs(int bof)
          Set number of BOFs to expect
 void setRemBofs(int bof)
          Set number of BOFs to be sent
 boolean setSpeed(int speed)
          Set speed of COMM port
 void writeFrame(byte[] frame)
          Write the byte array to the output, escapes special characters and adds leadin and CRC.
NOTE: Minimal implementation only! # XBOFs == default!!
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

XBOF

protected final byte XBOF

BOF

protected final byte BOF

EOF

protected final byte EOF

CE

protected final byte CE

XVAL

protected final byte XVAL

serIn

protected java.io.InputStream serIn

serOut

protected java.io.OutputStream serOut

serialPort

protected javax.comm.SerialPort serialPort

drainPort

protected boolean drainPort

fcs

protected Fcs fcs

lFrame

protected byte[] lFrame

dFrame

protected Frame dFrame

offset

protected int offset

state

protected int state

data

protected byte[] data

garbage

protected byte[] garbage

pos

protected int pos

num

protected int num

remBofs

protected int remBofs

locBofs

protected int locBofs

GARBAGE

protected final int GARBAGE

SYNCING

protected final int SYNCING

XBOFSYNCING

protected final int XBOFSYNCING

READING

protected final int READING

ESCREADING

protected final int ESCREADING
Constructor Detail

Serial

public Serial()
Method Detail

readFrame

public Frame readFrame()
read frame from the serial stream, processing special characters
Returns:
Frame returns Frame with results of null if no complete frame could be read or a CRC error occurred.

writeFrame

public void writeFrame(byte[] frame)
Write the byte array to the output, escapes special characters and adds leadin and CRC.
NOTE: Minimal implementation only! # XBOFs == default!!
Parameters:
frame - The array of bytes to be written.

setSpeed

public boolean setSpeed(int speed)
Set speed of COMM port
Parameters:
speed - integer value of speed
Returns:
boolean value indication success/failure

setRemBofs

public void setRemBofs(int bof)
Set number of BOFs to be sent
Parameters:
bof - Number of BOFs

setLocBofs

public void setLocBofs(int bof)
Set number of BOFs to expect
Parameters:
bof - Number of BOFs

display

public static void display(java.lang.String comment,
                           byte[] data,
                           int len)
display is a helper function usefull during debugging. Dumps the data in HEX format to standard output.
Parameters:
comment - Comment to be printed.
data - The data to be displayed.
len - Length of the data to be displayed. Allows for displaying part of the array.