42#ifndef _DUNEDAQ_UHALLIBS_PROTOCOLAXI4LITE_HPP_
43#define _DUNEDAQ_UHALLIBS_PROTOCOLAXI4LITE_HPP_
56#include "uhal/ClientInterface.hpp"
57#include "uhal/ProtocolIPbus.hpp"
58#include "uhal/log/exception.hpp"
74 Axi4LiteTimeout, uhal::exception::ClientTimeout,
75 "Exception class to handle the case in "
76 "which the Axi4Lite connection timed out."
81 Axi4LiteInitialisationError,
uhal::
exception::TransportLayerError,
82 "Exception class to handle a failure to read from the specified device "
83 "files during initialisation."
88 Axi4LiteCommunicationError,
uhal::
exception::TransportLayerError,
89 "Exception class to handle a low-level seek/read/write error after "
99 MappedFile(
const std::string& aPath,
size_t aLength,
int aProtFlags = PROT_WRITE);
102 const std::string&
getPath()
const;
104 void setPath(
const std::string& aPath);
116 void read(
const uint32_t aAddr,
const uint32_t aNrWords,
117 std::vector<uint32_t>& aValues);
119 void write(
const uint32_t aAddr,
const std::vector<uint32_t>& aValues);
121 void write(
const uint32_t aAddr,
const uint8_t*
const aPtr,
122 const size_t aNrBytes);
124 void write(
const uint32_t aAddr,
125 const std::vector<std::pair<const uint8_t*, size_t> >& aData);
150 Axi4Lite(
const std::string& aId,
const uhal::URI& aUri);
177 virtual void Flush( );
207 void write(
const std::shared_ptr<uhal::Buffers>& aBuffers);
void close()
Unmap and close file.
MappedFile(const std::string &aPath, size_t aLength, int aProtFlags=PROT_WRITE)
void open()
Open bus file and map it to memory.
void setPath(const std::string &aPath)
void write(const uint32_t aAddr, const std::vector< uint32_t > &aValues)
void createBuffer(const size_t aNrBytes)
Create a local buffer.
const std::string & getPath() const
void read(const uint32_t aAddr, const uint32_t aNrWords, std::vector< uint32_t > &aValues)
bool mIPCExternalSessionActive
std::chrono::microseconds mSleepDuration
static std::string getSharedMemName(const std::string &)
ipc::SharedMemObject< IPCMutex_t > mIPCMutex
uint32_t getMaxSendSize()
void connect()
Set up the connection to the device.
virtual void Flush()
Concrete implementation of the synchronization function to block until all buffers have been sent,...
ipc::RobustMutex IPCMutex_t
IPbus< 2, 0 > InnerProtocol
static std::string getDevicePath(const uhal::URI &aUri)
uint32_t mReadReplyPageCount
uint32_t getMaxReplySize()
std::deque< std::shared_ptr< uhal::Buffers > > mReplyQueue
The list of buffers still awaiting a reply.
void disconnect()
Close the connection to the device.
virtual void dispatchExceptionHandler()
Function which tidies up this protocol layer in the event of an exception.
Axi4Lite(const std::string &aId, const uhal::URI &aUri)
void write(const std::shared_ptr< uhal::Buffers > &aBuffers)
Write request packet to next page in host-to-FPGA device file.
Axi4Lite(const Axi4Lite &)=delete
std::chrono::steady_clock SteadyClock_t
uint32_t mPublishedReplyPageCount
void read()
Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate conten...
std::unique_lock< IPCMutex_t > IPCScopedLock_t
void implementDispatch(std::shared_ptr< uhal::Buffers > aBuffers)
uint64_t mIPCSessionCount
UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(Axi4LiteTimeout, uhal::exception::ClientTimeout, "Exception class to handle the case in " "which the Axi4Lite connection timed out.") UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(Axi4LiteInitialisationError