DUDS
Distributed Update of Data from Something
duds::hardware::interface::MasterSyncSerialAccess Class Reference

Provides access for communicating using a MasterSyncSerial object. More...

#include <MasterSyncSerialAccess.hpp>

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

Public Types

typedef std::initializer_list< std::uint8_t > ByteList
 

Public Member Functions

 MasterSyncSerialAccess ()
 Makes a useless access object. More...
 
 ~MasterSyncSerialAccess ()
 Ends the conversation and closes communication. More...
 
void converse (Conversation &conv)
 Has a half-duplex Conversation with the connected device. More...
 
void receive (std::uint8_t *buff, duds::general::Bits bits)
 Receives bits of data. More...
 
void receive (std::int8_t *buff, duds::general::Bits bits)
 Receives bits of data using signed bytes for convenience. More...
 
void retire ()
 Ends the conversation and closes communication. More...
 
void start ()
 Starts a conversation; transitions from the open state to the communicating state. More...
 
void stop ()
 Ends the conversation; transitions from the communicating state to the open state. More...
 
void transfer (const std::uint8_t *__restrict__ out, std::uint8_t *__restrict__ in, duds::general::Bits bits)
 Sends and/or receives bits of data. More...
 
void transfer (const std::int8_t *__restrict__ out, std::int8_t *__restrict__ in, duds::general::Bits bits)
 Sends and/or receives bits of data using signed bytes for convenience. More...
 
void transfer (const ByteList &out, std::uint8_t *__restrict__ in, duds::general::Bits bits)
 Sends and/or receives bits of data. More...
 
void transmit (const std::uint8_t *buff, duds::general::Bits bits)
 Sends bits of data. More...
 
void transmit (const std::int8_t *buff, duds::general::Bits bits)
 Sends bits of data using signed bytes for convenience. More...
 
void transmit (const ByteList &buff)
 Sends bytes stored in a temporary value. More...
 

Private Member Functions

 MasterSyncSerialAccess (std::shared_ptr< MasterSyncSerial > m)
 Constructs an access object; called by MasterSyncSerial::access(). More...
 

Private Attributes

std::shared_ptr< MasterSyncSerialmss
 The serial interface used by this access object. More...
 

Friends

std::unique_ptr< MasterSyncSerialAccessMasterSyncSerial::access ()
 MasterSyncSerial::access() calls the constructor. More...
 
void MasterSyncSerial::access (MasterSyncSerialAccess &)
 MasterSyncSerial::access(MasterSyncSerialAccess &) changes mss. More...
 
void MasterSyncSerial::retire (MasterSyncSerialAccess *)
 

Detailed Description

Provides access for communicating using a MasterSyncSerial object.

Not derived from Conversationalist to avoid a virtual function table. Not sure if that is a good or bad decision. The objects are expected to be made on the stack just before use and then destroyed, giving them a short lifespan, so this may reduce overhead a little. The use of Conversationalist seems to be more sensible on MasterSyncSerial, which is a Conversationalist. A converse() function with the same prototype and usage as defined in Conversationalist is part of this class.

Author
Jeff Jackowski

Definition at line 28 of file MasterSyncSerialAccess.hpp.

Member Typedef Documentation

◆ ByteList

typedef std::initializer_list<std::uint8_t> duds::hardware::interface::MasterSyncSerialAccess::ByteList

Definition at line 47 of file MasterSyncSerialAccess.hpp.

Constructor & Destructor Documentation

◆ MasterSyncSerialAccess() [1/2]

duds::hardware::interface::MasterSyncSerialAccess::MasterSyncSerialAccess ( std::shared_ptr< MasterSyncSerial m)
inlineprivate

Constructs an access object; called by MasterSyncSerial::access().

Definition at line 45 of file MasterSyncSerialAccess.hpp.

◆ MasterSyncSerialAccess() [2/2]

duds::hardware::interface::MasterSyncSerialAccess::MasterSyncSerialAccess ( )
inline

Makes a useless access object.

Definition at line 52 of file MasterSyncSerialAccess.hpp.

◆ ~MasterSyncSerialAccess()

duds::hardware::interface::MasterSyncSerialAccess::~MasterSyncSerialAccess ( )
inline

Ends the conversation and closes communication.

Definition at line 56 of file MasterSyncSerialAccess.hpp.

Member Function Documentation

◆ converse()

void duds::hardware::interface::MasterSyncSerialAccess::converse ( Conversation conv)
inline

Has a half-duplex Conversation with the connected device.

The Conversation object defines all input and output parameters. On the ConversationPart objects, the MpfBreak flag is honored, but the MpfVarlen flag is ignored. The transmit() and receive() functions are called to move the data.

Precondition
The object is in the open state or the communicating state.
Postcondition
The object is in the open state, but not the communicating state.
Parameters
convThe conversation to have with the device on the other end.
Exceptions
SyncSerialIoErrorAn error prevented the communication.

Definition at line 266 of file MasterSyncSerialAccess.hpp.

◆ receive() [1/2]

void duds::hardware::interface::MasterSyncSerialAccess::receive ( std::uint8_t *  buff,
duds::general::Bits  bits 
)
inline

Receives bits of data.

If full duplex communication is used, transmitted data is undefined unless an implementation cares to have a definition.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
buffThe buffer that will receive the data.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 231 of file MasterSyncSerialAccess.hpp.

Referenced by receive().

◆ receive() [2/2]

void duds::hardware::interface::MasterSyncSerialAccess::receive ( std::int8_t *  buff,
duds::general::Bits  bits 
)
inline

Receives bits of data using signed bytes for convenience.

If full duplex communication is used, transmitted data is undefined unless an implementation cares to have a definition.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
buffThe buffer that will receive the data.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 251 of file MasterSyncSerialAccess.hpp.

◆ retire()

void duds::hardware::interface::MasterSyncSerialAccess::retire ( )
inline

Ends the conversation and closes communication.

Definition at line 62 of file MasterSyncSerialAccess.hpp.

Referenced by ~MasterSyncSerialAccess().

◆ start()

void duds::hardware::interface::MasterSyncSerialAccess::start ( )
inline

Starts a conversation; transitions from the open state to the communicating state.

Definition at line 71 of file MasterSyncSerialAccess.hpp.

◆ stop()

void duds::hardware::interface::MasterSyncSerialAccess::stop ( )
inline

Ends the conversation; transitions from the communicating state to the open state.

Definition at line 78 of file MasterSyncSerialAccess.hpp.

◆ transfer() [1/3]

void duds::hardware::interface::MasterSyncSerialAccess::transfer ( const std::uint8_t *__restrict__  out,
std::uint8_t *__restrict__  in,
duds::general::Bits  bits 
)
inline

Sends and/or receives bits of data.

If full duplex communication is not supported, one of the buffers should be given a NULL pointer. The buffers must not overlap.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
outThe data to transmit, or NULL to not transmit.
inThe buffer that will receive data, or NULL if nothing will be received.
bitsThe number of bits to transfer. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotFullDuplexBoth out and in are non-NULL, but the serial interface is half-duplex.
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 101 of file MasterSyncSerialAccess.hpp.

Referenced by transfer().

◆ transfer() [2/3]

void duds::hardware::interface::MasterSyncSerialAccess::transfer ( const std::int8_t *__restrict__  out,
std::int8_t *__restrict__  in,
duds::general::Bits  bits 
)
inline

Sends and/or receives bits of data using signed bytes for convenience.

If full duplex communication is not supported, one of the buffers should be given a NULL pointer. The buffers must not overlap.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
outThe data to transmit, or NULL to not transmit.
inThe buffer that will receive data, or NULL if nothing will be received.
bitsThe number of bits to transfer. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotFullDuplexBoth out and in are non-NULL, but the serial interface is half-duplex.
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 129 of file MasterSyncSerialAccess.hpp.

◆ transfer() [3/3]

void duds::hardware::interface::MasterSyncSerialAccess::transfer ( const ByteList out,
std::uint8_t *__restrict__  in,
duds::general::Bits  bits 
)
inline

Sends and/or receives bits of data.

If full duplex communication is not supported, one of the buffers should be given a NULL pointer. The buffers must not overlap.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
outThe data to transmit in an initializer list.
inThe buffer that will receive data, or NULL if nothing will be received.
bitsThe number of bits to transfer. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotFullDuplexBoth out and in are non-NULL, but the serial interface is half-duplex.
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 156 of file MasterSyncSerialAccess.hpp.

◆ transmit() [1/3]

void duds::hardware::interface::MasterSyncSerialAccess::transmit ( const std::uint8_t *  buff,
duds::general::Bits  bits 
)
inline

Sends bits of data.

If full duplex communication is used, received data is lost.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
buffThe data to transmit.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 178 of file MasterSyncSerialAccess.hpp.

Referenced by transmit().

◆ transmit() [2/3]

void duds::hardware::interface::MasterSyncSerialAccess::transmit ( const std::int8_t *  buff,
duds::general::Bits  bits 
)
inline

Sends bits of data using signed bytes for convenience.

If full duplex communication is used, received data is lost.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
buffThe data to transmit.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 196 of file MasterSyncSerialAccess.hpp.

◆ transmit() [3/3]

void duds::hardware::interface::MasterSyncSerialAccess::transmit ( const ByteList buff)
inline

Sends bytes stored in a temporary value.

If full duplex communication is used, received data is lost.

Precondition
The object is in the communicating state from a prior call to start().
Parameters
buffThe data to transmit as a list of bytes.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 212 of file MasterSyncSerialAccess.hpp.

Friends And Related Function Documentation

◆ MasterSyncSerial::access [1/2]

std::unique_ptr<MasterSyncSerialAccess> MasterSyncSerial::access ( )
friend

MasterSyncSerial::access() calls the constructor.

◆ MasterSyncSerial::access [2/2]

◆ MasterSyncSerial::retire

Member Data Documentation

◆ mss

std::shared_ptr<MasterSyncSerial> duds::hardware::interface::MasterSyncSerialAccess::mss
private

The serial interface used by this access object.

Definition at line 41 of file MasterSyncSerialAccess.hpp.

Referenced by duds::hardware::interface::MasterSyncSerial::access(), and duds::hardware::interface::MasterSyncSerial::retire().


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