UPacketBuilder Class Reference

List of all members.


Detailed Description

UPacketBuilder contains the methods to build a communication packet to the DS2480 based serial adapter.

Version:
0.00
Author:
DS, SH

Public Member Functions

 UPacketBuilder (UAdapterState startUState)
 Constructs a new u packet builder.
virtual void restart ()
 Reset the packet builder to start a new one.
virtual void newPacket ()
 Take the current packet and place it into the vector.
virtual int oneWireReset ()
 Add the command to reset the OneWire at the current speed.
virtual int dataBytes (byte[] dataBytesValue)
 Append data bytes (read/write) to the packet.
virtual int dataBytes (byte[] dataBytesValue, int off, int len)
 Append data bytes (read/write) to the packet.
virtual int dataByte (byte dataByteValue)
 Append a data byte (read/write) to the packet.
virtual int primedDataByte (byte dataByteValue)
 Append a data byte (read/write) to the packet.
virtual int dataBit (bool dataBit, bool strong5V)
 Append a data bit (read/write) to the packet.
virtual int search (OneWireState mState)
 Append a search to the packet.
virtual void setSpeed ()
 Append a search off to set the current speed.
virtual void setToCommandMode ()
 Set the U state to command mode.
virtual void setToDataMode ()
 Set the U state to data mode.
virtual int getParameter (Parameter parameter)
 Append a get parameter to the packet.
virtual int setParameter (SlewRate parameterValue)
 Append a set parameter to the packet.
virtual int setParameter (ProgramPulseTime12 parameterValue)
 Append a set parameter to the packet.
virtual int setParameter (ProgramPulseTime5 parameterValue)
 Append a set parameter to the packet.
virtual int setParameter (WriteOneLowTime parameterValue)
 Append a set parameter to the packet.
virtual int setParameter (SampleOffsetTime parameterValue)
 Append a set parameter to the packet.
virtual int setParameter (AdapterBaud parameterValue)
 Append a set parameter to the packet.
virtual int sendCommand (byte command, bool expectResponse)
 Append a send command to the packet.
virtual void interpretDataBytes (byte[] dataByteResponse, int responseOffset, byte[] result, int offset, int len)
 Interpret the block of bytes.
virtual OWResetResult interpretOneWireReset (byte resetResponse)
 Interpret the reset response byte from a U adapter.
virtual bool interpretOneWireBit (byte bitResponse)
 Interpret the bit response byte from a U adapter.
virtual bool interpretSearch (OneWireState mState, byte[] searchResponse, int responseOffset)
 Interpret the search response and set the 1-Wire state accordingly.
virtual byte interpretPrimedByte (byte[] primedDataResponse, int responseOffset)
 Interpret the data response byte from a primed byte operation.
virtual bool bitRead (byte[] bitBuffer, int address)
 Bit utility to read a bit in the provided array of chars.
virtual void bitWrite (byte[] bitBuffer, int address, bool newBitState)
 Bit utility to write a bit in the provided array of chars.

Static Public Member Functions

static BaudRates getDesiredBaud (int operation, OWSpeed owSpeed, BaudRates maxBaud)
 Request the maximum rate to do an operation.

Public Attributes

const int OPERATION_BYTE = 0
 Byte operation.
const int OPERATION_SEARCH = 1
 Byte operation.
const byte MAX_BYTES_STREAMED = (byte) (64)
 Max bytes to stream at once.
const byte FUNCTION_BIT = (byte) (0x81)
 DS9097U funciton command, single bit.
const byte FUNCTION_SEARCHON = (byte) (0xB1)
 DS9097U funciton command, turn search mode on.
const byte FUNCTION_SEARCHOFF = (byte) (0xA1)
 DS9097U funciton command, turn search mode off.
const byte FUNCTION_RESET = (byte) (0xC1)
 DS9097U funciton command, OneWire reset.
const byte FUNCTION_5VPULSE_NOW = (byte) (0xED)
 DS9097U funciton command, 5V pulse imediate.
const byte FUNCTION_12VPULSE_NOW = (byte) (0xFD)
 DS9097U funciton command, 12V pulse imediate.
const byte FUNCTION_5VPULSE_ARM = (byte) (0xEF)
 DS9097U funciton command, 5V pulse after next byte.
const byte FUNCTION_STOP_PULSE = (byte) (0xF1)
 DS9097U funciton command to stop an ongoing pulse.
const byte BIT_ONE = (byte) (0x10)
 DS9097U bit polarity one for function FUNCTION_BIT.
const byte BIT_ZERO = (byte) (0x00)
 DS9097U bit polarity zero for function FUNCTION_BIT.
const byte PRIME5V_TRUE = (byte) (0x02)
 DS9097U 5V prime on for function FUNCTION_BIT.
const byte PRIME5V_FALSE = (byte) (0x00)
 DS9097U 5V prime off for function FUNCTION_BIT.
const byte CONFIG_MASK = (byte) (0x01)
 DS9097U mask to read or write a configuration parameter.
const byte RESPONSE_RESET_MASK = (byte) (0x03)
 DS9097U mask to read the OneWire reset response byte.
const byte RESPONSE_RESET_SHORT = (byte) (0x00)
 DS9097U OneWire reset result = shorted.
const byte RESPONSE_RESET_PRESENCE = (byte) (0x01)
 DS9097U OneWire reset result = presence.
const byte RESPONSE_RESET_ALARM = (byte) (0x02)
 DS9097U OneWire reset result = alarm.
const byte RESPONSE_RESET_NOPRESENCE = (byte) (0x03)
 DS9097U OneWire reset result = no presence.
const byte RESPONSE_BIT_MASK = (byte) (0x03)
 DS9097U mask to read bit operation result.
const byte RESPONSE_BIT_ONE = (byte) (0x03)
 DS9097U read bit operation 1.
const byte RESPONSE_BIT_ZERO = (byte) (0x00)
 DS9097U read bit operation 0.

Static Public Attributes

static bool doDebugMessages = false
 Enable/disable debug messages.

Protected Attributes

internal int totalReturnLength
 The current current count for the number of return bytes from the packet being created.
internal RawSendPacket packet
 Current raw send packet before it is added to the packetsVector.
internal
System.Collections.ArrayList 
packetsVector
 Vector of raw send packets.
internal bool bitsOnly
 Flag to send only 'bit' commands to the DS2480.

Properties

System.Collections.IEnumerator Packets [get]
 Retrieve enumeration of raw send packets.

Constructor & Destructor Documentation

UPacketBuilder ( UAdapterState  startUState  ) 

Constructs a new u packet builder.

Parameters:
startUState the object that contains the U brick state which is reference when creating packets


Member Function Documentation

virtual void restart (  )  [virtual]

Reset the packet builder to start a new one.

virtual void newPacket (  )  [virtual]

Take the current packet and place it into the vector.

This indicates a place where we need to wait for the results from DS9097U adapter.

virtual int oneWireReset (  )  [virtual]

Add the command to reset the OneWire at the current speed.

Returns:
the number offset in the return packet to get the result of this operation

virtual int dataBytes ( byte[]  dataBytesValue  )  [virtual]

Append data bytes (read/write) to the packet.

Parameters:
dataBytesValue character array of data bytes

Returns:
the number offset in the return packet to get the result of this operation

virtual int dataBytes ( byte[]  dataBytesValue,
int  off,
int  len 
) [virtual]

Append data bytes (read/write) to the packet.

Parameters:
dataBytesValue byte array of data bytes
off offset into the array of data to start
len length of data to send / receive starting at 'off'

Returns:
the number offset in the return packet to get the result of this operation

virtual int dataByte ( byte  dataByteValue  )  [virtual]

Append a data byte (read/write) to the packet.

Parameters:
dataByteValue data byte to append

Returns:
the number offset in the return packet to get the result of this operation

virtual int primedDataByte ( byte  dataByteValue  )  [virtual]

Append a data byte (read/write) to the packet.

Do a strong pullup when the byte is complete

Parameters:
dataByteValue data byte to append

Returns:
the number offset in the return packet to get the result of this operation

virtual int dataBit ( bool  dataBit,
bool  strong5V 
) [virtual]

Append a data bit (read/write) to the packet.

Parameters:
dataBit bit to append
strong5V true if want strong5V after bit

Returns:
the number offset in the return packet to get the result of this operation

virtual int search ( OneWireState  mState  )  [virtual]

Append a search to the packet.

Assume that any reset and search command have already been appended. This will add only the search itself.

Parameters:
mState OneWire state

Returns:
the number offset in the return packet to get the result of this operation

virtual void setSpeed (  )  [virtual]

Append a search off to set the current speed.

virtual void setToCommandMode (  )  [virtual]

Set the U state to command mode.

virtual void setToDataMode (  )  [virtual]

Set the U state to data mode.

virtual int getParameter ( Parameter  parameter  )  [virtual]

Append a get parameter to the packet.

Parameters:
parameter parameter to get

Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( SlewRate  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( ProgramPulseTime12  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( ProgramPulseTime5  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( WriteOneLowTime  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( SampleOffsetTime  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int setParameter ( AdapterBaud  parameterValue  )  [virtual]

Append a set parameter to the packet.

Parameters:
parameterValue parameter value
Returns:
the number offset in the return packet to get the result of this operation

virtual int sendCommand ( byte  command,
bool  expectResponse 
) [virtual]

Append a send command to the packet.

This command does not elicit a response byte.

Parameters:
command command to send
 expectResponse

Returns:
the number offset in the return packet to get the result of this operation (if there is one)

virtual void interpretDataBytes ( byte[]  dataByteResponse,
int  responseOffset,
byte[]  result,
int  offset,
int  len 
) [virtual]

Interpret the block of bytes.

Parameters:
dataByteResponse 
 responseOffset
 result
 offset
 len

virtual OWResetResult interpretOneWireReset ( byte  resetResponse  )  [virtual]

Interpret the reset response byte from a U adapter.

Parameters:
resetResponse reset response byte from U

Returns:
the number representing the result of a 1-Wire reset

virtual bool interpretOneWireBit ( byte  bitResponse  )  [virtual]

Interpret the bit response byte from a U adapter.

Parameters:
bitResponse bit response byte from U

Returns:
boolean representing the result of a 1-Wire bit operation

virtual bool interpretSearch ( OneWireState  mState,
byte[]  searchResponse,
int  responseOffset 
) [virtual]

Interpret the search response and set the 1-Wire state accordingly.

Parameters:
bitResponse bit response byte from U

Parameters:
 mState
 searchResponse
 responseOffset

Returns:
boolean return is true if a valid ID was found when interpreting the search results

virtual byte interpretPrimedByte ( byte[]  primedDataResponse,
int  responseOffset 
) [virtual]

Interpret the data response byte from a primed byte operation.

Parameters:
 primedDataResponse
 responseOffset

Returns:
the byte representing the result of a 1-Wire data byte

static BaudRates getDesiredBaud ( int  operation,
OWSpeed  owSpeed,
BaudRates  maxBaud 
) [static]

Request the maximum rate to do an operation.

virtual bool bitRead ( byte[]  bitBuffer,
int  address 
) [virtual]

Bit utility to read a bit in the provided array of chars.

Parameters:
bitBuffer array of chars where the bit to read is located
address bit location to read (LSBit of first Byte in bitBuffer is postion 0)

Returns:
the boolean value of the bit position

virtual void bitWrite ( byte[]  bitBuffer,
int  address,
bool  newBitState 
) [virtual]

Bit utility to write a bit in the provided array of chars.

Parameters:
bitBuffer array of chars where the bit to write is located
address bit location to write (LSBit of first Byte in bitBuffer is postion 0)
newBitState new bit state


Member Data Documentation

const int OPERATION_BYTE = 0

Byte operation.

const int OPERATION_SEARCH = 1

Byte operation.

const byte MAX_BYTES_STREAMED = (byte) (64)

Max bytes to stream at once.

const byte FUNCTION_BIT = (byte) (0x81)

DS9097U funciton command, single bit.

const byte FUNCTION_SEARCHON = (byte) (0xB1)

DS9097U funciton command, turn search mode on.

const byte FUNCTION_SEARCHOFF = (byte) (0xA1)

DS9097U funciton command, turn search mode off.

const byte FUNCTION_RESET = (byte) (0xC1)

DS9097U funciton command, OneWire reset.

const byte FUNCTION_5VPULSE_NOW = (byte) (0xED)

DS9097U funciton command, 5V pulse imediate.

const byte FUNCTION_12VPULSE_NOW = (byte) (0xFD)

DS9097U funciton command, 12V pulse imediate.

const byte FUNCTION_5VPULSE_ARM = (byte) (0xEF)

DS9097U funciton command, 5V pulse after next byte.

const byte FUNCTION_STOP_PULSE = (byte) (0xF1)

DS9097U funciton command to stop an ongoing pulse.

const byte BIT_ONE = (byte) (0x10)

DS9097U bit polarity one for function FUNCTION_BIT.

const byte BIT_ZERO = (byte) (0x00)

DS9097U bit polarity zero for function FUNCTION_BIT.

const byte PRIME5V_TRUE = (byte) (0x02)

DS9097U 5V prime on for function FUNCTION_BIT.

const byte PRIME5V_FALSE = (byte) (0x00)

DS9097U 5V prime off for function FUNCTION_BIT.

const byte CONFIG_MASK = (byte) (0x01)

DS9097U mask to read or write a configuration parameter.

const byte RESPONSE_RESET_MASK = (byte) (0x03)

DS9097U mask to read the OneWire reset response byte.

const byte RESPONSE_RESET_SHORT = (byte) (0x00)

DS9097U OneWire reset result = shorted.

const byte RESPONSE_RESET_PRESENCE = (byte) (0x01)

DS9097U OneWire reset result = presence.

const byte RESPONSE_RESET_ALARM = (byte) (0x02)

DS9097U OneWire reset result = alarm.

const byte RESPONSE_RESET_NOPRESENCE = (byte) (0x03)

DS9097U OneWire reset result = no presence.

const byte RESPONSE_BIT_MASK = (byte) (0x03)

DS9097U mask to read bit operation result.

const byte RESPONSE_BIT_ONE = (byte) (0x03)

DS9097U read bit operation 1.

const byte RESPONSE_BIT_ZERO = (byte) (0x00)

DS9097U read bit operation 0.

bool doDebugMessages = false [static]

Enable/disable debug messages.

internal RawSendPacket packet [protected]

Current raw send packet before it is added to the packetsVector.

internal System.Collections.ArrayList packetsVector [protected]

Vector of raw send packets.

internal bool bitsOnly [protected]

Flag to send only 'bit' commands to the DS2480.


Property Documentation

System.Collections.IEnumerator Packets [get]

Retrieve enumeration of raw send packets.

Returns:
the enumeration of packets


The documentation for this class was generated from the following file:

Generated on Thu Aug 28 15:41:57 2008 for 1-Wire API for Compact.NET by  doxygen 1.5.6