com.dalsemi.onewire.container
Class JibComm

java.lang.Object
  |
  +--com.dalsemi.onewire.container.JibComm

public class JibComm
extends Object

JibComm - an object that implements the necessary communication protocol to access the Java iButtons. Note that many methods are now synchronized because they access global byte arrays. This should not affect performance, however, since applications should be using the DSPortAdapter methods beginExclusive(boolean) and endExclusive() to synchronize their 1-Wire operations.

Usage

Used primarily by OneWireContainer16

Version:
0.04, 23 Jan 2002
Author:
K, JK
See Also:
OneWireContainer16

Field Summary
static boolean doDebugMessages
          enable/disable debug messages
 int min_read_runtime
           
 
Constructor Summary
JibComm(OneWireContainer16 owc, DSPortAdapter newAdapter, byte[] newAddress)
          Constructs a JibComm object to communicate with this Java iButton.
 
Method Summary
 void checkStatus(int runTime, int dir, byte[] status, int start)
          Checks the status of this Java iButton.
 void correctPOR()
          Corrects the device from a Power-On-Reset (POR) error.
 byte[] getData(int length)
          Gets data from this Java iButton.
 void getHeader(byte[] header, int start)
          Gets header from this Java iButton.
 void getStatus(byte[] status, int start)
          Gets the status from this Java iButton.
 void interrupt(int runTime)
          Interrupts the Micro in this Java iButton.
 void reset()
          Resets the Micro in this Java iButton.
 void run(int runTime)
          Runs the Micro in this Java iButton.
 void sendCommand(byte[] commandBuffer, byte[] releaseBuffer, boolean powerMode, long sleepTime)
          Sends command to this Java iButton.
 void setData(byte[] data)
          Sets data to be written to this Java iButton.
 void setHeader(byte[] header)
          Sets header to be written to this Java iButton.
static void setMinRuntime(int runtime)
          Sets the time given by a host for the Java Powered iButton to perform its task.
static void setRuntimeMultiplier(int multiplier)
          Sets the incremental increase in runtime a host will give a Java Powered iButton to perform its task.
 void setStatus(int runTime)
          Sets status register of this Java iButton.
 byte[] transferJibData(byte[] data, int runTime)
          Transfers data to and from this Java iButton.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doDebugMessages

public static boolean doDebugMessages
enable/disable debug messages

min_read_runtime

public int min_read_runtime
Constructor Detail

JibComm

public JibComm(OneWireContainer16 owc,
               DSPortAdapter newAdapter,
               byte[] newAddress)
        throws IllegalArgumentException
Constructs a JibComm object to communicate with this Java iButton.
Parameters:
newAdapter - adapter used to communicate with this Java iButton
newAddress - address of this Java iButton
Throws:
IllegalArgumentException - Invalid Java iButton address
See Also:
Address
Method Detail

setMinRuntime

public static void setMinRuntime(int runtime)
Sets the time given by a host for the Java Powered iButton to perform its task. In some cases, increases in this value may help avoid communications errors. 63 milliseconds is the absolute lowest rated value, but 96 milliseconds makes for fewer errors.
Parameters:
runtime - minimum runtime the host gives a Java iButton to perform its task (in ms)
Throws:
IllegalArgumentException - on illegal run time values (must be at least 63)

setRuntimeMultiplier

public static void setRuntimeMultiplier(int multiplier)
Sets the incremental increase in runtime a host will give a Java Powered iButton to perform its task. Beyond the initial minimum runtime, the Java iButton only understands increments of 250 milliseconds. However, due to clock and timing variations, this value may need to be altered. CRC errors are common if this value is too low for a given operation. 250 milliseconds is the absolute lowest rated value. 290 milliseconds is the default.
Parameters:
multiplier - new incremental runtime increase value to be used for this Java iButton to perform its task (in ms)
Throws:
IllegalArgumentException - on illegal multiplier values (must be at least 250)

transferJibData

public byte[] transferJibData(byte[] data,
                              int runTime)
                       throws OneWireException,
                              OneWireIOException,
                              IllegalArgumentException
Transfers data to and from this Java iButton.
Parameters:
data - byte array with data to be written to this Java iButton
runTime - a 4 bit value (0 -15) that represents the expected run time of the device. Actual run time is calculated as followed:
    runTime * 250 + 62.5 mS 
Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS 1 -> 1 * 250 + 62.5 = 312.5 mS
and so on.
Returns:
byte array containing data read back from this Java iButton.
Throws:
IllegalArgumentException - Invalid run time value
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]

correctPOR

public void correctPOR()
                throws OneWireException,
                       OneWireIOException
Corrects the device from a Power-On-Reset (POR) error.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]

getStatus

public void getStatus(byte[] status,
                      int start)
               throws OneWireException,
                      OneWireIOException
Gets the status from this Java iButton.
Returns:
status byte array read from this Java iButton. The contents of the status array is as follows:
      Byte 0 - number of free bytes in the Input Buffer.
      Byte 1 - number of used bytes in the Output Buffer.
      Byte 2 - contents of the OWMS Register.
      Byte 3 - contents of the CPST register.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), setStatus(int)

checkStatus

public void checkStatus(int runTime,
                        int dir,
                        byte[] status,
                        int start)
                 throws OneWireIOException,
                        OneWireException
Checks the status of this Java iButton.
Parameters:
runTime - a 4 bit value (0 -15) that represents the expected run time of the device. Actual run time is calculated as followed:
    runTime * 250 + 62.5 mS 
Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS 1 -> 1 * 250 + 62.5 = 312.5 mS
and so on.
dir - SEND if sending data to this Java iButton, RECEIVE if receiving
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
getStatus(byte[], int), setStatus(int)

setStatus

public void setStatus(int runTime)
               throws OneWireException,
                      OneWireIOException
Sets status register of this Java iButton.
Parameters:
runTime - a 4 bit value (0 -15) that represents the expected run time of the device Actual run time is calculated as followed:
    runTime * 250 + 62.5 mS 
Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS 1 -> 1 * 250 + 62.5 = 312.5 mS
and so on.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), getStatus(byte[], int)

setHeader

public void setHeader(byte[] header)
               throws OneWireException,
                      OneWireIOException,
                      IllegalArgumentException
Sets header to be written to this Java iButton.
Parameters:
header - byte array with the header information
Throws:
IllegalArgumentException - Invalid header length
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), getHeader(byte[], int)

getHeader

public void getHeader(byte[] header,
                      int start)
               throws OneWireException,
                      OneWireIOException
Gets header from this Java iButton.
Returns:
header read from this Java iButton.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), setHeader(byte[])

setData

public void setData(byte[] data)
             throws OneWireException,
                    OneWireIOException
Sets data to be written to this Java iButton.
Parameters:
data - data to be written to this Java iButton
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), getData(int)

getData

public byte[] getData(int length)
               throws OneWireException,
                      OneWireIOException
Gets data from this Java iButton.
Parameters:
length - expected number of bytes of data to be read from the IPR
Returns:
data from this Java iButton.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]
See Also:
checkStatus(int, int, byte[], int), setData(byte[])

run

public void run(int runTime)
         throws OneWireException,
                OneWireIOException
Runs the Micro in this Java iButton.
Parameters:
runTime - a 4 bit value (0 -15) that represents the expected run time of the device Actual run time is calculated as followed:
    runTime * 250 + 62.5 mS 
Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS 1 -> 1 * 250 + 62.5 = 312.5 mS
and so on.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]

interrupt

public void interrupt(int runTime)
               throws OneWireException,
                      OneWireIOException
Interrupts the Micro in this Java iButton.
Parameters:
runTime - a 4 bit value (0 -15) that represents the expected run time of the device Actual run time is calculated as followed:
    runTime * 250 + 62.5 mS 
Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS 1 -> 1 * 250 + 62.5 = 312.5 mS
and so on.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]

reset

public void reset()
           throws OneWireException,
                  OneWireIOException
Resets the Micro in this Java iButton.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]

sendCommand

public void sendCommand(byte[] commandBuffer,
                        byte[] releaseBuffer,
                        boolean powerMode,
                        long sleepTime)
                 throws OneWireException,
                        OneWireIOException
Sends command to this Java iButton.
Parameters:
commandBuffer - byte array containing the command
releaseBuffer - byte array containing the release code
powerMode - true if power supply is to be toggled
sleepTime - sleep time for the program while the Micro runs. Applicable only if powerMode is true.
Throws:
OneWireException - Part could not be found [ fatal ]
OneWireIOException - Data wasn't transferred properly [ recoverable ]


Copyright © 1999-2003 Dallas Semiconductor. All Rights Reserved.