mirror of
https://github.com/wfjm/w11.git
synced 2026-03-10 21:03:26 +00:00
add librtools/Rfd
- ReventFd, RtimerFd: derive from Rfd - RlinkServer,Rw11CntlDEUNA: adapt to new ReventFd API
This commit is contained in:
@@ -26,6 +26,10 @@ The full set of tests is only run for tagged releases.
|
||||
### Summary
|
||||
- use vivado 2019.1 as default
|
||||
|
||||
### New features
|
||||
- new tools
|
||||
- ibrtools/Rfd: added, encapsulates a file descriptor
|
||||
|
||||
### Changes
|
||||
- tools changes
|
||||
- add -reset option to stats subcommand
|
||||
@@ -33,6 +37,7 @@ The full set of tests is only run for tagged releases.
|
||||
- librtcltools/RtclStats: Rename Collect->Exec, not longer const; add -reset
|
||||
- libr*/*: Stats() not longer const; use RtclStats::Exec()
|
||||
- librtools/RparseUrl: add DirName,FileName,FileStem,FileType
|
||||
- derive ReventFd and RtimerFd from Rfd
|
||||
- firmware changes
|
||||
- sys_w11a_arty: down-rate to 72 MHz, viv 2019.1 fails with 75 MHz
|
||||
- sys_w11a_*.vmfset: add new rule for vivado 2019.1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RlinkServer.cpp 1127 2019-04-07 10:59:07Z mueller $
|
||||
// $Id: RlinkServer.cpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 2.2.11 adapt to new ReventFd API
|
||||
// 2019-04-07 1127 2.2.10 trace now with timestamp and selective
|
||||
// 2019-02-23 1114 2.2.9 use std::bind instead of lambda
|
||||
// 2018-12-17 1088 2.2.8 use std::lock_guard, std::thread instead of boost
|
||||
@@ -70,7 +71,7 @@ RlinkServer::RlinkServer()
|
||||
fContext(),
|
||||
fAttnDsc(),
|
||||
fActnList(),
|
||||
fWakeupEvent(),
|
||||
fWakeupEvent("RlinkServer::fWakeupEvent."),
|
||||
fELoop(this),
|
||||
fServerThread(),
|
||||
fAttnPatt(0),
|
||||
@@ -83,7 +84,7 @@ RlinkServer::RlinkServer()
|
||||
RlinkCommand::kStat_M_RbErr);
|
||||
|
||||
fELoop.AddPollHandler(bind(&RlinkServer::WakeupHandler, this, _1),
|
||||
fWakeupEvent, POLLIN);
|
||||
fWakeupEvent.Fd(), POLLIN);
|
||||
|
||||
// Statistic setup
|
||||
fStats.Define(kStatNEloopWait,"NEloopWait","event loop turns (wait)");
|
||||
@@ -296,11 +297,7 @@ void RlinkServer::Resume()
|
||||
|
||||
void RlinkServer::Wakeup()
|
||||
{
|
||||
uint64_t one(1);
|
||||
int irc = ::write(fWakeupEvent, &one, sizeof(one));
|
||||
if (irc < 0)
|
||||
throw Rexception("RlinkServer::Wakeup()",
|
||||
"write() to eventfd failed: ", errno);
|
||||
fWakeupEvent.Signal();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -560,11 +557,7 @@ int RlinkServer::WakeupHandler(const pollfd& pfd)
|
||||
// bail-out and cancel handler if poll returns an error event
|
||||
if (pfd.revents & (~pfd.events)) return -1;
|
||||
|
||||
uint64_t buf;
|
||||
int irc = ::read(fWakeupEvent, &buf, sizeof(buf));
|
||||
if (irc < 0)
|
||||
throw Rexception("RlinkServer::WakeupHandler()",
|
||||
"read() from eventfd failed: ", errno);
|
||||
fWakeupEvent.Wait(); // read event
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# $Id: Makefile 1125 2019-03-30 07:34:54Z mueller $
|
||||
# $Id: Makefile 1161 2019-06-08 11:52:01Z mueller $
|
||||
#
|
||||
# Revision History:
|
||||
# Date Rev Version Comment
|
||||
# 2019-06-07 1161 1.1.5 add Rfd
|
||||
# 2019-03-30 1125 1.1.4 add ReventFd,RtimerFd
|
||||
# 2019-01-02 1100 1.1.3 drop boost includes and libs
|
||||
# 2014-11-01 600 1.1.2 add -lboost_system (needed in boost 1.54)
|
||||
@@ -27,6 +28,7 @@ OBJ_all = Rbits.o
|
||||
OBJ_all += RerrMsg.o
|
||||
OBJ_all += ReventFd.o
|
||||
OBJ_all += Rexception.o
|
||||
OBJ_all += Rfd.o
|
||||
OBJ_all += RiosState.o
|
||||
OBJ_all += RlogFile.o RlogFileCatalog.o RlogMsg.o
|
||||
OBJ_all += RosFill.o
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: ReventFd.cpp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: ReventFd.cpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 1.1 derive from Rfd, inherit Fd
|
||||
// 2018-12-18 1089 1.0.1 use c++ style casts
|
||||
// 2013-01-14 475 1.0 Initial version
|
||||
// 2013-01-11 473 0.5 First draft
|
||||
@@ -44,38 +45,44 @@ namespace Retro {
|
||||
//! FIXME_docs
|
||||
|
||||
ReventFd::ReventFd()
|
||||
: ReventFd("ReventFd::")
|
||||
{}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
ReventFd::ReventFd(const char* cnam)
|
||||
: Rfd(cnam)
|
||||
{
|
||||
fFd = ::eventfd(0,0); // ini value = 0; no flags
|
||||
if (fFd < 0)
|
||||
throw Rexception("ReventFd::ctor", "eventfd() failed: ", errno);
|
||||
throw Rexception(fCnam+"ctor", "eventfd() failed: ", errno);
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
ReventFd::~ReventFd()
|
||||
void ReventFd::Signal(uint64_t val)
|
||||
{
|
||||
::close(fFd);
|
||||
int irc = ::write(fFd, &val, sizeof(val));
|
||||
if (irc < 0) {
|
||||
throw Rexception(fCnam+"Signal()", "write() failed: ", errno);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
int ReventFd::SignalFd(int fd)
|
||||
{
|
||||
uint64_t one(1);
|
||||
int irc = ::write(fd, &one, sizeof(one));
|
||||
return irc;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
int ReventFd::WaitFd(int fd)
|
||||
uint64_t ReventFd::Wait()
|
||||
{
|
||||
uint64_t buf;
|
||||
int irc = ::read(fd, &buf, sizeof(buf));
|
||||
return (irc <= 0) ? irc : int(buf);
|
||||
int irc = ::read(fFd, &buf, sizeof(buf));
|
||||
if (irc < 0) {
|
||||
if (errno == EAGAIN) return 0;
|
||||
throw Rexception(fCnam+"Wait()", "read() failed: ", errno);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: ReventFd.hpp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: ReventFd.hpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 1.1 derive from Rfd, inherit Fd
|
||||
// 2018-12-16 1084 1.0.1 use =delete for noncopyable instead of boost
|
||||
// 2013-01-14 475 1.0 Initial version
|
||||
// 2013-01-11 473 0.5 First draft
|
||||
@@ -26,32 +27,24 @@
|
||||
#ifndef included_Retro_ReventFd
|
||||
#define included_Retro_ReventFd 1
|
||||
|
||||
#include "Rfd.hpp"
|
||||
|
||||
namespace Retro {
|
||||
|
||||
class ReventFd {
|
||||
class ReventFd : public Rfd {
|
||||
public:
|
||||
ReventFd();
|
||||
virtual ~ReventFd();
|
||||
explicit ReventFd(const char* cnam);
|
||||
|
||||
ReventFd(const ReventFd&) = delete; // noncopyable
|
||||
ReventFd& operator=(const ReventFd&) = delete; // noncopyable
|
||||
|
||||
int Fd() const;
|
||||
int Signal();
|
||||
int Wait();
|
||||
|
||||
operator int() const;
|
||||
|
||||
static int SignalFd(int fd);
|
||||
static int WaitFd(int fd);
|
||||
|
||||
protected:
|
||||
|
||||
int fFd;
|
||||
void Signal(uint64_t val=1);
|
||||
uint64_t Wait();
|
||||
};
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
#include "ReventFd.ipp"
|
||||
//#include "ReventFd.ipp"
|
||||
|
||||
#endif
|
||||
|
||||
133
tools/src/librtools/Rfd.cpp
Normal file
133
tools/src/librtools/Rfd.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
// $Id: Rfd.cpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation, either version 3, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for complete details.
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-07 1161 1.0 Initial version
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
\brief Implemenation of class RtimerFd.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Rfd.hpp"
|
||||
|
||||
#include "Rexception.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*!
|
||||
\class Retro::Rfd
|
||||
\brief FIXME_docs
|
||||
*/
|
||||
|
||||
// all method definitions in namespace Retro
|
||||
namespace Retro {
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
Rfd::Rfd()
|
||||
: fFd(-1),
|
||||
fCnam("Rfd::")
|
||||
{}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
Rfd::Rfd(Rfd&& rhs)
|
||||
: fFd(rhs.fFd),
|
||||
fCnam(move(rhs.fCnam))
|
||||
{
|
||||
rhs.fFd = -1;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
Rfd::Rfd(const char* cnam)
|
||||
: fFd(-1),
|
||||
fCnam(cnam)
|
||||
{}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
Rfd::~Rfd()
|
||||
{
|
||||
if (IsOpen()) CloseOrCerr();
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
void Rfd::SetFd(int fd)
|
||||
{
|
||||
if (IsOpen())
|
||||
throw Rexception(fCnam+"Open()", "bad state: already open");
|
||||
fFd = fd;
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
void Rfd::Close()
|
||||
{
|
||||
if (IsOpenNonStd()) {
|
||||
::close(fFd);
|
||||
fFd = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
bool Rfd::Close(RerrMsg& emsg)
|
||||
{
|
||||
if (!IsOpen()) {
|
||||
emsg.Init(fCnam+"Close()", "bad state: not open");
|
||||
return false;
|
||||
}
|
||||
if (!IsOpenNonStd()) {
|
||||
fFd = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
int irc = ::close(fFd);
|
||||
fFd = -1;
|
||||
if (irc < 0) {
|
||||
emsg.InitErrno(fCnam+"Close()", "close() failed: ", errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
void Rfd::CloseOrCerr()
|
||||
{
|
||||
RerrMsg emsg;
|
||||
if (!Close(emsg)) cerr << emsg.Meth() << "-E: " << emsg.Text() << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
} // end namespace Retro
|
||||
64
tools/src/librtools/Rfd.hpp
Normal file
64
tools/src/librtools/Rfd.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// $Id: Rfd.hpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation, either version 3, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for complete details.
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-07 1161 1.0 Initial version
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
/*!
|
||||
\brief Declaration of class \c Rfd.
|
||||
*/
|
||||
|
||||
#ifndef included_Retro_Rfd
|
||||
#define included_Retro_Rfd 1
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "RerrMsg.hpp"
|
||||
|
||||
namespace Retro {
|
||||
|
||||
class Rfd {
|
||||
public:
|
||||
Rfd();
|
||||
Rfd(Rfd&& rhs); // move ctor
|
||||
explicit Rfd(const char* cnam);
|
||||
virtual ~Rfd();
|
||||
|
||||
Rfd(const Rfd&) = delete; // noncopyable
|
||||
Rfd& operator=(const Rfd&) = delete; // noncopyable
|
||||
|
||||
void SetFd(int fd);
|
||||
int Fd() const;
|
||||
|
||||
bool IsOpen() const;
|
||||
bool IsOpenNonStd() const;
|
||||
void Close();
|
||||
bool Close(RerrMsg& emsg);
|
||||
void CloseOrCerr();
|
||||
|
||||
explicit operator bool() const;
|
||||
|
||||
protected:
|
||||
|
||||
int fFd;
|
||||
std::string fCnam;
|
||||
};
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
#include "Rfd.ipp"
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: ReventFd.ipp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: Rfd.ipp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,12 +13,11 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2013-01-14 475 1.0 Initial version
|
||||
// 2013-01-11 473 0.5 First draft
|
||||
// 2019-06-07 1161 1.0 Initial version
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
\brief Implemenation (inline) of class ReventFd.
|
||||
\brief Implemenation (inline) of class Rfd.
|
||||
*/
|
||||
|
||||
// all method definitions in namespace Retro
|
||||
@@ -27,7 +26,7 @@ namespace Retro {
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline int ReventFd::Fd() const
|
||||
inline int Rfd::Fd() const
|
||||
{
|
||||
return fFd;
|
||||
}
|
||||
@@ -35,25 +34,27 @@ inline int ReventFd::Fd() const
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline int ReventFd::Signal()
|
||||
inline bool Rfd::IsOpen() const
|
||||
{
|
||||
return SignalFd(fFd);
|
||||
return fFd >= 0;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline int ReventFd::Wait()
|
||||
inline bool Rfd::IsOpenNonStd() const
|
||||
{
|
||||
return WaitFd(fFd);
|
||||
return fFd > 2;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline ReventFd::operator int() const
|
||||
inline Rfd::operator bool() const
|
||||
{
|
||||
return fFd;
|
||||
return IsOpen();
|
||||
}
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: RtimerFd.cpp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: RtimerFd.cpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 1.1 derive from Rfd, inherit IsOpen,Close,Fd
|
||||
// 2017-02-18 852 1.0 Initial version
|
||||
// 2013-01-11 473 0.1 First draft
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -43,16 +44,15 @@ namespace Retro {
|
||||
//! FIXME_docs
|
||||
|
||||
RtimerFd::RtimerFd()
|
||||
: fFd(-1)
|
||||
: RtimerFd("RtimerFd::")
|
||||
{}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
RtimerFd::~RtimerFd()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
RtimerFd::RtimerFd(const char* cnam)
|
||||
: Rfd(cnam)
|
||||
{}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
@@ -60,23 +60,11 @@ RtimerFd::~RtimerFd()
|
||||
void RtimerFd::Open(clockid_t clkid)
|
||||
{
|
||||
if (IsOpen())
|
||||
throw Rexception("RtimerFd::Open()", "bad state: already open");
|
||||
throw Rexception(fCnam+"Open()", "bad state: already open");
|
||||
|
||||
fFd = ::timerfd_create(clkid, TFD_NONBLOCK);
|
||||
if (!IsOpen())
|
||||
throw Rexception("RtimerFd::Open()", "timerfd_create() failed: ", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
void RtimerFd::Close()
|
||||
{
|
||||
if (IsOpen()) {
|
||||
::close(fFd);
|
||||
fFd = -1;
|
||||
}
|
||||
throw Rexception(fCnam+"Open()", "timerfd_create() failed: ", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -86,11 +74,10 @@ void RtimerFd::Close()
|
||||
void RtimerFd::SetRelative(const Rtime& dt)
|
||||
{
|
||||
if (!IsOpen())
|
||||
throw Rexception("RtimerFd::SetRelative()", "bad state: not open");
|
||||
throw Rexception(fCnam+"SetRelative()", "bad state: not open");
|
||||
|
||||
if (dt.Sec() <= 0 || dt.NSec() <= 0)
|
||||
throw Rexception("RtimerFd::SetRelative()",
|
||||
"bad value: dt zero or negative ");
|
||||
throw Rexception(fCnam+"SetRelative()", "bad value: dt zero or negative ");
|
||||
|
||||
struct itimerspec itspec;
|
||||
itspec.it_interval.tv_sec = 0;
|
||||
@@ -98,7 +85,7 @@ void RtimerFd::SetRelative(const Rtime& dt)
|
||||
itspec.it_value = dt.Timespec();
|
||||
|
||||
if (::timerfd_settime(fFd, 0, &itspec, nullptr) < 0)
|
||||
throw Rexception("RtimerFd::SetRelative()",
|
||||
throw Rexception(fCnam+"SetRelative()",
|
||||
"timerfd_settime() failed: ", errno);
|
||||
return;
|
||||
}
|
||||
@@ -109,7 +96,7 @@ void RtimerFd::SetRelative(const Rtime& dt)
|
||||
void RtimerFd::Cancel()
|
||||
{
|
||||
if (!IsOpen())
|
||||
throw Rexception("RtimerFd::Cancel()", "bad state: not open");
|
||||
throw Rexception(fCnam+"Cancel()", "bad state: not open");
|
||||
|
||||
struct itimerspec itspec;
|
||||
itspec.it_interval.tv_sec = 0;
|
||||
@@ -119,14 +106,13 @@ void RtimerFd::Cancel()
|
||||
|
||||
// cancel running timers
|
||||
if (::timerfd_settime(fFd, 0, &itspec, nullptr) < 0)
|
||||
throw Rexception("RtimerFd::Cancel()",
|
||||
"timerfd_settime() failed: ", errno);
|
||||
throw Rexception(fCnam+"Cancel()", "timerfd_settime() failed: ", errno);
|
||||
|
||||
// clear aready experied timers
|
||||
uint64_t cnt;
|
||||
int irc = ::read(fFd, &cnt, sizeof(cnt));
|
||||
if (irc < 0 && errno != EAGAIN)
|
||||
throw Rexception("RtimerFd::Cancel()", "read() failed: ", errno);
|
||||
throw Rexception(fCnam+"Cancel()", "read() failed: ", errno);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -137,13 +123,13 @@ void RtimerFd::Cancel()
|
||||
uint64_t RtimerFd::Read()
|
||||
{
|
||||
if (!IsOpen())
|
||||
throw Rexception("RtimerFd::Read()", "bad state: not open");
|
||||
throw Rexception(fCnam+"Read()", "bad state: not open");
|
||||
|
||||
uint64_t cnt;
|
||||
int irc = ::read(fFd, &cnt, sizeof(cnt));
|
||||
if (irc < 0) {
|
||||
if (errno == EAGAIN) return 0;
|
||||
throw Rexception("RtimerFd::Read()", "read() failed: ", errno);
|
||||
throw Rexception(fCnam+"Read()", "read() failed: ", errno);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: RtimerFd.hpp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: RtimerFd.hpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 1.1 derive from Rfd, inherit IsOpen,Close,Fd
|
||||
// 2018-12-16 1084 1.0.1 use =delete for noncopyable instead of boost
|
||||
// 2017-02-18 852 1.0 Initial version
|
||||
// 2013-01-11 473 0.1 First draft
|
||||
@@ -28,33 +29,26 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "Rfd.hpp"
|
||||
#include "Rtime.hpp"
|
||||
|
||||
|
||||
namespace Retro {
|
||||
|
||||
class RtimerFd {
|
||||
class RtimerFd : public Rfd {
|
||||
public:
|
||||
RtimerFd();
|
||||
virtual ~RtimerFd();
|
||||
explicit RtimerFd(const char* cnam);
|
||||
|
||||
RtimerFd(const RtimerFd&) = delete; // noncopyable
|
||||
RtimerFd& operator=(const RtimerFd&) = delete; // noncopyable
|
||||
|
||||
void Open(clockid_t clkid=CLOCK_MONOTONIC);
|
||||
bool IsOpen() const;
|
||||
void Close();
|
||||
void SetRelative(const Rtime& dt);
|
||||
void SetRelative(double dt);
|
||||
void Cancel();
|
||||
uint64_t Read();
|
||||
|
||||
int Fd() const;
|
||||
explicit operator bool() const;
|
||||
|
||||
protected:
|
||||
|
||||
int fFd;
|
||||
};
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: RtimerFd.ipp 1125 2019-03-30 07:34:54Z mueller $
|
||||
// $Id: RtimerFd.ipp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2013-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 1.1 derive from Rfd, inherit IsOpen,Close,Fd
|
||||
// 2017-02-18 851 1.0 Initial version
|
||||
// 2013-01-11 473 0.1 First draft
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -27,35 +28,11 @@ namespace Retro {
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline bool RtimerFd::IsOpen() const
|
||||
{
|
||||
return fFd >= 0;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline void RtimerFd::SetRelative(double dt)
|
||||
{
|
||||
return SetRelative(Rtime(dt));
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline int RtimerFd::Fd() const
|
||||
{
|
||||
return fFd;
|
||||
}
|
||||
|
||||
//------------------------------------------+-----------------------------------
|
||||
//! FIXME_docs
|
||||
|
||||
inline RtimerFd::operator bool() const
|
||||
{
|
||||
return IsOpen();
|
||||
}
|
||||
|
||||
} // end namespace Retro
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// $Id: Rw11CntlDEUNA.cpp 1133 2019-04-19 18:43:00Z mueller $
|
||||
// $Id: Rw11CntlDEUNA.cpp 1161 2019-06-08 11:52:01Z mueller $
|
||||
//
|
||||
// Copyright 2014-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2019-06-08 1161 0.5.10 adapt to new RtimerFd API
|
||||
// 2019-04-19 1133 0.5.9 use ExecWibr()
|
||||
// 2019-02-23 1114 0.5.8 use std::bind instead of lambda
|
||||
// 2018-12-19 1090 0.5.7 use RosPrintf(bool)
|
||||
@@ -251,7 +252,7 @@ Rw11CntlDEUNA::Rw11CntlDEUNA()
|
||||
fRxDscNxt{},
|
||||
fRxPollTime(0.01),
|
||||
fRxQueLimit(1000),
|
||||
fRxPollTimer(),
|
||||
fRxPollTimer("Rw11CntlDEUNA::fRxPollTimer."),
|
||||
fRxBufQueue(),
|
||||
fRxBufCurr(),
|
||||
fRxBufOffset(0)
|
||||
|
||||
Reference in New Issue
Block a user