com.buglabs.bug.module.vonhippel
Class VonHippelModuleControl

java.lang.Object
  extended by com.buglabs.bug.module.vonhippel.VonHippelModuleControl
All Implemented Interfaces:
IVonHippelModuleControl, IVonHippelSerialPort, IModuleLEDController

public class VonHippelModuleControl
extends java.lang.Object
implements IVonHippelModuleControl, IModuleLEDController, IVonHippelSerialPort


Field Summary
 
Fields inherited from interface com.buglabs.bug.module.vonhippel.pub.IVonHippelModuleControl
VH_ADC_W1_CH0, VH_ADC_W1_CH01, VH_ADC_W1_CH1, VH_ADC_W1_CH10, VH_ADC_W1_CH2, VH_ADC_W1_CH23, VH_ADC_W1_CH3, VH_ADC_W1_CH32, VH_ADC_W1_EN, VH_ADC_W2_EN, VH_ADC_W2_IM, VH_ADC_W2_SPD, VH_DAC_BCH, VH_DAC_CHA, VH_DAC_CHB, VH_DAC_PD100K, VH_DAC_PD1K, VH_DAC_PDF, VH_DAC_PU, VH_DAC_W1_ALL, VH_DAC_W1_ALLA, VH_DAC_W1_ALLB, VH_DAC_W1_ALLI, VH_DAC_W1_EC, VH_DAC_W1_LA, VH_DAC_W1_LB, VH_DAC_W1_RDA, VH_DAC_W1_RDB, VH_DAC_W1_UA, VH_DAC_W1_UALL, VH_DAC_W1_UB
 
Constructor Summary
VonHippelModuleControl(VonHippel vh, int slotId)
           
 
Method Summary
 void clearGPIO(int pin)
          Sets specified pin as low
 void clearIOX(int pin)
          Sets specified IOX pin as high.
protected  void dispose()
          Close input and output streams.
 boolean getAutoCTS()
           
 boolean getAutoRTS()
           
 java.lang.String getBaudrate()
           
 int getBitsPerChar()
           
 boolean getBlocking()
           
 java.lang.String getParity()
           
 int getRDACResistance()
          Get RDAC resistance value from ioctl
 java.io.InputStream getRS232InputStream()
          Gets the input stream associated with the RS232 port on Von Hippel module.
 java.io.OutputStream getRS232OutputStream()
          Gets the output stream associated with the RS232 port on Von Hippel module.
 java.io.InputStream getSerialInputStream()
          Gets the input stream associated with the RS232 port on Von Hippel module.
 java.io.OutputStream getSerialOutputStream()
          Gets the output stream associated with the RS232 port on Von Hippel module.
 int getStatus()
          Returns status of module.
 java.lang.String getStopBits()
           
 boolean isInputStreamOpen()
           
 boolean isOutputStreamOpen()
           
 int LEDGreenOff()
          Set module's Green LED off.
 int LEDGreenOn()
          Set module's Green LED on.
 int LEDRedOff()
          Set module's Red LED off.
 int LEDRedOn()
          Set module's Red LED on.
 void makeGPIOIn(int pin)
          Sets specified pin as an in pin.
 void makeGPIOOut(int pin)
          Sets specified pin as an output pin.
 void makeIOXIn(int pin)
          Sets specified IOX pin as an in pin
 void makeIOXOut(int pin)
          Sets specified IOX pin as an out pin
 int readADC()
          Read value after last conversion.
 int readDAC(int channel)
          Read channel after last conversion.
 void setAutoCTS(boolean autoCTS)
           
 void setAutoRTS(boolean autoRTS)
           
 void setBaudrate(java.lang.String baudrate)
          Set baud rate for serial port.
 void setBitsPerChar(int bitsPerChar)
           
 void setBlocking(boolean blocking)
           
 void setGPIO(int pin)
          Sets specified pin as high
 void setIOX(int pin)
          Sets specified IOX pin as high.
 int setLEDGreen(boolean state)
           
 int setLEDRed(boolean state)
           
 void setParity(java.lang.String parity)
           
 void setRDACResistance(int resistance)
          Set RDAC to adjust LDO voltage
 void setStopBits(java.lang.String stopBits)
           
 void writeADC(int control)
           
 void writeDAC(int digital)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VonHippelModuleControl

public VonHippelModuleControl(VonHippel vh,
                              int slotId)
Method Detail

dispose

protected void dispose()
Close input and output streams.


LEDGreenOff

public int LEDGreenOff()
                throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Set module's Green LED off. Note that the state of the LED will also be reflected in GPIO pin 2

Specified by:
LEDGreenOff in interface IVonHippelModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

LEDGreenOn

public int LEDGreenOn()
               throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Set module's Green LED on. Note that the state of the LED will also be reflected in GPIO pin 2

Specified by:
LEDGreenOn in interface IVonHippelModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

LEDRedOff

public int LEDRedOff()
              throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Set module's Red LED off. Note that the state of the LED will also be reflected in GPIO pin 3

Specified by:
LEDRedOff in interface IVonHippelModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

LEDRedOn

public int LEDRedOn()
             throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Set module's Red LED on. Note that the state of the LED will also be reflected in GPIO pin 3

Specified by:
LEDRedOn in interface IVonHippelModuleControl
Returns:
value returned by ioctl.
Throws:
java.io.IOException

clearGPIO

public void clearGPIO(int pin)
               throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified pin as low

Specified by:
clearGPIO in interface IVonHippelModuleControl
Parameters:
pin - to set as low
Throws:
java.io.IOException

clearIOX

public void clearIOX(int pin)
              throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified IOX pin as high. Note that pin 0 will set Red LED off (not GPIO red), 1 will set yellow LED off, 2 will set green LED off (not GPIO LED), 3 will set blue LED off.

Specified by:
clearIOX in interface IVonHippelModuleControl
Throws:
java.io.IOException

writeADC

public void writeADC(int control)
              throws java.io.IOException
Specified by:
writeADC in interface IVonHippelModuleControl
Parameters:
control - the control word to be written to ADC. Used to initiate ADC conversion and also configure ADC device for ADC single-ended or differential, among other things. see bmi_vh.h and bmi_vh.c in kernel.
Throws:
java.io.IOException

readADC

public int readADC()
            throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Read value after last conversion.

Specified by:
readADC in interface IVonHippelModuleControl
Throws:
java.io.IOException

writeDAC

public void writeDAC(int digital)
              throws java.io.IOException
Specified by:
writeDAC in interface IVonHippelModuleControl
Parameters:
digital - the control word encoded digital input to be encoded as analog out. See datasheet and bmi_vh.h and bmi_vh.c in kernel.
Throws:
java.io.IOException

readDAC

public int readDAC(int channel)
            throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Read channel after last conversion.

Specified by:
readDAC in interface IVonHippelModuleControl
Parameters:
channel - should be either VH_DAC_W1_RDA for channel A or VH_DAC_W1_RDB for channel B.
Throws:
java.io.IOException

getRDACResistance

public int getRDACResistance()
                      throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Get RDAC resistance value from ioctl

Specified by:
getRDACResistance in interface IVonHippelModuleControl
Throws:
java.io.IOException

getStatus

public int getStatus()
              throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Returns status of module. As passed up from ioctl. for information about the format please see line 500 at bug-linux-2.6.27.2/drivers/bmi/pims/vonhippel/bmi_vh.c

Specified by:
getStatus in interface IVonHippelModuleControl
Returns:
integer containing status information of GPIO and IOX bits
Throws:
java.io.IOException

makeGPIOIn

public void makeGPIOIn(int pin)
                throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified pin as an in pin. Note that the driver sets pins 0 and 1 as in by default

Specified by:
makeGPIOIn in interface IVonHippelModuleControl
Parameters:
pin - to set as Out
Throws:
java.io.IOException

makeGPIOOut

public void makeGPIOOut(int pin)
                 throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified pin as an output pin. Note that the driver sets pins 2 and 3 as out by default

Specified by:
makeGPIOOut in interface IVonHippelModuleControl
Parameters:
pin - to set as Out
Throws:
java.io.IOException

makeIOXIn

public void makeIOXIn(int pin)
               throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified IOX pin as an in pin

Specified by:
makeIOXIn in interface IVonHippelModuleControl
Throws:
java.io.IOException

makeIOXOut

public void makeIOXOut(int pin)
                throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified IOX pin as an out pin

Specified by:
makeIOXOut in interface IVonHippelModuleControl
Throws:
java.io.IOException

setGPIO

public void setGPIO(int pin)
             throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified pin as high

Specified by:
setGPIO in interface IVonHippelModuleControl
Parameters:
pin - to set as high
Throws:
java.io.IOException

setIOX

public void setIOX(int pin)
            throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Sets specified IOX pin as high. Note that pin 0 will set Red LED on (not GPIO red), 1 will set yellow LED on, 2 will set green LED on (not GPIO LED), 3 will set blue LED on.

Specified by:
setIOX in interface IVonHippelModuleControl
Throws:
java.io.IOException

setRDACResistance

public void setRDACResistance(int resistance)
                       throws java.io.IOException
Description copied from interface: IVonHippelModuleControl
Set RDAC to adjust LDO voltage

Specified by:
setRDACResistance in interface IVonHippelModuleControl
Parameters:
resistance - value
Throws:
java.io.IOException

setLEDGreen

public int setLEDGreen(boolean state)
                throws java.io.IOException
Specified by:
setLEDGreen in interface IModuleLEDController
Throws:
java.io.IOException

setLEDRed

public int setLEDRed(boolean state)
              throws java.io.IOException
Specified by:
setLEDRed in interface IModuleLEDController
Parameters:
state - on = true, off = false;
Returns:
the return of the underlying ioctl.
Throws:
java.io.IOException

getRS232InputStream

public java.io.InputStream getRS232InputStream()
Description copied from interface: IVonHippelModuleControl
Gets the input stream associated with the RS232 port on Von Hippel module. This implementation is based on the javax.microedition.commports API. The port is set up with the following parameters in VonHippelModuleControl: baudrate=9600 bitsperchar=8 stopbits=1 parity=none autocts=off autorts=off blocking=off

Specified by:
getRS232InputStream in interface IVonHippelModuleControl
Returns:
stream associated with RS232 input (reading)

getRS232OutputStream

public java.io.OutputStream getRS232OutputStream()
Description copied from interface: IVonHippelModuleControl
Gets the output stream associated with the RS232 port on Von Hippel module. This implementation is based on the javax.microedition.commports API. The port is set up with the following parameters in VonHippelModuleControl: baudrate=9600 bitsperchar=8 stopbits=1 parity=none autocts=off autorts=off blocking=off

Specified by:
getRS232OutputStream in interface IVonHippelModuleControl
Returns:
stream associated with RS232 output (writing)

getSerialInputStream

public java.io.InputStream getSerialInputStream()
                                         throws java.io.IOException
Description copied from interface: IVonHippelSerialPort
Gets the input stream associated with the RS232 port on Von Hippel module. This implementation is based on the javax.microedition.commports API. The port is set up with the following parameters in VonHippelModuleControl: baudrate=9600 bitsperchar=8 stopbits=1 parity=none autocts=off autorts=off blocking=off

Specified by:
getSerialInputStream in interface IVonHippelSerialPort
Returns:
stream associated with RS232 input (reading)
Throws:
java.io.IOException

getSerialOutputStream

public java.io.OutputStream getSerialOutputStream()
                                           throws java.io.IOException
Description copied from interface: IVonHippelSerialPort
Gets the output stream associated with the RS232 port on Von Hippel module. This implementation is based on the javax.microedition.commports API. The port is set up with the following parameters in VonHippelModuleControl: baudrate=9600 bitsperchar=8 stopbits=1 parity=none autocts=off autorts=off blocking=off

Specified by:
getSerialOutputStream in interface IVonHippelSerialPort
Returns:
stream associated with RS232 output (writing)
Throws:
java.io.IOException

getBaudrate

public java.lang.String getBaudrate()
Specified by:
getBaudrate in interface IVonHippelSerialPort
Returns:
baud rate setting for serial port.

setBaudrate

public void setBaudrate(java.lang.String baudrate)
                 throws java.io.IOException
Description copied from interface: IVonHippelSerialPort
Set baud rate for serial port.

Specified by:
setBaudrate in interface IVonHippelSerialPort
Throws:
java.io.IOException - Is thrown if connection is already open.

getBitsPerChar

public int getBitsPerChar()
Specified by:
getBitsPerChar in interface IVonHippelSerialPort
Returns:
Bits per char of serial connection.

getStopBits

public java.lang.String getStopBits()
Specified by:
getStopBits in interface IVonHippelSerialPort
Returns:
get stop bits of serial connection.

setStopBits

public void setStopBits(java.lang.String stopBits)
                 throws java.io.IOException
Specified by:
setStopBits in interface IVonHippelSerialPort
Throws:
java.io.IOException - Is thrown if connection is already open.

getParity

public java.lang.String getParity()
Specified by:
getParity in interface IVonHippelSerialPort
Returns:

setParity

public void setParity(java.lang.String parity)
               throws java.io.IOException
Specified by:
setParity in interface IVonHippelSerialPort
Throws:
java.io.IOException - Is thrown if connection is already open.

getAutoCTS

public boolean getAutoCTS()
Specified by:
getAutoCTS in interface IVonHippelSerialPort
Returns:

setAutoCTS

public void setAutoCTS(boolean autoCTS)
                throws java.io.IOException
Specified by:
setAutoCTS in interface IVonHippelSerialPort
Throws:
java.io.IOException - Is thrown if connection is already open.

getAutoRTS

public boolean getAutoRTS()
Specified by:
getAutoRTS in interface IVonHippelSerialPort
Returns:
Is thrown if connection is already open.

setAutoRTS

public void setAutoRTS(boolean autoRTS)
                throws java.io.IOException
Specified by:
setAutoRTS in interface IVonHippelSerialPort
Throws:
java.io.IOException

getBlocking

public boolean getBlocking()
Specified by:
getBlocking in interface IVonHippelSerialPort
Returns:

setBlocking

public void setBlocking(boolean blocking)
                 throws java.io.IOException
Specified by:
setBlocking in interface IVonHippelSerialPort
Throws:
java.io.IOException

isInputStreamOpen

public boolean isInputStreamOpen()
Specified by:
isInputStreamOpen in interface IVonHippelSerialPort
Returns:
true if a client has already opened the input stream.

isOutputStreamOpen

public boolean isOutputStreamOpen()
Specified by:
isOutputStreamOpen in interface IVonHippelSerialPort
Returns:
true if a client has already opened the output stream.

setBitsPerChar

public void setBitsPerChar(int bitsPerChar)
                    throws java.io.IOException
Specified by:
setBitsPerChar in interface IVonHippelSerialPort
Throws:
java.io.IOException - Is thrown if connection is already open.