1-Wire API for Compact.NET  Version 4.10
UPacketBuilder Class Reference

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

Collaboration diagram for UPacketBuilder:

Public Member Functions

 UPacketBuilder (UAdapterState startUState)
 Constructs a new u packet builder. More...
 
virtual void Restart ()
 Reset the packet builder to start a new one. More...
 
virtual void NewPacket ()
 Take the current packet and place it into the vector. More...
 
virtual int OneWireReset ()
 Add the command to reset the OneWire at the current speed. More...
 
virtual int DataBytes (byte[] dataBytesValue)
 Append data bytes (read/write) to the packet. More...
 
virtual int DataBytes (byte[] dataBytesValue, int off, int len)
 Append data bytes (read/write) to the packet. More...
 
virtual int DataByte (byte dataByteValue)
 Append a data byte (read/write) to the packet. More...
 
virtual int PrimedDataByte (byte dataByteValue)
 Append a data byte (read/write) to the packet. More...
 
virtual int DataBit (bool dataBit, bool strong5V)
 Append a data bit (read/write) to the packet. More...
 
virtual int Search (OneWireState mState)
 Append a Search to the packet. More...
 
virtual void SetSpeed ()
 Append a Search off to set the current speed. More...
 
virtual void SetToCommandMode ()
 Set the U state to command mode. More...
 
virtual void SetToDataMode ()
 Set the U state to data mode. More...
 
virtual int GetParameter (Parameter parameter)
 Append a get parameter to the packet. More...
 
virtual int SetParameter (SlewRate parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SetParameter (ProgramPulseTime12 parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SetParameter (ProgramPulseTime5 parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SetParameter (WriteOneLowTime parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SetParameter (SampleOffsetTime parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SetParameter (AdapterBaud parameterValue)
 Append a set parameter to the packet. More...
 
virtual int SendCommand (byte command, bool expectResponse)
 Append a send command to the packet. More...
 
virtual void InterpretDataBytes (byte[] dataByteResponse, int responseOffset, byte[] result, int offset, int len)
 Interpret the block of bytes More...
 
virtual OWResetResult InterpretOneWireReset (byte resetResponse)
 Interpret the reset response byte from a U adapter More...
 
virtual bool InterpretOneWireBit (byte bitResponse)
 Interpret the bit response byte from a U adapter More...
 
virtual bool InterpretSearch (OneWireState mState, byte[] searchResponse, int responseOffset)
 Interpret the Search response and set the 1-Wire state accordingly. More...
 
virtual byte InterpretPrimedByte (byte[] primedDataResponse, int responseOffset)
 Interpret the data response byte from a primed byte operation More...
 
virtual bool BitRead (byte[] bitBuffer, int address)
 Bit utility to read a bit in the provided array of chars. More...
 
virtual void BitWrite (byte[] bitBuffer, int address, bool newBitState)
 Bit utility to write a bit in the provided array of chars. More...
 

Static Public Member Functions

static uint GetDesiredBaud (int operation, OWSpeed owSpeed, uint maxBaud)
 Request the maximum rate to do an operation More...
 

Public Attributes

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

Static Public Attributes

static bool doDebugMessages = false
 Enable/disable debug messages More...
 

Protected Attributes

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

Properties

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

Detailed Description

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

<version>0.00</version> <author>DS, SH</author>

Constructor & Destructor Documentation

◆ UPacketBuilder()

UPacketBuilder ( UAdapterState  startUState)

Constructs a new u packet builder.

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

Member Function Documentation

◆ BitRead()

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

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

Parameters
bitBufferarray of chars where the bit to read is located
addressbit location to read (LSBit of first Byte in bitBuffer is postion 0)
Returns
the boolean value of the bit position

◆ BitWrite()

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

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

Parameters
bitBufferarray of chars where the bit to write is located
addressbit location to write (LSBit of first Byte in bitBuffer is postion 0)
newBitStatenew bit state

◆ DataBit()

virtual int DataBit ( bool  dataBit,
bool  strong5V 
)
virtual

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

Parameters
DataBitbit to append
strong5Vtrue if want strong5V after bit
Returns
the number offset in the return packet to get the result of this operation

◆ DataByte()

virtual int DataByte ( byte  dataByteValue)
virtual

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

Parameters
dataByteValuedata byte to append
Returns
the number offset in the return packet to get the result of this operation

◆ DataBytes() [1/2]

virtual int DataBytes ( byte []  dataBytesValue)
virtual

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

Parameters
dataBytesValuecharacter array of data bytes
Returns
the number offset in the return packet to get the result of this operation

◆ DataBytes() [2/2]

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

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

Parameters
dataBytesValuebyte array of data bytes
offoffset into the array of data to start
lenlength of data to send / receive starting at 'off'
Returns
the number offset in the return packet to get the result of this operation

◆ GetDesiredBaud()

static uint GetDesiredBaud ( int  operation,
OWSpeed  owSpeed,
uint  maxBaud 
)
static

Request the maximum rate to do an operation

◆ GetParameter()

virtual int GetParameter ( Parameter  parameter)
virtual

Append a get parameter to the packet.

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

◆ InterpretDataBytes()

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

◆ InterpretOneWireBit()

virtual bool InterpretOneWireBit ( byte  bitResponse)
virtual

Interpret the bit response byte from a U adapter

Parameters
bitResponsebit response byte from U
Returns
boolean representing the result of a 1-Wire bit operation

◆ InterpretOneWireReset()

virtual OWResetResult InterpretOneWireReset ( byte  resetResponse)
virtual

Interpret the reset response byte from a U adapter

Parameters
resetResponsereset response byte from U
Returns
the number representing the result of a 1-Wire reset

◆ InterpretPrimedByte()

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

Interpret the data response byte from a primed byte operation

primedDataResponse

responseOffset

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

◆ InterpretSearch()

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

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

Parameters
bitResponsebit response byte from U

mState

searchResponse

responseOffset

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

◆ NewPacket()

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.

◆ OneWireReset()

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

◆ PrimedDataByte()

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
dataByteValuedata byte to append
Returns
the number offset in the return packet to get the result of this operation

◆ Restart()

virtual void Restart ( )
virtual

Reset the packet builder to start a new one.

◆ Search()

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
mStateOneWire state
Returns
the number offset in the return packet to get the result of this operation

◆ SendCommand()

virtual int SendCommand ( byte  command,
bool  expectResponse 
)
virtual

Append a send command to the packet.

This command does not elicit a response byte.

Parameters
commandcommand to send

expectResponse

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

◆ SetParameter() [1/6]

virtual int SetParameter ( SlewRate  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetParameter() [2/6]

virtual int SetParameter ( ProgramPulseTime12  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetParameter() [3/6]

virtual int SetParameter ( ProgramPulseTime5  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetParameter() [4/6]

virtual int SetParameter ( WriteOneLowTime  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetParameter() [5/6]

virtual int SetParameter ( SampleOffsetTime  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetParameter() [6/6]

virtual int SetParameter ( AdapterBaud  parameterValue)
virtual

Append a set parameter to the packet.

Parameters
parameterValueparameter value
Returns
the number offset in the return packet to get the result of this operation

◆ SetSpeed()

virtual void SetSpeed ( )
virtual

Append a Search off to set the current speed.

◆ SetToCommandMode()

virtual void SetToCommandMode ( )
virtual

Set the U state to command mode.

◆ SetToDataMode()

virtual void SetToDataMode ( )
virtual

Set the U state to data mode.

Member Data Documentation

◆ BIT_ONE

const byte BIT_ONE = (byte)(0x10)

DS9097U bit polarity one for function FUNCTION_BIT

◆ BIT_ZERO

const byte BIT_ZERO = (byte)(0x00)

DS9097U bit polarity zero for function FUNCTION_BIT

◆ bitsOnly

internal bool bitsOnly
protected

Flag to send only 'bit' commands to the DS2480

◆ CONFIG_MASK

const byte CONFIG_MASK = (byte)(0x01)

DS9097U mask to read or write a configuration parameter

◆ doDebugMessages

bool doDebugMessages = false
static

Enable/disable debug messages

◆ FUNCTION_12VPULSE_NOW

const byte FUNCTION_12VPULSE_NOW = (byte)(0xFD)

DS9097U funciton command, 12V pulse imediate

◆ FUNCTION_5VPULSE_ARM

const byte FUNCTION_5VPULSE_ARM = (byte)(0xEF)

DS9097U funciton command, 5V pulse after next byte

◆ FUNCTION_5VPULSE_NOW

const byte FUNCTION_5VPULSE_NOW = (byte)(0xED)

DS9097U funciton command, 5V pulse imediate

◆ FUNCTION_BIT

const byte FUNCTION_BIT = (byte)(0x81)

DS9097U funciton command, single bit

◆ FUNCTION_RESET

const byte FUNCTION_RESET = (byte)(0xC1)

DS9097U funciton command, OneWire reset

◆ FUNCTION_SEARCHOFF

const byte FUNCTION_SEARCHOFF = (byte)(0xA1)

DS9097U funciton command, turn Search mode off

◆ FUNCTION_SEARCHON

const byte FUNCTION_SEARCHON = (byte)(0xB1)

DS9097U funciton command, turn Search mode on

◆ FUNCTION_STOP_PULSE

const byte FUNCTION_STOP_PULSE = (byte)(0xF1)

DS9097U funciton command to stop an ongoing pulse

◆ MAX_BYTES_STREAMED

const byte MAX_BYTES_STREAMED = (byte)(64)

Max bytes to stream at once

◆ OPERATION_BYTE

const int OPERATION_BYTE = 0

Byte operation

◆ OPERATION_SEARCH

const int OPERATION_SEARCH = 1

Byte operation

◆ packet

internal RawSendPacket packet
protected

Current raw send packet before it is added to the packetsVector

◆ packetsVector

internal System.Collections.ArrayList packetsVector
protected

Vector of raw send packets

◆ PRIME5V_FALSE

const byte PRIME5V_FALSE = (byte)(0x00)

DS9097U 5V prime off for function FUNCTION_BIT

◆ PRIME5V_TRUE

const byte PRIME5V_TRUE = (byte)(0x02)

DS9097U 5V prime on for function FUNCTION_BIT

◆ RESPONSE_BIT_MASK

const byte RESPONSE_BIT_MASK = (byte)(0x03)

DS9097U mask to read bit operation result

◆ RESPONSE_BIT_ONE

const byte RESPONSE_BIT_ONE = (byte)(0x03)

DS9097U read bit operation 1

◆ RESPONSE_BIT_ZERO

const byte RESPONSE_BIT_ZERO = (byte)(0x00)

DS9097U read bit operation 0

◆ RESPONSE_RESET_ALARM

const byte RESPONSE_RESET_ALARM = (byte)(0x02)

DS9097U OneWire reset result = alarm

◆ RESPONSE_RESET_MASK

const byte RESPONSE_RESET_MASK = (byte)(0x03)

DS9097U mask to read the OneWire reset response byte

◆ RESPONSE_RESET_NOPRESENCE

const byte RESPONSE_RESET_NOPRESENCE = (byte)(0x03)

DS9097U OneWire reset result = no presence

◆ RESPONSE_RESET_PRESENCE

const byte RESPONSE_RESET_PRESENCE = (byte)(0x01)

DS9097U OneWire reset result = presence

◆ RESPONSE_RESET_SHORT

const byte RESPONSE_RESET_SHORT = (byte)(0x00)

DS9097U OneWire reset result = shorted

◆ totalReturnLength

internal int totalReturnLength
protected

The current current count for the number of return bytes from the packet being created.

Property Documentation

◆ Packets

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: