com.bankframe.services.devices
Class MCASerialPort

java.lang.Object
  extended bycom.bankframe.services.devices.MCASerialPort
All Implemented Interfaces:
javax.comm.CommPortOwnershipListener, java.util.EventListener, MCADevice
Direct Known Subclasses:
MagTekIntelliPIN, MagTekMiniMicr, SlipPrinter

public abstract class MCASerialPort
extends java.lang.Object
implements MCADevice, javax.comm.CommPortOwnershipListener

Abstract superclass for all MCA serial port devices.


Field Summary
static java.lang.String SERIALPORT_BAUD
          Baud Rate setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_COMMDRIVER
          Communications Driver setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_DATABITS
          Data Bits setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_FLOWCONTROL
          Flowcontrol setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_NAME
          Port Name setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_PARITY
          Parity setting field in the BankframeDevices.properties file.
static java.lang.String SERIALPORT_STOPBITS
          Stop Bits setting field in the BankframeDevices.properties file.
 
Fields inherited from interface javax.comm.CommPortOwnershipListener
PORT_OWNED, PORT_OWNERSHIP_REQUESTED, PORT_UNOWNED
 
Constructor Summary
MCASerialPort(java.lang.String deviceName)
          MCA SerialPort constructor.
MCASerialPort(java.lang.String deviceName, java.lang.String noInit)
           
 
Method Summary
 int available()
          This method gets the number of bytes that can be read without blocking
 void close()
          This method closes the device.
 void disableNotifications()
          This method disables notifications
 void disableReceiveFraming()
          This method disables receive framing
 void disableReceiveThreshold()
          This method disables thresh hold for receive
 void disableReceiveTimeout()
          This method disables receive timeout
 void enableNotifications(boolean b)
          This method enables notifications
 void enableReceiveFraming(int framingByte)
          This method enables receive framing
 void enableReceiveThreshold(int thresh)
          This method enables thresh hold for receive
 void enableReceiveTimeout(int rcvTimeout)
          This method enables receive timeout
 int getBaudRate()
          This method gets the baud rate
 java.io.BufferedInputStream getBufferedInputStream()
          This method gets Buffered input stream.
 int getDataBits()
          This method gets the number of data bits
 java.lang.String getDeviceName()
          This method gets the device name
 int getFlowControlMode()
          This method gets flow control mode
 java.io.InputStream getInputStream()
          This method gets input stream.
 java.io.OutputStream getOutputStream()
          This method gets output stream.
 int getParity()
          This method gets parity
 java.lang.Object getReceivedData()
          This method gets the last received data from the device
 int getReceiveFramingByte()
          This method gets Receive Framing byte
 int getReceiveThreshold()
          This method gets Receive Threshold
 int getReceiveTimeout()
          This method gets Receive Timeout
 int getStopBits()
          This method gets stop bits
 boolean isCD()
          This method gets the state of the Carrier Detect bit in the UART
 boolean isCTS()
          This method gets the state of the Clear To Send bit in the UART
 boolean isDSR()
          This method gets the state of the Data Set Ready bit in the UART
 boolean isDTR()
          This method gets the state of the Data Terminal Ready bit in the UART
 boolean isReceiveFramingEnabled()
          This method tests if receive framing enabled
 boolean isReceiveThresholdEnabled()
          This method tests of receive thresh hold enabled
 boolean isReceiveTimeoutEnabled()
          This method tests if receive thresh timeout enabled
 boolean isRI()
          This method gets the state of the Ring Indicator bit in the UART
 boolean isRTS()
          This method gets the state of the Request To Send bit in the UART
 void open()
          This method opens the serial device using the port name "serialport.portname=..." specified in the BankframeDevices.properties file for the name deviceName.
 void ownershipChange(int type)
          This method implements method for CommPortOwnershipListener Interface
 int read()
          This method reads the next byte from buffered inputstream.
 int read(byte[] bytes, int off, int len)
          This method reads bytes from buffered inputstream.
 void restartInputThread()
          This method is called by the open( ) method.
 void sendBreak(int millis)
          This method sends break to serial port
 void setDeviceName(java.lang.String deviceName)
          This method sets the device name
 void setDTR(boolean dtr)
          This method sets the Data Terminal Ready bit in the UART
 void setFlowControlMode(int flowControl)
          This method sets flow control mode for serial device
 void setRcvFifoTrigger(int trigger)
          Deprecated. This was advisory only.
 void setRTS(boolean rts)
          This method sets the Request To Send bit in the UART
 void setSerialPortParams(int baud, int databits, int stopbits, int parity)
          This method sets the serial port paramaters for this device
 java.lang.String toString()
          This method gets a string representation of the communications port
 java.lang.Object waitforDataAvailable(int timeOut)
          This method clears the received data value and goes into a wait cycle for a specified time until a new value is received on the serial port If timeout = 0 then the wait cycle is infinite.
 void write(byte[] bytes)
          This method writes bytes to output stream
 void write(int theByte)
          This method writes a byte to output stream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERIALPORT_COMMDRIVER

public static final java.lang.String SERIALPORT_COMMDRIVER
Communications Driver setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_NAME

public static final java.lang.String SERIALPORT_NAME
Port Name setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_BAUD

public static final java.lang.String SERIALPORT_BAUD
Baud Rate setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_DATABITS

public static final java.lang.String SERIALPORT_DATABITS
Data Bits setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_STOPBITS

public static final java.lang.String SERIALPORT_STOPBITS
Stop Bits setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_PARITY

public static final java.lang.String SERIALPORT_PARITY
Parity setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values

SERIALPORT_FLOWCONTROL

public static final java.lang.String SERIALPORT_FLOWCONTROL
Flowcontrol setting field in the BankframeDevices.properties file.

See Also:
Constant Field Values
Constructor Detail

MCASerialPort

public MCASerialPort(java.lang.String deviceName,
                     java.lang.String noInit)
              throws DeviceException

MCASerialPort

public MCASerialPort(java.lang.String deviceName)
              throws DeviceException
MCA SerialPort constructor.

Parameters:
deviceName - is the unique String name for this device
Throws:
DeviceException
Method Detail

available

public int available()
              throws DeviceException
This method gets the number of bytes that can be read without blocking

Returns:
int number of bytes
Throws:
java.io.IOException
DeviceException

close

public void close()
This method closes the device. It kills input thread and closes the serial port connection

Specified by:
close in interface MCADevice

disableNotifications

public void disableNotifications()
This method disables notifications


disableReceiveFraming

public void disableReceiveFraming()
This method disables receive framing


disableReceiveThreshold

public void disableReceiveThreshold()
This method disables thresh hold for receive


disableReceiveTimeout

public void disableReceiveTimeout()
This method disables receive timeout


enableNotifications

public void enableNotifications(boolean b)
This method enables notifications


enableReceiveFraming

public void enableReceiveFraming(int framingByte)
                          throws DeviceException
This method enables receive framing

Throws:
DeviceException

enableReceiveThreshold

public void enableReceiveThreshold(int thresh)
                            throws DeviceException
This method enables thresh hold for receive

Throws:
DeviceException

enableReceiveTimeout

public void enableReceiveTimeout(int rcvTimeout)
                          throws DeviceException
This method enables receive timeout

Throws:
DeviceException

getBaudRate

public int getBaudRate()
This method gets the baud rate

Returns:
The baud rate

getBufferedInputStream

public java.io.BufferedInputStream getBufferedInputStream()
This method gets Buffered input stream. Implementation of MCADevice Interface

Returns:
BufferedInputStream

getDataBits

public int getDataBits()
This method gets the number of data bits

Returns:
int

getDeviceName

public java.lang.String getDeviceName()
This method gets the device name

Specified by:
getDeviceName in interface MCADevice
Returns:
unique String name for this device

getFlowControlMode

public int getFlowControlMode()
This method gets flow control mode

Returns:
int

getInputStream

public java.io.InputStream getInputStream()
This method gets input stream. Implementation of MCADevice Interface

Returns:
InputStream

getOutputStream

public java.io.OutputStream getOutputStream()
This method gets output stream. Implementation of MCADevice Interface

Returns:
OutputStream

getParity

public int getParity()
This method gets parity

Returns:
int

getReceivedData

public java.lang.Object getReceivedData()
This method gets the last received data from the device

Returns:
Object received data

getReceiveFramingByte

public int getReceiveFramingByte()
This method gets Receive Framing byte

Returns:
int framing byte

getReceiveThreshold

public int getReceiveThreshold()
This method gets Receive Threshold

Returns:
int number of bytes for receive threshold

getReceiveTimeout

public int getReceiveTimeout()
This method gets Receive Timeout

Returns:
int number of milliseconds in timeout

getStopBits

public int getStopBits()
This method gets stop bits

Returns:
int

isCD

public boolean isCD()
This method gets the state of the Carrier Detect bit in the UART

Returns:
boolean state

isCTS

public boolean isCTS()
This method gets the state of the Clear To Send bit in the UART

Returns:
boolean state

isDSR

public boolean isDSR()
This method gets the state of the Data Set Ready bit in the UART

Returns:
boolean state

isDTR

public boolean isDTR()
This method gets the state of the Data Terminal Ready bit in the UART

Returns:
boolean state

isReceiveFramingEnabled

public boolean isReceiveFramingEnabled()
This method tests if receive framing enabled

Returns:
boolean

isReceiveThresholdEnabled

public boolean isReceiveThresholdEnabled()
This method tests of receive thresh hold enabled

Returns:
boolean

isReceiveTimeoutEnabled

public boolean isReceiveTimeoutEnabled()
This method tests if receive thresh timeout enabled

Returns:
boolean

isRI

public boolean isRI()
This method gets the state of the Ring Indicator bit in the UART

Returns:
boolean state

isRTS

public boolean isRTS()
This method gets the state of the Request To Send bit in the UART

Returns:
boolean state

open

public void open()
          throws DeviceException
This method opens the serial device using the port name "serialport.portname=..." specified in the BankframeDevices.properties file for the name deviceName. This method always restarts the input reader thread so that the input listener is re-registered. This method always calls that setup() method as its last step. Therefore all initialisation of the device should be place in the setup() method of the derived class.

Specified by:
open in interface MCADevice
Throws:
DeviceException

ownershipChange

public void ownershipChange(int type)
This method implements method for CommPortOwnershipListener Interface

Specified by:
ownershipChange in interface javax.comm.CommPortOwnershipListener

read

public int read()
         throws DeviceException
This method reads the next byte from buffered inputstream.

Returns:
the next byte in the stream
Throws:
DeviceException

read

public int read(byte[] bytes,
                int off,
                int len)
         throws DeviceException
This method reads bytes from buffered inputstream.

Returns:
number of bytes read
Throws:
DeviceException

restartInputThread

public void restartInputThread()
This method is called by the open( ) method. It has to be called if the SerialPort is closed and re-opened for any events to be detected by the event listener.


sendBreak

public void sendBreak(int millis)
This method sends break to serial port


setDeviceName

public void setDeviceName(java.lang.String deviceName)
This method sets the device name

Specified by:
setDeviceName in interface MCADevice
Parameters:
deviceName - is the unique String name for this device

setDTR

public void setDTR(boolean dtr)
This method sets the Data Terminal Ready bit in the UART


setFlowControlMode

public void setFlowControlMode(int flowControl)
                        throws DeviceException
This method sets flow control mode for serial device

Throws:
DeviceException

setRcvFifoTrigger

public void setRcvFifoTrigger(int trigger)
Deprecated. This was advisory only.

This method sets the Receive Fifo trigger level If the uart has a FIFO and if it can have programmable trigger levels, then this method will cause the uart to raise an interrupt after trigger bytes have been received.


setRTS

public void setRTS(boolean rts)
This method sets the Request To Send bit in the UART


setSerialPortParams

public void setSerialPortParams(int baud,
                                int databits,
                                int stopbits,
                                int parity)
                         throws DeviceException
This method sets the serial port paramaters for this device

Throws:
javax.comm.UnsupportedCommOperationException
DeviceException

toString

public java.lang.String toString()
This method gets a string representation of the communications port

Returns:
String representation of the port

waitforDataAvailable

public java.lang.Object waitforDataAvailable(int timeOut)
This method clears the received data value and goes into a wait cycle for a specified time until a new value is received on the serial port If timeout = 0 then the wait cycle is infinite.

Returns:
Object data received

write

public void write(byte[] bytes)
           throws DeviceException
This method writes bytes to output stream

Throws:
DeviceException

write

public void write(int theByte)
           throws DeviceException
This method writes a byte to output stream

Throws:
DeviceException


Copyright © 2005, 2007, Oracle. All rights reserved.