DUDS
Distributed Update of Data from Something
duds::hardware::interface::ConversationPart Class Referenceabstract

Represents a section of a half-duplex conversation with a device. More...

#include <ConversationPart.hpp>

Inheritance diagram for duds::hardware::interface::ConversationPart:
Collaboration diagram for duds::hardware::interface::ConversationPart:

Public Types

typedef duds::general::BitFlags< struct ConversationPartFlags, std::uint16_t > Flags
 The type used to store flags that modify the operation of the classes derived from this class, or how the objects are used. More...
 

Public Member Functions

 ConversationPart (const ConversationPart &)=default
 Copies are OK. More...
 
virtual ~ConversationPart ()
 
bool bigEndian () const
 True if this part is flagged as having data in big-endian form. More...
 
ConversationPartbigEndian (bool big)
 Changes the flagged endianess of this part. More...
 
ConversationPartbreakBefore ()
 Flags the conversation part to have a break before this part is sent. More...
 
bool extract () const
 True if this part is flagged for extraction by ConversationExtractor. More...
 
ConversationPartextract (bool ex)
 Changes the extraction flag for this part. More...
 
Flags flags () const
 Returns the flags. More...
 
bool input () const
 True if this part is flagged for input use. More...
 
virtual std::size_t length () const =0
 Returns the length of the buffer following the start pointer. More...
 
bool littleEndian () const
 True if this part is flagged as having data in little-endian form. More...
 
ConversationPartlittleEndian (bool little)
 Changes the flagged endianess of this part. More...
 
bool output () const
 True if this part is flagged for output use. More...
 
virtual char * start () const =0
 Returns a pointer to the begining of the conversation part's buffer. More...
 
bool varyingLength () const
 True if this part is flagged as having a variable length. More...
 

Static Public Attributes

static constexpr Flags MpfBigendian = Flags::Bit(3)
 True/set to expect data to be big-endian. More...
 
static constexpr Flags MpfBreak = Flags::Bit(4)
 True/set to indicate that any kind of selection signal should be toggled, or a stop condition should occur, before communicating the part with this flag. More...
 
static constexpr Flags MpfExtract = Flags::Bit(1)
 True/set to extract message part contents with the ConversationExtractor. More...
 
static constexpr Flags MpfInput = Flags::Bit(0)
 True/set for input; false for output. More...
 
static constexpr Flags MpfVarlen = Flags::Bit(2)
 True/set for a varying length; valid only for input. More...
 

Protected Member Functions

 ConversationPart (Flags f)
 Construct with the given flags. More...
 
 ConversationPart (Flags f, std::int16_t v)
 Construct with the given flags and an initial value for val16. More...
 

Protected Attributes

std::int16_t val16
 A small integer for derived classes to use. More...
 

Private Attributes

Flags mpf
 A set of flags that alter the behavior of the message part. More...
 

Detailed Description

Represents a section of a half-duplex conversation with a device.

The conversation part is stored in contiguous memory. It may either be used for input or output.

Several flags are defined that modify how a conversation part works or is used. All flags are named for the set state and are clear (not set) by default.

  • MpfInput: The part is used to hold data received from the other end.
  • MpfExtract: The part's data will be extracted by ConversationExtractor rather than skipped. This is normally set for input from a ConversationVector object, but clear for input from a ConversationExternal object.
  • MpfVarlen: Indicates a variable length input. Intended for use by communication code that takes Conversation objects.
  • MpfBigendian: Functions that do not specify endianess, and the insertion and extraction operators of ConversationVector, will treat the data as little-endian by default. Setting this flag will cause them to treat the data as big-endian. This only affects data sent to and from the device on the other end of the Conversation; data moving between the Conversation and the program using it is done in host endianess.
Author
Jeff Jackowski

Definition at line 50 of file ConversationPart.hpp.

Member Typedef Documentation

◆ Flags

typedef duds::general::BitFlags<struct ConversationPartFlags, std::uint16_t> duds::hardware::interface::ConversationPart::Flags

The type used to store flags that modify the operation of the classes derived from this class, or how the objects are used.

Definition at line 57 of file ConversationPart.hpp.

Constructor & Destructor Documentation

◆ ConversationPart() [1/3]

duds::hardware::interface::ConversationPart::ConversationPart ( Flags  f)
inlineprotected

Construct with the given flags.

Definition at line 104 of file ConversationPart.hpp.

◆ ConversationPart() [2/3]

duds::hardware::interface::ConversationPart::ConversationPart ( Flags  f,
std::int16_t  v 
)
inlineprotected

Construct with the given flags and an initial value for val16.

Definition at line 108 of file ConversationPart.hpp.

◆ ConversationPart() [3/3]

duds::hardware::interface::ConversationPart::ConversationPart ( const ConversationPart )
default

Copies are OK.

◆ ~ConversationPart()

duds::hardware::interface::ConversationPart::~ConversationPart ( )
virtual

Definition at line 20 of file ConversationPart.cpp.

Member Function Documentation

◆ bigEndian() [1/2]

bool duds::hardware::interface::ConversationPart::bigEndian ( ) const
inline

True if this part is flagged as having data in big-endian form.

Definition at line 163 of file ConversationPart.hpp.

Referenced by duds::hardware::devices::instruments::AM2320::AM2320(), duds::hardware::devices::instruments::FXOS8700CQ::configure(), and duds::hardware::interface::operator<<().

◆ bigEndian() [2/2]

ConversationPart& duds::hardware::interface::ConversationPart::bigEndian ( bool  big)
inline

Changes the flagged endianess of this part.

Parameters
bigTrue to flag as big-endian, false for little-endian.
Returns
The ConversationPart object being modified; makes further modification easier.

Definition at line 172 of file ConversationPart.hpp.

◆ breakBefore()

ConversationPart& duds::hardware::interface::ConversationPart::breakBefore ( )
inline

Flags the conversation part to have a break before this part is sent.

Exactly what this means and if it is honored is implementation specific. For I2C, it should cause a stop condition, followed by a start condition, and then this part's data. For SPI, it should cause the device's chip select to change to the unselected state briefly.

Returns
The ConversationPart object being modified; makes further modification easier.

Definition at line 201 of file ConversationPart.hpp.

Referenced by duds::hardware::devices::instruments::AMG88xx::AMG88xx().

◆ extract() [1/2]

bool duds::hardware::interface::ConversationPart::extract ( ) const
inline

True if this part is flagged for extraction by ConversationExtractor.

Definition at line 141 of file ConversationPart.hpp.

◆ extract() [2/2]

ConversationPart& duds::hardware::interface::ConversationPart::extract ( bool  ex)
inline

Changes the extraction flag for this part.

Returns
The ConversationPart object being modified; makes further modification easier.

Definition at line 149 of file ConversationPart.hpp.

◆ flags()

Flags duds::hardware::interface::ConversationPart::flags ( ) const
inline

Returns the flags.

Values are:

  • MpfInput
  • MpfExtract
  • MpfVarlen
  • MpfBigendian
  • MpfBreak

Definition at line 123 of file ConversationPart.hpp.

Referenced by duds::hardware::interface::linux::DevI2c::converse(), and duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen().

◆ input()

bool duds::hardware::interface::ConversationPart::input ( ) const
inline

◆ length()

virtual std::size_t duds::hardware::interface::ConversationPart::length ( ) const
pure virtual

◆ littleEndian() [1/2]

bool duds::hardware::interface::ConversationPart::littleEndian ( ) const
inline

True if this part is flagged as having data in little-endian form.

Definition at line 179 of file ConversationPart.hpp.

◆ littleEndian() [2/2]

ConversationPart& duds::hardware::interface::ConversationPart::littleEndian ( bool  little)
inline

Changes the flagged endianess of this part.

Parameters
littleTrue to flag as little-endian, false for big-endian.
Returns
The ConversationPart object being modified; makes further modification easier.

Definition at line 188 of file ConversationPart.hpp.

◆ output()

bool duds::hardware::interface::ConversationPart::output ( ) const
inline

True if this part is flagged for output use.

Definition at line 135 of file ConversationPart.hpp.

◆ start()

virtual char* duds::hardware::interface::ConversationPart::start ( ) const
pure virtual

Returns a pointer to the begining of the conversation part's buffer.

The return type is not const because use for input will require a write operation. The implementation must not make changes to the part object, so the function is const.

Implemented in duds::hardware::interface::ConversationVector, and duds::hardware::interface::ConversationExternal.

Referenced by duds::hardware::interface::linux::DevI2c::converse(), duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen(), and duds::hardware::interface::ConversationExtractor::reset().

◆ varyingLength()

bool duds::hardware::interface::ConversationPart::varyingLength ( ) const
inline

True if this part is flagged as having a variable length.

It is only valid for input.

Definition at line 157 of file ConversationPart.hpp.

Referenced by duds::hardware::interface::linux::DevI2c::converse(), duds::hardware::interface::ConversationVector::setLength(), and duds::hardware::interface::ConversationVector::setStartOffset().

Member Data Documentation

◆ mpf

Flags duds::hardware::interface::ConversationPart::mpf
private

A set of flags that alter the behavior of the message part.

Todo:
Change this to cpf.

Definition at line 94 of file ConversationPart.hpp.

◆ MpfBigendian

constexpr ConversationPart::Flags duds::hardware::interface::ConversationPart::MpfBigendian = Flags::Bit(3)
static

True/set to expect data to be big-endian.

Definition at line 77 of file ConversationPart.hpp.

◆ MpfBreak

constexpr ConversationPart::Flags duds::hardware::interface::ConversationPart::MpfBreak = Flags::Bit(4)
static

True/set to indicate that any kind of selection signal should be toggled, or a stop condition should occur, before communicating the part with this flag.

The flag is only used by code that implements the communication. Implementations are not required to honor the flag. Some implementations may honor it, but be unable to guarantee that another communication from another thread or process will not occur before resuming the conversation. Implementations should specify these details in the documentation.

Definition at line 88 of file ConversationPart.hpp.

Referenced by duds::hardware::interface::linux::DevI2c::converse(), and duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen().

◆ MpfExtract

constexpr ConversationPart::Flags duds::hardware::interface::ConversationPart::MpfExtract = Flags::Bit(1)
static

True/set to extract message part contents with the ConversationExtractor.

This is honored for both input and output messages.

Definition at line 67 of file ConversationPart.hpp.

◆ MpfInput

constexpr ConversationPart::Flags duds::hardware::interface::ConversationPart::MpfInput = Flags::Bit(0)
static

True/set for input; false for output.

Todo:
Change to CpfInput.

Definition at line 62 of file ConversationPart.hpp.

◆ MpfVarlen

constexpr ConversationPart::Flags duds::hardware::interface::ConversationPart::MpfVarlen = Flags::Bit(2)
static

True/set for a varying length; valid only for input.

Intended for use by communication code that takes Conversation objects; they can use the flag to tell there is a need to properly set the input length.

Definition at line 73 of file ConversationPart.hpp.

◆ val16

std::int16_t duds::hardware::interface::ConversationPart::val16
protected

A small integer for derived classes to use.

Placed here because it won't increase the size of this class thanks to memory alignment.

Definition at line 100 of file ConversationPart.hpp.

Referenced by duds::hardware::interface::ConversationVector::length(), duds::hardware::interface::ConversationVector::reserve(), duds::hardware::interface::ConversationVector::setStartOffset(), and duds::hardware::interface::ConversationVector::start().


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