μHAL (v2.7.9)
Part of the IPbus software repository
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
uhal::Mmap Class Reference

Transport protocol to transfer an IPbus buffer via device file, using mmap. More...

#include <uhal/ProtocolMmap.hpp>

Inheritance diagram for uhal::Mmap:
[legend]
Collaboration diagram for uhal::Mmap:
[legend]

Classes

class  File
 
struct  HexTo
 
class  PacketFmt
 

Public Member Functions

 Mmap (const std::string &aId, const URI &aUri)
 Constructor. More...
 
virtual ~Mmap ()
 Destructor. More...
 

Private Types

typedef IPbus< 2, 0 > InnerProtocol
 
typedef boost::chrono::steady_clock SteadyClock_t
 

Private Member Functions

 Mmap (const Mmap &aMmap)
 
Mmapoperator= (const Mmap &aMmap)
 
void implementDispatch (boost::shared_ptr< Buffers > aBuffers)
 Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate function. More...
 
virtual void Flush ()
 Concrete implementation of the synchronization function to block until all buffers have been sent, all replies received and all data validated. More...
 
virtual void dispatchExceptionHandler ()
 Function which tidies up this protocol layer in the event of an exception. More...
 
uint32_t getMaxSendSize ()
 Return the maximum size to be sent based on the buffer size in the target. More...
 
uint32_t getMaxReplySize ()
 Return the maximum size of reply packet based on the buffer size in the target. More...
 
void connect ()
 Set up the connection to the device. More...
 
void disconnect ()
 Close the connection to the device. More...
 
void write (const boost::shared_ptr< Buffers > &aBuffers)
 Write request packet to next page in host-to-FPGA device file. More...
 
void read ()
 Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate contents. More...
 

Private Attributes

bool mConnected
 
File mDeviceFile
 
boost::chrono::microseconds mSleepDuration
 
uint32_t mNumberOfPages
 
uint32_t mPageSize
 
uint32_t mIndexNextPage
 
uint32_t mPublishedReplyPageCount
 
uint32_t mReadReplyPageCount
 
std::deque< boost::shared_ptr< Buffers > > mReplyQueue
 The list of buffers still awaiting a reply. More...
 
uhal::exception::exceptionmAsynchronousException
 A pointer to an exception object for passing exceptions from the worker thread to the main thread. More...
 

Detailed Description

Transport protocol to transfer an IPbus buffer via device file, using mmap.

Definition at line 83 of file ProtocolMmap.hpp.

Member Typedef Documentation

◆ InnerProtocol

typedef IPbus< 2 , 0 > uhal::Mmap::InnerProtocol
private

Definition at line 165 of file ProtocolMmap.hpp.

◆ SteadyClock_t

typedef boost::chrono::steady_clock uhal::Mmap::SteadyClock_t
private

Definition at line 167 of file ProtocolMmap.hpp.

Constructor & Destructor Documentation

◆ Mmap() [1/2]

uhal::Mmap::Mmap ( const Mmap aMmap)
private

◆ Mmap() [2/2]

uhal::Mmap::Mmap ( const std::string &  aId,
const URI aUri 
)

Constructor.

Parameters
aIdthe uinique identifier that the client will be given.
aUria struct containing the full URI of the target.

Definition at line 256 of file ProtocolMmap.cpp.

References uhal::Integer(), uhal::log(), uhal::URI::mArguments, mDeviceFile, mSleepDuration, uhal::Notice, uhal::Quote(), uhal::Mmap::File::setOffset(), uhal::tests::uri, and uhal::Warning.

◆ ~Mmap()

uhal::Mmap::~Mmap ( )
virtual

Destructor.

Definition at line 294 of file ProtocolMmap.cpp.

References disconnect().

Member Function Documentation

◆ connect()

void uhal::Mmap::connect ( )
private

◆ disconnect()

void uhal::Mmap::disconnect ( )
private

Close the connection to the device.

Definition at line 382 of file ProtocolMmap.cpp.

References uhal::Mmap::File::close(), mConnected, and mDeviceFile.

Referenced by dispatchExceptionHandler(), and ~Mmap().

◆ dispatchExceptionHandler()

void uhal::Mmap::dispatchExceptionHandler ( )
privatevirtual

Function which tidies up this protocol layer in the event of an exception.

Definition at line 322 of file ProtocolMmap.cpp.

References disconnect(), uhal::log(), mReplyQueue, uhal::Notice, uhal::Quote(), uhal::ClientInterface::returnBufferToPool(), and uhal::tests::uri.

◆ Flush()

void uhal::Mmap::Flush ( )
privatevirtual

Concrete implementation of the synchronization function to block until all buffers have been sent, all replies received and all data validated.

Definition at line 313 of file ProtocolMmap.cpp.

References uhal::Debug, uhal::log(), mReplyQueue, uhal::Quote(), read(), and uhal::tests::uri.

◆ getMaxReplySize()

uint32_t uhal::Mmap::getMaxReplySize ( )
private

Return the maximum size of reply packet based on the buffer size in the target.

Returns
the maximum size of reply packet

Definition at line 343 of file ProtocolMmap.cpp.

References connect(), mConnected, and mPageSize.

◆ getMaxSendSize()

uint32_t uhal::Mmap::getMaxSendSize ( )
private

Return the maximum size to be sent based on the buffer size in the target.

Returns
the maximum size to be sent

Definition at line 334 of file ProtocolMmap.cpp.

References connect(), mConnected, and mPageSize.

◆ implementDispatch()

void uhal::Mmap::implementDispatch ( boost::shared_ptr< Buffers aBuffers)
private

Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate function.

Parameters
aBuffersthe buffer object wrapping the send and recieve buffers that are to be transported If multithreaded, adds buffer to the dispatch queue and returns. If single-threaded, calls the dispatch-worker dispatch function directly and blocks until the response is validated.

Definition at line 300 of file ProtocolMmap.cpp.

References connect(), uhal::Debug, uhal::log(), mConnected, mNumberOfPages, mReplyQueue, uhal::Quote(), read(), uhal::tests::uri, and write().

◆ operator=()

Mmap& uhal::Mmap::operator= ( const Mmap aMmap)
private

◆ read()

void uhal::Mmap::read ( )
private

◆ write()

void uhal::Mmap::write ( const boost::shared_ptr< Buffers > &  aBuffers)
private

Write request packet to next page in host-to-FPGA device file.

Definition at line 389 of file ProtocolMmap.cpp.

References uhal::Debug, uhal::Mmap::File::getPath(), uhal::Info, uhal::Integer(), uhal::log(), mDeviceFile, mIndexNextPage, mNumberOfPages, mPageSize, mReplyQueue, uhal::Quote(), uhal::tests::uri, and uhal::Mmap::File::write().

Referenced by implementDispatch().

Member Data Documentation

◆ mAsynchronousException

uhal::exception::exception* uhal::Mmap::mAsynchronousException
private

A pointer to an exception object for passing exceptions from the worker thread to the main thread.

Exceptions must always be created on the heap (i.e. using new) and deletion will be handled in the main thread

Definition at line 208 of file ProtocolMmap.hpp.

Referenced by read().

◆ mConnected

bool uhal::Mmap::mConnected
private

◆ mDeviceFile

File uhal::Mmap::mDeviceFile
private

Definition at line 195 of file ProtocolMmap.hpp.

Referenced by connect(), disconnect(), Mmap(), read(), and write().

◆ mIndexNextPage

uint32_t uhal::Mmap::mIndexNextPage
private

Definition at line 199 of file ProtocolMmap.hpp.

Referenced by connect(), read(), and write().

◆ mNumberOfPages

uint32_t uhal::Mmap::mNumberOfPages
private

Definition at line 199 of file ProtocolMmap.hpp.

Referenced by connect(), implementDispatch(), read(), and write().

◆ mPageSize

uint32_t uhal::Mmap::mPageSize
private

Definition at line 199 of file ProtocolMmap.hpp.

Referenced by connect(), getMaxReplySize(), getMaxSendSize(), read(), and write().

◆ mPublishedReplyPageCount

uint32_t uhal::Mmap::mPublishedReplyPageCount
private

Definition at line 199 of file ProtocolMmap.hpp.

Referenced by connect(), and read().

◆ mReadReplyPageCount

uint32_t uhal::Mmap::mReadReplyPageCount
private

Definition at line 199 of file ProtocolMmap.hpp.

Referenced by connect(), and read().

◆ mReplyQueue

std::deque< boost::shared_ptr< Buffers > > uhal::Mmap::mReplyQueue
private

The list of buffers still awaiting a reply.

Definition at line 202 of file ProtocolMmap.hpp.

Referenced by dispatchExceptionHandler(), Flush(), implementDispatch(), read(), and write().

◆ mSleepDuration

boost::chrono::microseconds uhal::Mmap::mSleepDuration
private

Definition at line 197 of file ProtocolMmap.hpp.

Referenced by Mmap(), and read().


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