1
0
mirror of https://github.com/wfjm/w11.git synced 2026-05-03 22:59:46 +00:00

- added RH70/RP/RM big disk support

- many cleanups
This commit is contained in:
Walter F.J. Mueller
2015-05-14 17:00:36 +00:00
parent e91847f8db
commit 4a032e9436
247 changed files with 11301 additions and 3449 deletions

View File

@@ -1,6 +1,6 @@
// $Id: ReventLoop.cpp 511 2013-04-27 13:51:46Z mueller $
// $Id: ReventLoop.cpp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), add UnStop,StopPending
// 2013-04-27 511 1.1.3 BUGFIX: logic in DoCall() fixed (loop range)
// 2013-03-05 495 1.1.2 add exception catcher to EventLoop
// 2013-03-01 493 1.1.1 DoCall(): remove handler on negative return
@@ -22,7 +23,7 @@
/*!
\file
\version $Id: ReventLoop.cpp 511 2013-04-27 13:51:46Z mueller $
\version $Id: ReventLoop.cpp 662 2015-04-05 08:02:54Z mueller $
\brief Implemenation of class ReventLoop.
*/
@@ -54,7 +55,7 @@ namespace Retro {
//! FIXME_docs
ReventLoop::ReventLoop()
: fLoopActive(false),
: fStopPending(false),
fUpdatePoll(false),
fPollDscMutex(),
fPollDsc(),
@@ -161,11 +162,10 @@ void ReventLoop::RemovePollHandler(int fd)
void ReventLoop::EventLoop()
{
fLoopActive = true;
fUpdatePoll = true;
try {
while (fLoopActive) {
while (!StopPending()) {
int irc = DoPoll();
if (fPollFd.size() == 0) break;
if (irc>0) DoCall();
@@ -188,7 +188,7 @@ void ReventLoop::Dump(std::ostream& os, int ind, const char* text) const
{
RosFill bl(ind);
os << bl << (text?text:"--") << "ReventLoop @ " << this << endl;
os << bl << " fLoopActive: " << fLoopActive << endl;
os << bl << " fStopPending: " << fStopPending << endl;
os << bl << " fUpdatePoll: " << fUpdatePoll << endl;
{
boost::lock_guard<boost::mutex> lock(((ReventLoop*)this)->fPollDscMutex);

View File

@@ -1,6 +1,6 @@
// $Id: ReventLoop.hpp 513 2013-05-01 14:02:06Z mueller $
// $Id: ReventLoop.hpp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), add UnStop,StopPending
// 2013-05-01 513 1.1.1 fTraceLevel now uint32_t
// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
// 2013-01-11 473 1.0 Initial version
@@ -21,7 +22,7 @@
/*!
\file
\version $Id: ReventLoop.hpp 513 2013-05-01 14:02:06Z mueller $
\version $Id: ReventLoop.hpp 662 2015-04-05 08:02:54Z mueller $
\brief Declaration of class \c ReventLoop.
*/
@@ -60,6 +61,8 @@ namespace Retro {
uint32_t TraceLevel() const;
void Stop();
void UnStop();
bool StopPending();
virtual void EventLoop();
virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const;
@@ -79,7 +82,7 @@ namespace Retro {
fHandler(hdl),fFd(fd),fEvents(evts) {}
};
bool fLoopActive;
bool fStopPending;
bool fUpdatePoll;
boost::mutex fPollDscMutex;
std::vector<PollDsc> fPollDsc;

View File

@@ -1,6 +1,6 @@
// $Id: ReventLoop.ipp 513 2013-05-01 14:02:06Z mueller $
// $Id: ReventLoop.ipp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), add UnStop,StopPending
// 2013-05-01 513 1.1.1 fTraceLevel now uint32_t
// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
// 2013-01-11 473 1.0 Initial version
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: ReventLoop.ipp 513 2013-05-01 14:02:06Z mueller $
\version $Id: ReventLoop.ipp 662 2015-04-05 08:02:54Z mueller $
\brief Implemenation (inline) of class ReventLoop.
*/
@@ -32,13 +33,30 @@ namespace Retro {
inline void ReventLoop::Stop()
{
fLoopActive = false;
fStopPending = true;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void ReventLoop::UnStop()
{
fStopPending = false;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool ReventLoop::StopPending()
{
return fStopPending;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void ReventLoop::SetLogFile(const boost::shared_ptr<RlogFile>& splog)
{
fspLog = splog;

View File

@@ -1,4 +1,4 @@
// $Id: RlinkCommand.cpp 643 2015-02-07 17:41:53Z mueller $
// $Id: RlinkCommand.cpp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-02 661 1.3 expect logic: add stat check, Print() without cntx
// 2015-02-07 642 1.2.3 Print()+Dump(): adopt for large nblk;
// 2014-12-21 617 1.2.2 use kStat_M_RbTout for rbus timeout
// 2014-12-20 616 1.2.1 Print(): display BlockDone; add kFlagChkDone
@@ -26,7 +27,7 @@
/*!
\file
\version $Id: RlinkCommand.cpp 643 2015-02-07 17:41:53Z mueller $
\version $Id: RlinkCommand.cpp 662 2015-04-05 08:02:54Z mueller $
\brief Implemenation of class RlinkCommand.
*/
@@ -97,6 +98,9 @@ RlinkCommand::RlinkCommand()
fStatus(0),
fFlags(0),
fRcvSize(0),
fExpectStatusSet(false),
fExpectStatusVal(0),
fExpectStatusMsk(0x0),
fpExpect(nullptr)
{}
@@ -114,6 +118,9 @@ RlinkCommand::RlinkCommand(const RlinkCommand& rhs)
fStatus(rhs.fStatus),
fFlags(rhs.fFlags),
fRcvSize(rhs.fRcvSize),
fExpectStatusSet(rhs.fExpectStatusSet),
fExpectStatusVal(rhs.fExpectStatusVal),
fExpectStatusMsk(rhs.fExpectStatusMsk),
fpExpect(rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : nullptr)
{}
@@ -256,24 +263,24 @@ void RlinkCommand::SetExpect(RlinkCommandExpect* pexp)
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
void RlinkCommand::Print(std::ostream& os,
const RlinkAddrMap* pamap, size_t abase,
size_t dbase, size_t sbase) const
{
uint8_t ccode = Command();
// separator + command mnemonic, code and flags
// separator: ++ first in packet
// -- non-first in packet
// ?? FIXME_code: separator for labo canceled commands
const char* sep = "??";
if (TestFlagAny(kFlagPktBeg)) {
sep = "++";
} else {
sep = "--";
}
os << sep << " " << CommandName(ccode)
// separator: ++ first in packet
// -- non-first in packet
// -! +! labo with abort
// -. +. labo canceled command
char sep0 = TestFlagAny(kFlagPktBeg) ? '+' : '-';
char sep1 = sep0;
if (ccode==kCmdLabo && fData) sep1 = '!'; // indicate aborting labo
if (TestFlagAny(kFlagLabo)) sep1 = '.'; // indicate aborted command
os << sep0 << sep1 << " " << CommandName(ccode)
<< " (" << RosPrintBvi(Request(), 8)
<< "," << RosPrintBvi(fFlags, 16, 20)
<< ")";
@@ -290,6 +297,12 @@ void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
}
}
// don't write more that command and address for canceled commands
if (TestFlagAny(kFlagLabo)) {
os << " CANCELED" << endl;
return;
}
// data field (scalar)
if (ccode== kCmdRreg || ccode==kCmdWreg ||
ccode== kCmdLabo || ccode==kCmdAttn ||
@@ -301,7 +314,7 @@ void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
if (TestFlagAny(kFlagChkData)) {
os << "#";
os << " D=" << RosPrintBvi(fpExpect->DataValue(), dbase);
if (fpExpect->DataMask() != 0x0000) {
if (fpExpect->DataMask() != 0xffff) {
os << "," << RosPrintBvi(fpExpect->DataMask(), dbase);
}
} else if (fpExpect->DataIsChecked()) {
@@ -335,16 +348,14 @@ void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
// status field
os << " s=" << RosPrintBvi(fStatus, sbase);
uint8_t scval = fpExpect ? fpExpect->StatusValue() : cntx.StatusValue();
uint8_t scmsk = fpExpect ? fpExpect->StatusMask() : cntx.StatusMask();
if (TestFlagAny(kFlagChkStat)) {
os << "#";
os << " S=" << RosPrintBvi(scval, sbase);
if (scmsk != 0x00) {
os << "," << RosPrintBvi(scmsk, sbase);
os << " S=" << RosPrintBvi(fExpectStatusVal, sbase);
if (fExpectStatusMsk != 0xff) {
os << "," << RosPrintBvi(fExpectStatusMsk, sbase);
}
} else {
os << ( scmsk != 0xff ? "!" : " " );
os << (StatusIsChecked() ? (ExpectStatusSet() ? "|" : "!") : " " );
}
if (TestFlagAny(kFlagDone)) {
@@ -396,7 +407,7 @@ void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx,
os << "\n FAIL d[" << RosPrintf(i,"d",4) << "]: "
<< RosPrintBvi(pdat[i], dbase) << "#"
<< " D=" << RosPrintBvi(evalvec[i], dbase);
if (i < emskvec.size() && emskvec[i]!=0x0000) {
if (i < emskvec.size() && emskvec[i]!=0xffff) {
os << "," << RosPrintBvi(emskvec[i], dbase);
}
}
@@ -450,8 +461,10 @@ void RlinkCommand::Dump(std::ostream& os, int ind, const char* text) const
}
os << endl;
}
os << bl << " fExpectStatusVal:" << RosPrintBvi(fExpectStatusVal,0) << endl;
os << bl << " fExpectStatusMsk:" << RosPrintBvi(fExpectStatusMsk,0) << endl;
if (fpExpect) fpExpect->Dump(os, ind+2, "fpExpect: ");
return;
}
@@ -495,18 +508,21 @@ const Retro::RflagName* RlinkCommand::FlagNames()
RlinkCommand& RlinkCommand::operator=(const RlinkCommand& rhs)
{
if (&rhs == this) return *this;
fRequest = rhs.fRequest;
fAddress = rhs.fAddress;
fData = rhs.fData;
fBlock = rhs.fBlock;
fpBlockExt = rhs.fpBlockExt;
fBlockExtSize = rhs.fBlockExtSize;
fBlockDone = rhs.fBlockDone;
fStatus = rhs.fStatus;
fFlags = rhs.fFlags;
fRcvSize = rhs.fRcvSize;
fRequest = rhs.fRequest;
fAddress = rhs.fAddress;
fData = rhs.fData;
fBlock = rhs.fBlock;
fpBlockExt = rhs.fpBlockExt;
fBlockExtSize = rhs.fBlockExtSize;
fBlockDone = rhs.fBlockDone;
fStatus = rhs.fStatus;
fFlags = rhs.fFlags;
fRcvSize = rhs.fRcvSize;
fExpectStatusSet = rhs.fExpectStatusSet;
fExpectStatusVal = rhs.fExpectStatusVal;
fExpectStatusMsk = rhs.fExpectStatusMsk;
delete fpExpect;
fpExpect = rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : 0;
fpExpect = rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : 0;
return *this;
}

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommand.hpp 617 2014-12-21 14:18:53Z mueller $
// $Id: RlinkCommand.hpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.3 expect logic: add stat check, Print() without cntx
// 2014-12-21 617 1.2.2 use kStat_M_RbTout for rbus timeout
// 2014-12-20 616 1.2.1 add kFlagChkDone
// 2014-12-06 609 1.2 new rlink v4 iface
@@ -24,7 +25,7 @@
/*!
\file
\version $Id: RlinkCommand.hpp 617 2014-12-21 14:18:53Z mueller $
\version $Id: RlinkCommand.hpp 661 2015-04-03 18:28:41Z mueller $
\brief Declaration of class RlinkCommand.
*/
@@ -74,7 +75,10 @@ namespace Retro {
void SetFlagBit(uint32_t mask);
void ClearFlagBit(uint32_t mask);
void SetRcvSize(size_t rsize);
void SetExpect(RlinkCommandExpect* pexp);
void SetExpectStatus(uint8_t stat, uint8_t statmsk=0xff);
void SetExpectStatusDefault(uint8_t stat=0, uint8_t statmsk=0x0);
uint8_t Request() const;
uint8_t Command() const;
@@ -92,11 +96,17 @@ namespace Retro {
bool TestFlagAny(uint32_t mask) const;
bool TestFlagAll(uint32_t mask) const;
size_t RcvSize() const;
RlinkCommandExpect* Expect() const;
void Print(std::ostream& os, const RlinkContext& cntx,
const RlinkAddrMap* pamap=0, size_t abase=16,
size_t dbase=16, size_t sbase=16) const;
RlinkCommandExpect* Expect() const;
uint8_t ExpectStatusValue() const;
uint8_t ExpectStatusMask() const;
bool ExpectStatusSet() const;
bool StatusCheck() const;
bool StatusIsChecked() const;
void Print(std::ostream& os, const RlinkAddrMap* pamap=0,
size_t abase=16, size_t dbase=16,
size_t sbase=16) const;
void Dump(std::ostream& os, int ind=0, const char* text=0) const;
static const char* CommandName(uint8_t cmd);
@@ -150,6 +160,9 @@ namespace Retro {
uint8_t fStatus; //!< rlink command status
uint32_t fFlags; //!< state bits
size_t fRcvSize; //!< receive size for command
bool fExpectStatusSet; //!< stat chk set explicitely
uint8_t fExpectStatusVal; //!< status value
uint8_t fExpectStatusMsk; //!< status mask
RlinkCommandExpect* fpExpect; //!< pointer to expect container
};

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommand.ipp 600 2014-11-02 22:33:02Z mueller $
// $Id: RlinkCommand.ipp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.3 expect logic: add stat check, Print() without cntx
// 2014-11-02 600 1.2 new rlink v4 iface
// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<()
// 2011-03-27 374 1.0 Initial version
@@ -21,7 +22,7 @@
/*!
\file
\version $Id: RlinkCommand.ipp 600 2014-11-02 22:33:02Z mueller $
\version $Id: RlinkCommand.ipp 661 2015-04-03 18:28:41Z mueller $
\brief Implemenation (inline) of class RlinkCommand.
*/
@@ -139,6 +140,28 @@ inline void RlinkCommand::SetRcvSize(size_t rsize)
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkCommand::SetExpectStatus(uint8_t stat, uint8_t statmsk)
{
fExpectStatusSet = true;
fExpectStatusVal = stat;
fExpectStatusMsk = statmsk;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkCommand::SetExpectStatusDefault(uint8_t stat, uint8_t statmsk)
{
fExpectStatusSet = false;
fExpectStatusVal = stat;
fExpectStatusMsk = statmsk;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkCommand::Request() const
{
return fRequest;
@@ -272,5 +295,45 @@ inline RlinkCommandExpect* RlinkCommand::Expect() const
return fpExpect;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkCommand::ExpectStatusValue() const
{
return fExpectStatusVal;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkCommand::ExpectStatusMask() const
{
return fExpectStatusMsk;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommand::ExpectStatusSet() const
{
return fExpectStatusSet;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommand::StatusCheck() const
{
return (fStatus & fExpectStatusMsk) == fExpectStatusVal;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommand::StatusIsChecked() const
{
return fExpectStatusMsk != 0x0;
}
} // end namespace Retro

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $
// $Id: RlinkCommandExpect.cpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.1 expect logic: remove stat from Expect, invert mask
// 2011-11-28 434 1.0.1 Dump(): use proper cast for lp64 compatibility
// 2011-03-12 368 1.0 Initial version
// 2011-01-15 355 0.1 First draft
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $
\version $Id: RlinkCommandExpect.cpp 661 2015-04-03 18:28:41Z mueller $
\brief Implemenation of class RlinkCommandExpect.
*/
@@ -49,10 +50,8 @@ namespace Retro {
//! Default constructor
RlinkCommandExpect::RlinkCommandExpect()
: fStatusVal(0),
fStatusMsk(0xff),
fDataVal(0),
fDataMsk(0xffff),
: fDataVal(0),
fDataMsk(0x0),
fBlockVal(),
fBlockMsk()
{}
@@ -60,23 +59,8 @@ RlinkCommandExpect::RlinkCommandExpect()
//------------------------------------------+-----------------------------------
//! FIXME_docs
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk)
: fStatusVal(stat),
fStatusMsk(statmsk),
fDataVal(0),
fDataMsk(0xffff),
fBlockVal(),
fBlockMsk()
{}
//------------------------------------------+-----------------------------------
//! FIXME_docs
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
uint16_t data, uint16_t datamsk)
: fStatusVal(stat),
fStatusMsk(statmsk),
fDataVal(data),
RlinkCommandExpect::RlinkCommandExpect(uint16_t data, uint16_t datamsk)
: fDataVal(data),
fDataMsk(datamsk),
fBlockVal(),
fBlockMsk()
@@ -85,12 +69,9 @@ RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
//------------------------------------------+-----------------------------------
//! FIXME_docs
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
const std::vector<uint16_t>& block)
: fStatusVal(stat),
fStatusMsk(statmsk),
fDataVal(0),
fDataMsk(0xffff),
RlinkCommandExpect::RlinkCommandExpect(const std::vector<uint16_t>& block)
: fDataVal(0),
fDataMsk(0x0),
fBlockVal(block),
fBlockMsk()
{}
@@ -98,13 +79,10 @@ RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
//------------------------------------------+-----------------------------------
//! FIXME_docs
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
const std::vector<uint16_t>& block,
RlinkCommandExpect::RlinkCommandExpect(const std::vector<uint16_t>& block,
const std::vector<uint16_t>& blockmsk)
: fStatusVal(stat),
fStatusMsk(statmsk),
fDataVal(0),
fDataMsk(0xffff),
: fDataVal(0),
fDataMsk(0x0),
fBlockVal(block),
fBlockMsk(blockmsk)
{}
@@ -122,8 +100,8 @@ bool RlinkCommandExpect::BlockCheck(size_t ind, uint16_t val) const
{
if (ind >= fBlockVal.size()) return true;
uint16_t eval = fBlockVal[ind];
uint16_t emsk = (ind < fBlockMsk.size()) ? fBlockMsk[ind] : 0x0000;
return (val|emsk) == (eval|emsk);
uint16_t emsk = (ind < fBlockMsk.size()) ? fBlockMsk[ind] : 0xffff;
return (val & emsk) == eval;
}
//------------------------------------------+-----------------------------------
@@ -135,8 +113,8 @@ size_t RlinkCommandExpect::BlockCheck(const uint16_t* pval, size_t size) const
for (size_t i=0; i<size; i++) {
if (i >= fBlockVal.size()) break;
uint16_t eval = fBlockVal[i];
uint16_t emsk = (i < fBlockMsk.size()) ? fBlockMsk[i] : 0x0000;
if ((pval[i]|emsk) != (eval|emsk)) nerr += 1;
uint16_t emsk = (i < fBlockMsk.size()) ? fBlockMsk[i] : 0xffff;
if ((pval[i] & emsk) != eval) nerr += 1;
}
return nerr;
@@ -149,7 +127,7 @@ bool RlinkCommandExpect::BlockIsChecked(size_t ind) const
{
if (ind >= fBlockVal.size()) return false;
if (ind >= fBlockMsk.size()) return true;
return fBlockMsk[ind] != 0xffff;
return fBlockMsk[ind] != 0x0;
}
//------------------------------------------+-----------------------------------
@@ -160,8 +138,6 @@ void RlinkCommandExpect::Dump(std::ostream& os, int ind, const char* text) const
RosFill bl(ind);
os << bl << (text?text:"--") << "RlinkCommandExpect @ " << this << endl;
os << bl << " fStatusVal: " << RosPrintBvi(fStatusVal,0) << endl;
os << bl << " fStatusMsk: " << RosPrintBvi(fStatusMsk,0) << endl;
os << bl << " fDataVal: " << RosPrintBvi(fDataVal,0) << endl;
os << bl << " fDataMsk: " << RosPrintBvi(fDataMsk,0) << endl;
os << bl << " fBlockVal.size: " << RosPrintf(fBlockVal.size(),"d",3) << endl;
@@ -175,7 +151,7 @@ void RlinkCommandExpect::Dump(std::ostream& os, int ind, const char* text) const
os << RosPrintBvi(fBlockVal[i],16);
if (fBlockMsk.size()>0) {
if (i<fBlockMsk.size() && fBlockMsk[i]!=0x0000) {
if (i<fBlockMsk.size() && fBlockMsk[i]!=0xffff) {
os << "," << RosPrintBvi(fBlockMsk[i],16);
} else {
os << " ";

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommandExpect.hpp 616 2014-12-21 10:09:25Z mueller $
// $Id: RlinkCommandExpect.hpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.2 expect logic: remove stat from Expect, invert mask
// 2014-12-20 616 1.1 add Done count methods (for rblk/wblk)
// 2011-03-12 368 1.0 Initial version
// 2011-01-15 355 0.1 First draft
@@ -21,7 +22,7 @@
/*!
\file
\version $Id: RlinkCommandExpect.hpp 616 2014-12-21 10:09:25Z mueller $
\version $Id: RlinkCommandExpect.hpp 661 2015-04-03 18:28:41Z mueller $
\brief Declaration of class RlinkCommandExpect.
*/
@@ -37,38 +38,29 @@ namespace Retro {
public:
RlinkCommandExpect();
explicit RlinkCommandExpect(uint8_t stat, uint8_t statmsk=0);
RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
uint16_t data, uint16_t datamsk=0);
RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
const std::vector<uint16_t>& block);
RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
const std::vector<uint16_t>& block,
RlinkCommandExpect(uint16_t data, uint16_t datamsk=0xffff);
RlinkCommandExpect(const std::vector<uint16_t>& block);
RlinkCommandExpect(const std::vector<uint16_t>& block,
const std::vector<uint16_t>& blockmsk);
~RlinkCommandExpect();
void SetStatus(uint8_t stat, uint8_t statmsk=0);
void SetData(uint16_t data, uint16_t datamsk=0);
void SetDone(uint16_t done, bool check=true);
void SetBlock(const std::vector<uint16_t>& block);
void SetBlock(const std::vector<uint16_t>& block,
const std::vector<uint16_t>& blockmsk);
uint8_t StatusValue() const;
uint8_t StatusMask() const;
uint16_t DataValue() const;
uint16_t DataMask() const;
uint16_t DoneValue() const;
const std::vector<uint16_t>& BlockValue() const;
const std::vector<uint16_t>& BlockMask() const;
bool StatusCheck(uint8_t val) const;
bool DataCheck(uint16_t val) const;
bool DoneCheck(uint16_t val) const;
bool BlockCheck(size_t ind, uint16_t val) const;
size_t BlockCheck(const uint16_t* pval, size_t size) const;
bool StatusIsChecked() const;
bool DataIsChecked() const;
bool DoneIsChecked() const;
bool BlockIsChecked(size_t ind) const;
@@ -76,8 +68,6 @@ namespace Retro {
void Dump(std::ostream& os, int ind=0, const char* text=0) const;
protected:
uint8_t fStatusVal; //!< status value
uint8_t fStatusMsk; //!< status mask
uint16_t fDataVal; //!< data value
uint16_t fDataMsk; //!< data mask
std::vector<uint16_t> fBlockVal; //!< block value

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommandExpect.ipp 616 2014-12-21 10:09:25Z mueller $
// $Id: RlinkCommandExpect.ipp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.2 expect logic: remove stat from Expect, invert mask
// 2014-12-20 616 1.1 add Done count methods (for rblk/wblk)
// 2011-03-12 368 1.0 Initial version
// 2011-01-15 355 0.1 First draft
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkCommandExpect.ipp 616 2014-12-21 10:09:25Z mueller $
\version $Id: RlinkCommandExpect.ipp 661 2015-04-03 18:28:41Z mueller $
\brief Implemenation (inline) of class RlinkCommandExpect.
*/
@@ -30,16 +31,6 @@ namespace Retro {
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkCommandExpect::SetStatus(uint8_t stat, uint8_t statmsk)
{
fStatusVal = stat;
fStatusMsk = statmsk;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkCommandExpect::SetData(uint16_t data, uint16_t datamsk)
{
fDataVal = data;
@@ -53,7 +44,7 @@ inline void RlinkCommandExpect::SetData(uint16_t data, uint16_t datamsk)
inline void RlinkCommandExpect::SetDone(uint16_t done, bool check)
{
fDataVal = done;
fDataMsk = check ? 0 : 0xffff;
fDataMsk = check ? 0xffff : 0x0;
return;
}
@@ -81,22 +72,6 @@ inline void RlinkCommandExpect::SetBlock(
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkCommandExpect::StatusValue() const
{
return fStatusVal;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkCommandExpect::StatusMask() const
{
return fStatusMsk;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint16_t RlinkCommandExpect::DataValue() const
{
return fDataVal;
@@ -137,17 +112,9 @@ inline const std::vector<uint16_t>& RlinkCommandExpect::BlockMask() const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommandExpect::StatusCheck(uint8_t val) const
{
return (val|fStatusMsk) == (fStatusVal|fStatusMsk);
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommandExpect::DataCheck(uint16_t val) const
{
return (val|fDataMsk) == (fDataVal|fDataMsk);
return (val & fDataMsk) == fDataVal;
}
//------------------------------------------+-----------------------------------
@@ -161,17 +128,9 @@ inline bool RlinkCommandExpect::DoneCheck(uint16_t val) const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommandExpect::StatusIsChecked() const
{
return fStatusMsk != 0xff;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkCommandExpect::DataIsChecked() const
{
return fDataMsk != 0xffff;
return fDataMsk != 0x0;
}
//------------------------------------------+-----------------------------------
@@ -179,7 +138,7 @@ inline bool RlinkCommandExpect::DataIsChecked() const
inline bool RlinkCommandExpect::DoneIsChecked() const
{
return fDataMsk == 0;
return fDataMsk != 0x0;
}
} // end namespace Retro

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommandList.cpp 606 2014-11-24 07:08:51Z mueller $
// $Id: RlinkCommandList.cpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.3 expect logic: add SetLastExpect methods
// 2014-11-23 606 1.2 new rlink v4 iface
// 2014-08-02 576 1.1 rename LastExpect->SetLastExpect
// 2013-05-06 495 1.0.3 add RlinkContext to Print() args
@@ -24,7 +25,7 @@
/*!
\file
\version $Id: RlinkCommandList.cpp 606 2014-11-24 07:08:51Z mueller $
\version $Id: RlinkCommandList.cpp 661 2015-04-03 18:28:41Z mueller $
\brief Implemenation of class RlinkCommandList.
*/
@@ -200,13 +201,81 @@ size_t RlinkCommandList::AddInit(uint16_t addr, uint16_t data)
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpectStatus(uint8_t stat, uint8_t statmsk)
{
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpectStatus()",
"Bad state: list empty");
fList.back()->SetExpectStatus(stat, statmsk);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpectData(uint16_t data, uint16_t datamsk)
{
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpectData()",
"Bad state: list empty");
RlinkCommand& cmd = *fList.back();
if (!cmd.Expect()) cmd.SetExpect(new RlinkCommandExpect());
cmd.Expect()->SetData(data, datamsk);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpectDone(uint16_t done)
{
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpectDone()",
"Bad state: list empty");
RlinkCommand& cmd = *fList.back();
if (!cmd.Expect()) cmd.SetExpect(new RlinkCommandExpect());
cmd.Expect()->SetDone(done);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpectBlock(const std::vector<uint16_t>& block)
{
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpectBlock()",
"Bad state: list empty");
RlinkCommand& cmd = *fList.back();
if (!cmd.Expect()) cmd.SetExpect(new RlinkCommandExpect());
cmd.Expect()->SetBlock(block);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpectBlock(const std::vector<uint16_t>& block,
const std::vector<uint16_t>& blockmsk)
{
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpectBlock()",
"Bad state: list empty");
RlinkCommand& cmd = *fList.back();
if (!cmd.Expect()) cmd.SetExpect(new RlinkCommandExpect());
cmd.Expect()->SetBlock(block, blockmsk);
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::SetLastExpect(RlinkCommandExpect* pexp)
{
size_t ncmd = fList.size();
if (ncmd == 0)
if (fList.empty())
throw Rexception("RlinkCommandList::SetLastExpect()",
"Bad state: list empty");
fList[ncmd-1]->SetExpect(pexp);
fList.back()->SetExpect(pexp);
return;
}
@@ -224,12 +293,12 @@ void RlinkCommandList::Clear()
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkCommandList::Print(std::ostream& os, const RlinkContext& cntx,
void RlinkCommandList::Print(std::ostream& os,
const RlinkAddrMap* pamap, size_t abase,
size_t dbase, size_t sbase) const
{
foreach_ (RlinkCommand* pcmd, fList) {
pcmd->Print(os, cntx, pamap, abase, dbase, sbase);
pcmd->Print(os, pamap, abase, dbase, sbase);
}
return;
}

View File

@@ -1,6 +1,6 @@
// $Id: RlinkCommandList.hpp 606 2014-11-24 07:08:51Z mueller $
// $Id: RlinkCommandList.hpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-02 661 1.3 expect logic: add SetLastExpect methods
// 2014-11-23 606 1.2 new rlink v4 iface
// 2014-08-02 576 1.1 rename LastExpect->SetLastExpect
// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<()
@@ -23,7 +24,7 @@
/*!
\file
\version $Id: RlinkCommandList.hpp 606 2014-11-24 07:08:51Z mueller $
\version $Id: RlinkCommandList.hpp 661 2015-04-03 18:28:41Z mueller $
\brief Declaration of class RlinkCommandList.
*/
@@ -62,6 +63,12 @@ namespace Retro {
size_t AddAttn();
size_t AddInit(uint16_t addr, uint16_t data);
void SetLastExpectStatus(uint8_t stat, uint8_t statmsk=0xff);
void SetLastExpectData(uint16_t data, uint16_t datamsk=0xffff);
void SetLastExpectDone(uint16_t done);
void SetLastExpectBlock(const std::vector<uint16_t>& block);
void SetLastExpectBlock(const std::vector<uint16_t>& block,
const std::vector<uint16_t>& blockmsk);
void SetLastExpect(RlinkCommandExpect* exp);
void ClearLaboIndex();
@@ -72,9 +79,9 @@ namespace Retro {
void Clear();
size_t Size() const;
void Print(std::ostream& os, const RlinkContext& cntx,
const RlinkAddrMap* pamap=0, size_t abase=16,
size_t dbase=16, size_t sbase=16) const;
void Print(std::ostream& os, const RlinkAddrMap* pamap=0,
size_t abase=16, size_t dbase=16,
size_t sbase=16) const;
void Dump(std::ostream& os, int ind=0, const char* text=0) const;
RlinkCommandList& operator=(const RlinkCommandList& rhs);

View File

@@ -1,4 +1,4 @@
// $Id: RlinkConnect.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkConnect.cpp 679 2015-05-13 17:38:46Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,9 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-05-10 678 2.3.1 WaitAttn(): BUGFIX: return 0. (not -1.) if poll
// 2015-04-12 666 2.3 add LinkInit,LinkInitDone; transfer xon
// 2015-04-02 661 2.2 expect logic: stat expect in Command, invert mask
// 2015-01-06 631 2.1 full rlink v4 implementation
// 2014-12-10 611 2.0 re-organize for rlink v4
// 2014-08-26 587 1.5 start accept rlink v4 protocol (partially...)
@@ -33,7 +36,7 @@
/*!
\file
\version $Id: RlinkConnect.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkConnect.cpp 679 2015-05-13 17:38:46Z mueller $
\brief Implemenation of RlinkConnect.
*/
@@ -91,18 +94,20 @@ const uint16_t RlinkConnect::kRbufPrudentDelta;
RlinkConnect::RlinkConnect()
: fpPort(),
fLinkInitDeferred(false),
fLinkInitDone(false),
fpServ(nullptr),
fSndPkt(),
fRcvPkt(),
fContext(),
fAddrMap(),
fStats(),
fLogBaseAddr(16),
fLogBaseData(16),
fLogBaseStat(16),
fPrintLevel(0),
fDumpLevel(0),
fTraceLevel(0),
fLogBaseAddr(16), // addr default radix: hex
fLogBaseData(16), // data default radix: hex
fLogBaseStat(16), // stat default radix: hex
fPrintLevel(2), // default print: error and checks
fDumpLevel(0), // default dump: no
fTraceLevel(0), // default trace: no
fspLog(new RlogFile(&cout)),
fConnectMutex(),
fAttnNotiPatt(0),
@@ -111,7 +116,11 @@ RlinkConnect::RlinkConnect()
fRbufSize(2048)
{
for (size_t i=0; i<8; i++) fSeqNumber[i] = 0;
fContext.SetStatus(0, RlinkCommand::kStat_M_RbTout |
RlinkCommand::kStat_M_RbNak |
RlinkCommand::kStat_M_RbErr);
// Statistic setup
fStats.Define(kStatNExec, "NExec", "Exec() calls");
fStats.Define(kStatNExecPart, "NExecPart", "ExecPart() calls");
@@ -125,11 +134,12 @@ RlinkConnect::RlinkConnect()
fStats.Define(kStatNInit, "NInit", "init commands");
fStats.Define(kStatNRblkWord, "NRblkWord", "words rcvd with rblk");
fStats.Define(kStatNWblkWord, "NWblkWord", "words send with wblk");
fStats.Define(kStatNExpData, "NExpData", "Expect() for data defined");
fStats.Define(kStatNExpDone, "NExpDone", "Expect() for done defined");
fStats.Define(kStatNExpStat, "NExpStat", "Expect() for stat defined");
fStats.Define(kStatNExpData, "NExpData", "expect for data defined");
fStats.Define(kStatNExpDone, "NExpDone", "expect for done defined");
fStats.Define(kStatNExpStat, "NExpStat", "expect for stat explicit");
fStats.Define(kStatNNoExpStat,"NNoExpStat","no expect for stat");
fStats.Define(kStatNChkData, "NChkData", "expect data failed");
fStats.Define(kStatNChkDone, "NChkData", "expect done failed");
fStats.Define(kStatNChkDone, "NChkDone", "expect done failed");
fStats.Define(kStatNChkStat, "NChkStat", "expect stat failed");
fStats.Define(kStatNSndOob, "NSndOob", "SndOob() calls");
fStats.Define(kStatNErrMiss, "NErrMiss", "decode: missing data");
@@ -156,26 +166,22 @@ bool RlinkConnect::Open(const std::string& name, RerrMsg& emsg)
fpPort.reset(RlinkPortFactory::Open(name, emsg));
if (!fpPort) return false;
fSndPkt.SetXonEscape(fpPort->XonEnable()); // transfer XON enable
fpPort->SetLogFile(fspLog);
fpPort->SetTraceLevel(fTraceLevel);
RlinkCommandList clist;
clist.AddRreg(kRbaddr_RLSTAT);
clist.AddRreg(kRbaddr_RLID1);
clist.AddRreg(kRbaddr_RLID0);
if (!Exec(clist, emsg)) {
Close();
return false;
fLinkInitDone = false;
fRbufSize = 2048; // use minimum (2kB) as startup
fSysId = 0xffffffff;
if (! fpPort->Url().FindOpt("noinit")) {
if (!LinkInit(emsg)) {
Close();
return false;
}
}
uint16_t rlstat = clist[0].Data();
uint16_t rlid1 = clist[1].Data();
uint16_t rlid0 = clist[2].Data();
fRbufSize = size_t(1) << (10 + (rlstat & kRLSTAT_M_RBSize));
fSysId = uint32_t(rlid1)<<16 | uint32_t(rlid0);
return true;
}
@@ -198,6 +204,32 @@ void RlinkConnect::Close()
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
bool RlinkConnect::LinkInit(RerrMsg& emsg)
{
if (fLinkInitDone) return true;
RlinkCommandList clist;
clist.AddRreg(kRbaddr_RLSTAT);
clist.AddRreg(kRbaddr_RLID1);
clist.AddRreg(kRbaddr_RLID0);
if (!Exec(clist, emsg)) return false;
fLinkInitDone = true;
uint16_t rlstat = clist[0].Data();
uint16_t rlid1 = clist[1].Data();
uint16_t rlid0 = clist[2].Data();
fRbufSize = size_t(1) << (10 + (rlstat & kRLSTAT_M_RBSize));
fSysId = uint32_t(rlid1)<<16 | uint32_t(rlid0);
return true;
}
//------------------------------------------+-----------------------------------
//! Indicates whether server is active.
/*!
@@ -276,6 +308,8 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx,
clist.ClearLaboIndex();
uint8_t defstatval = cntx.StatusValue();
uint8_t defstatmsk = cntx.StatusMask();
size_t size = clist.Size();
for (size_t i=0; i<size; i++) {
@@ -298,6 +332,11 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx,
RlinkCommand::kFlagPktEnd |
RlinkCommand::kFlagErrNak |
RlinkCommand::kFlagErrDec);
// setup default status check unless explicit check defined
if (!cmd.ExpectStatusSet()) {
cmd.SetExpectStatusDefault(defstatval, defstatmsk);
}
}
// old split volative logic. Currently dormant
@@ -312,13 +351,13 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx,
break;
}
}
bool rc = ExecPart(clist, ibeg, iend, emsg, cntx);
bool rc = ExecPart(clist, ibeg, iend, emsg);
if (!rc) return rc;
ibeg = iend+1;
}
#endif
bool rc = ExecPart(clist, 0, size-1, emsg, cntx);
bool rc = ExecPart(clist, 0, size-1, emsg);
if (!rc) return rc;
bool checkseen = false;
@@ -342,8 +381,7 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx,
if (errorseen) loglevel = 1;
if (loglevel <= fPrintLevel) {
RlogMsg lmsg(*fspLog);
clist.Print(lmsg(), cntx, &AddrMap(), fLogBaseAddr, fLogBaseData,
fLogBaseStat);
clist.Print(lmsg(), &AddrMap(), fLogBaseAddr, fLogBaseData, fLogBaseStat);
}
if (loglevel <= fDumpLevel) {
RlogMsg lmsg(*fspLog);
@@ -417,7 +455,7 @@ double RlinkConnect::WaitAttn(double timeout, uint16_t& apat, RerrMsg& emsg)
}
// quit if poll only (zero timeout)
if (timeout == 0.) return -1.;
if (timeout == 0.) return 0.;
// wait for new notifier
double tnow = Rtools::TimeOfDayAsDouble();
@@ -591,6 +629,8 @@ void RlinkConnect::Dump(std::ostream& os, int ind, const char* text) const
os << bl << " fpPort: " << fpPort.get() << endl;
}
os << bl << " fLinkInitDone: " << fLinkInitDone << endl;
os << bl << " fpServ: " << fpServ << endl;
os << bl << " fSeqNumber: ";
for (size_t i=0; i<8; i++) os << RosPrintBvi(fSeqNumber[i],16) << " ";
@@ -647,7 +687,7 @@ void RlinkConnect::HandleUnsolicitedData()
//! FIXME_docs
bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend,
RerrMsg& emsg, RlinkContext& cntx)
RerrMsg& emsg)
{
if (ibeg>iend || iend>=clist.Size())
throw Rexception("RlinkConnect::ExecPart()",
@@ -666,7 +706,7 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend,
bool ok = ReadResponse(15., emsg);
if (!ok) Rexception("RlinkConnect::ExecPart()","faulty response");
int ncmd = DecodeResponse(clist, ibeg, iend, cntx);
int ncmd = DecodeResponse(clist, ibeg, iend);
if (ncmd != int(iend-ibeg+1)) {
clist.Dump(cout);
throw Rexception("RlinkConnect::ExecPart()","incomplete response");
@@ -764,8 +804,8 @@ void RlinkConnect::EncodeRequest(RlinkCommandList& clist, size_t ibeg,
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkConnect::DecodeResponse(RlinkCommandList& clist, size_t ibeg,
size_t iend, RlinkContext& cntx)
int RlinkConnect::DecodeResponse(RlinkCommandList& clist, size_t ibeg,
size_t iend)
{
size_t ncmd = 0;
@@ -872,7 +912,6 @@ int RlinkConnect::DecodeResponse(RlinkCommandList& clist, size_t ibeg,
} else {
if (expect.DataIsChecked()) fStats.Inc(kStatNExpData);
}
if (expect.StatusIsChecked()) fStats.Inc(kStatNExpStat);
if (ccode==RlinkCommand::kCmdRreg ||
ccode==RlinkCommand::kCmdLabo ||
@@ -894,19 +933,18 @@ int RlinkConnect::DecodeResponse(RlinkCommandList& clist, size_t ibeg,
fStats.Inc(kStatNChkDone);
cmd.SetFlagBit(RlinkCommand::kFlagChkDone);
}
}
if (!expect.StatusCheck(cmd.Status())) {
fStats.Inc(kStatNChkStat);
cmd.SetFlagBit(RlinkCommand::kFlagChkStat);
}
} else { // no expect, use context
if (!cntx.StatusCheck(cmd.Status())) {
fStats.Inc(kStatNChkStat);
cmd.SetFlagBit(RlinkCommand::kFlagChkStat);
}
} // if (cmd.Expect())
// status check, now independent of Expect object
if (cmd.ExpectStatusSet()) fStats.Inc(kStatNExpStat);
if (!cmd.StatusIsChecked()) fStats.Inc(kStatNNoExpStat);
if (!cmd.StatusCheck()) {
fStats.Inc(kStatNChkStat);
cmd.SetFlagBit(RlinkCommand::kFlagChkStat);
}
} // for (size_t i=ibeg; i<=iend; i++)
// FIXME_code: check that all data is consumed !!

View File

@@ -1,4 +1,4 @@
// $Id: RlinkConnect.hpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkConnect.hpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-12 666 2.3 add LinkInit,LinkInitDone; transfer xon
// 2015-04-02 661 2.2 expect logic: stat expect in Command, invert mask
// 2015-01-06 631 2.1 full rlink v4 implementation
// 2014-12-25 621 2.0.2 Reorganize packet send/revd stats
// 2014-12-20 616 2.0.1 add BlockDone expect checks
@@ -35,7 +37,7 @@
/*!
\file
\version $Id: RlinkConnect.hpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkConnect.hpp 666 2015-04-12 21:17:54Z mueller $
\brief Declaration of class \c RlinkConnect.
*/
@@ -80,6 +82,9 @@ namespace Retro {
bool IsOpen() const;
RlinkPort* Port() const;
bool LinkInit(RerrMsg& emsg);
bool LinkInitDone() const;
RlinkContext& Context();
void SetServer(RlinkServer* pserv);
@@ -185,9 +190,10 @@ namespace Retro {
kStatNInit, //!< init commands
kStatNRblkWord, //!< words rcvd with rblk
kStatNWblkWord, //!< words send with wblk
kStatNExpData, //!< Expect() for data defined
kStatNExpDone, //!< Expect() for done defined
kStatNExpStat, //!< Expect() for stat defined
kStatNExpData, //!< expect for data defined
kStatNExpDone, //!< expect for done defined
kStatNExpStat, //!< expect for stat explicit
kStatNNoExpStat, //!< no expect for stat
kStatNChkData, //!< expect data failed
kStatNChkDone, //!< expect done failed
kStatNChkStat, //!< expect stat failed
@@ -201,12 +207,12 @@ namespace Retro {
protected:
bool ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend,
RerrMsg& emsg, RlinkContext& cntx);
RerrMsg& emsg);
void EncodeRequest(RlinkCommandList& clist, size_t ibeg,
size_t iend);
int DecodeResponse(RlinkCommandList& clist, size_t ibeg,
size_t iend, RlinkContext& cntx);
int DecodeResponse(RlinkCommandList& clist, size_t ibeg,
size_t iend);
bool DecodeAttnNotify(uint16_t& apat);
bool ReadResponse(double timeout, RerrMsg& emsg);
void AcceptResponse();
@@ -215,6 +221,8 @@ namespace Retro {
protected:
boost::scoped_ptr<RlinkPort> fpPort; //!< ptr to port
bool fLinkInitDeferred; //!< noinit attr seen on Open
bool fLinkInitDone; //!< LinkInit done
RlinkServer* fpServ; //!< ptr to server (optional)
uint8_t fSeqNumber[8]; //!< command sequence number
RlinkPacketBufSnd fSndPkt; //!< send packet buffer

View File

@@ -1,4 +1,4 @@
// $Id: RlinkConnect.ipp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkConnect.ipp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-12 666 2.2 add LinkInit,LinkInitDone; transfer xon
// 2015-01-06 631 2.1 full rlink v4 implementation
// 2013-03-05 495 1.2.1 add Exec() without emsg (will send emsg to LogFile)
// 2013-02-23 492 1.2 use scoped_ptr for Port; Close allways allowed
@@ -25,7 +26,7 @@
/*!
\file
\version $Id: RlinkConnect.ipp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkConnect.ipp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation (inline) of RlinkConnect.
*/
@@ -51,6 +52,14 @@ inline RlinkPort* RlinkConnect::Port() const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkConnect::LinkInitDone() const
{
return fLinkInitDone;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline RlinkContext& RlinkConnect::Context()
{
return fContext;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkContext.hpp 492 2013-02-24 22:14:47Z mueller $
// $Id: RlinkContext.hpp 661 2015-04-03 18:28:41Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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,13 +13,14 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-03-28 660 1.1 add SetStatus(Value|Mask)()
// 2013-02-23 492 1.0 Initial version
// ---------------------------------------------------------------------------
/*!
\file
\version $Id: RlinkContext.hpp 492 2013-02-24 22:14:47Z mueller $
\version $Id: RlinkContext.hpp 661 2015-04-03 18:28:41Z mueller $
\brief Declaration of class RlinkContext.
*/
@@ -35,7 +36,10 @@ namespace Retro {
RlinkContext();
~RlinkContext();
void SetStatus(uint8_t stat, uint8_t statmsk=0);
void SetStatus(uint8_t stat, uint8_t statmsk=0xff);
void SetStatusValue(uint8_t stat);
void SetStatusMask(uint8_t statmsk);
uint8_t StatusValue() const;
uint8_t StatusMask() const;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkContext.ipp 492 2013-02-24 22:14:47Z mueller $
// $Id: RlinkContext.ipp 660 2015-03-29 22:10:16Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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,13 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-03-28 660 1.1 add SetStatus(Value|Mask)()
// 2013-02-23 492 1.0 Initial version
// ---------------------------------------------------------------------------
/*!
\file
\version $Id: RlinkContext.ipp 492 2013-02-24 22:14:47Z mueller $
\version $Id: RlinkContext.ipp 660 2015-03-29 22:10:16Z mueller $
\brief Implemenation (inline) of class RlinkContext.
*/
@@ -38,6 +39,24 @@ inline void RlinkContext::SetStatus(uint8_t stat, uint8_t statmsk)
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkContext::SetStatusValue(uint8_t stat)
{
fStatusVal = stat;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkContext::SetStatusMask(uint8_t statmsk)
{
fStatusMsk = statmsk;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline uint8_t RlinkContext::StatusValue() const
{
return fStatusVal;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPacketBufSnd.cpp 621 2014-12-26 21:20:05Z mueller $
// $Id: RlinkPacketBufSnd.cpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2015 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
// 2015-04-11 666 1.1 handle xon/xoff escaping, add (Set)XonEscape()
// 2014-12-25 621 1.0.1 Reorganize packet send/revd stats
// 2014-11-15 604 1.0 Initial version
// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkPacketBufSnd.cpp 621 2014-12-26 21:20:05Z mueller $
\version $Id: RlinkPacketBufSnd.cpp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation of class RlinkPacketBuf.
*/
@@ -47,11 +48,13 @@ namespace Retro {
//! Default constructor
RlinkPacketBufSnd::RlinkPacketBufSnd()
: fRawBuf()
: fXonEscape(false),
fRawBuf()
{
// Statistic setup
fStats.Define(kStatNTxPktByt, "NTxPktByt", "Tx packet bytes send");
fStats.Define(kStatNTxEsc, "NTxEsc", "Tx data escapes");
fStats.Define(kStatNTxEsc, "NTxEsc", "Tx esc escapes");
fStats.Define(kStatNTxXEsc, "NTxXEsc", "Tx xon escapes");
}
//------------------------------------------+-----------------------------------
@@ -88,7 +91,8 @@ void RlinkPacketBufSnd::PutWithCrc(const uint16_t* pdata, size_t count)
bool RlinkPacketBufSnd::SndPacket(RlinkPort* port, RerrMsg& emsg)
{
size_t nesc = 0;
size_t nesc = 0;
size_t nxesc = 0;
fRawBuf.reserve(2*fPktBuf.size()+4); // max. size of raw data
fRawBuf.clear();
@@ -99,16 +103,32 @@ bool RlinkPacketBufSnd::SndPacket(RlinkPort* port, RerrMsg& emsg)
uint8_t* pi = fPktBuf.data();
for (size_t i=0; i<ni; i++) {
uint8_t c = *pi++;
if (c == kSymEsc) {
PutRawEsc(kEcEsc);
nesc += 1;
} else {
fRawBuf.push_back(c);
continue;
}
if (fXonEscape) {
if (c == kSymXon) {
PutRawEsc(kEcXon);
nxesc += 1;
continue;
}
if (c == kSymXoff) {
PutRawEsc(kEcXoff);
nxesc += 1;
continue;
}
}
fRawBuf.push_back(c);
}
PutRawEsc(kEcEop); // <EOP>
fStats.Inc(kStatNTxEsc , double(nesc));
fStats.Inc(kStatNTxEsc, double(nesc));
fStats.Inc(kStatNTxXEsc, double(nxesc));
bool sndok = SndRaw(port, emsg);
if (sndok) fStats.Inc(kStatNTxPktByt, double(PktSize()));
@@ -132,6 +152,8 @@ bool RlinkPacketBufSnd::SndOob(RlinkPort* port, uint16_t addr, uint16_t data,
fRawBuf.push_back(uint8_t((data>>4) & 0x000f)); // DATA ( 7: 4)
fRawBuf.push_back(uint8_t((data>>8) & 0x000f)); // DATA (11: 8)
fRawBuf.push_back(uint8_t((data>>12) & 0x000f)); // DATA (15:12)
fRawBuf.push_back(0); // send two filler zero's to ensure that
fRawBuf.push_back(0); // comma handlers are in ground state
return SndRaw(port, emsg);
}
@@ -194,6 +216,8 @@ void RlinkPacketBufSnd::Dump(std::ostream& os, int ind, const char* text) const
RosFill bl(ind);
os << bl << (text?text:"--") << "RlinkPacketBufSnd @ " << this << endl;
os << bl << " fXonEscape: " << fXonEscape << endl;
size_t rawbufsize = fRawBuf.size();
os << bl << " fRawBuf(size): " << RosPrintf(rawbufsize,"d",4);
size_t ncol = max(1, (80-ind-4-6)/(2+1));

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPacketBufSnd.hpp 621 2014-12-26 21:20:05Z mueller $
// $Id: RlinkPacketBufSnd.hpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2015 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
// 2015-04-11 666 1.1 handle xon/xoff escaping, add (Set)XonEscape()
// 2014-12-25 621 1.0.1 Reorganize packet send/revd stats
// 2014-11-14 604 1.0 Initial version
// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
@@ -21,7 +22,7 @@
/*!
\file
\version $Id: RlinkPacketBufSnd.hpp 621 2014-12-26 21:20:05Z mueller $
\version $Id: RlinkPacketBufSnd.hpp 666 2015-04-12 21:17:54Z mueller $
\brief Declaration of class RlinkPacketBufSnd.
*/
@@ -39,6 +40,9 @@ namespace Retro {
RlinkPacketBufSnd();
~RlinkPacketBufSnd();
void SetXonEscape(bool xon);
bool XonEscape() const;
void Init();
void PutWithCrc(uint8_t data);
@@ -63,13 +67,15 @@ namespace Retro {
// statistics counter indices
enum stats {
kStatNTxPktByt=0, //!< Tx packet bytes send
kStatNTxEsc //!< Tx data escapes
kStatNTxEsc, //!< Tx esc escapes
kStatNTxXEsc //!< Tx xon escapes
};
protected:
bool SndRaw(RlinkPort* port, RerrMsg& emsg);
protected:
bool fXonEscape; //!< escape XON/XOFF
std::vector<uint8_t> fRawBuf; //!< raw data buffer
};

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPacketBufSnd.ipp 606 2014-11-24 07:08:51Z mueller $
// $Id: RlinkPacketBufSnd.ipp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2014- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2015 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,13 +13,14 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-11 666 1.1 handle xon/xoff escaping, add (Set)XonEscape()
// 2014-11-08 602 1.0 Initial version
// 2014-11-02 600 0.1 First draft (re-organize PacketBuf for rlink v4)
// ---------------------------------------------------------------------------
/*!
\file
\version $Id: RlinkPacketBufSnd.ipp 606 2014-11-24 07:08:51Z mueller $
\version $Id: RlinkPacketBufSnd.ipp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation (inline) of class RlinkPacketBuf.
*/
@@ -39,6 +40,23 @@ inline void RlinkPacketBufSnd::PutWithCrc(uint8_t data)
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkPacketBufSnd::SetXonEscape(bool xon)
{
fXonEscape = xon;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkPacketBufSnd::XonEscape() const
{
return fXonEscape;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline void RlinkPacketBufSnd::PutWithCrc(uint16_t data)
{
uint8_t datl = data & 0xff;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPort.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkPort.cpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-11 666 1.3 add fXon, XonEnable()
// 2014-12-10 611 1.2.4 add time stamps for Read/Write for logs
// 2014-11-29 607 1.2.3 BUGFIX: fix time handling on RawRead()
// 2014-11-23 606 1.2.2 use Rtools::TimeOfDayAsDouble()
@@ -30,7 +31,7 @@
/*!
\file
\version $Id: RlinkPort.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkPort.cpp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation of RlinkPort.
*/
@@ -72,6 +73,7 @@ const int RlinkPort::kErr;
RlinkPort::RlinkPort()
: fIsOpen(false),
fUrl(),
fXon(false),
fFdRead(-1),
fFdWrite(-1),
fspLog(),
@@ -295,6 +297,7 @@ void RlinkPort::Dump(std::ostream& os, int ind, const char* text) const
os << bl << " fIsOpen: " << (int)fIsOpen << endl;
fUrl.Dump(os, ind+2, "fUrl: ");
os << bl << " fXon: " << fXon << endl;
os << bl << " fFdRead: " << fFdRead << endl;
os << bl << " fFdWrite: " << fFdWrite << endl;
os << bl << " fspLog: " << fspLog.get() << endl;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPort.hpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-11 666 1.3 add fXon, XonEnable()
// 2014-12-10 611 1.2.2 add time stamps for Read/Write for logs
// 2013-05-01 513 1.2.1 fTraceLevel now uint32_t
// 2013-02-23 492 1.2 use RparseUrl
@@ -27,7 +28,7 @@
/*!
\file
\version $Id: RlinkPort.hpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkPort.hpp 666 2015-04-12 21:17:54Z mueller $
\brief Declaration of class RlinkPort.
*/
@@ -66,6 +67,7 @@ namespace Retro {
bool IsOpen() const;
const RparseUrl& Url() const;
bool XonEnable() const;
int FdRead() const;
int FdWrite() const;
@@ -101,6 +103,7 @@ namespace Retro {
protected:
bool fIsOpen; //!< is open flag
RparseUrl fUrl; //!< parsed url
bool fXon; //!< xon attribute set
int fFdRead; //!< fd for read
int fFdWrite; //!< fd for write
boost::shared_ptr<RlogFile> fspLog; //!< log file ptr

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPort.ipp 513 2013-05-01 14:02:06Z mueller $
// $Id: RlinkPort.ipp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-11 666 1.3 add fXon, XonEnable()
// 2013-05-01 513 1.2.1 fTraceLevel now uint32_t
// 2013-02-23 492 1.2 use RparseUrl
// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
@@ -22,7 +23,7 @@
/*!
\file
\version $Id: RlinkPort.ipp 513 2013-05-01 14:02:06Z mueller $
\version $Id: RlinkPort.ipp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation (inline) of RlinkPort.
*/
@@ -48,6 +49,14 @@ inline const Retro::RparseUrl& RlinkPort::Url() const
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline bool RlinkPort::XonEnable() const
{
return fXon;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
inline int RlinkPort::FdRead() const
{
return fFdRead;

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPortCuff.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkPortCuff.cpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2012-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2012-2015 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
// 2015-04-12 666 1.1.3 add noinit attribute
// 2014-08-22 584 1.1.2 use nullptr
// 2013-05-17 521 1.1.1 use Rtools::String2Long
// 2013-02-23 492 1.1 use RparseUrl
@@ -24,7 +25,7 @@
/*!
\file
\version $Id: RlinkPortCuff.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkPortCuff.cpp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation of RlinkPortCuff.
*/
@@ -97,7 +98,7 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg)
if (IsOpen()) Close();
if (!fUrl.Set(url, "|trace|", emsg)) return false;
if (!fUrl.Set(url, "|trace|noinit|", emsg)) return false;
// initialize USB context
irc = libusb_init(&fpUsbContext);

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPortFifo.cpp 607 2014-11-30 20:02:48Z mueller $
// $Id: RlinkPortFifo.cpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2013 y Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-12 666 1.2 add xon,noinit attributes
// 2013-02-23 492 1.1 use RparseUrl
// 2011-03-27 374 1.0 Initial version
// 2011-01-15 356 0.1 First draft
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkPortFifo.cpp 607 2014-11-30 20:02:48Z mueller $
\version $Id: RlinkPortFifo.cpp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation of RlinkPortFifo.
*/
@@ -64,7 +65,7 @@ bool RlinkPortFifo::Open(const std::string& url, RerrMsg& emsg)
{
if (IsOpen()) Close();
if (!fUrl.Set(url, "|keep|", emsg)) return false;
if (!fUrl.Set(url, "|keep|xon|noinit|", emsg)) return false;
// Note: _rx fifo must be opened before the _tx fifo, otherwise the test
// bench might close with EOF on read prematurely (is a race condition).
@@ -79,7 +80,8 @@ bool RlinkPortFifo::Open(const std::string& url, RerrMsg& emsg)
return false;
}
fIsOpen = true;
fXon = fUrl.FindOpt("xon");
fIsOpen = true;
return true;
}

View File

@@ -1,4 +1,4 @@
// $Id: RlinkPortTerm.cpp 641 2015-02-01 22:12:15Z mueller $
// $Id: RlinkPortTerm.cpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-12 666 1.3 drop xon/xoff excaping; add noinit attribute
// 2015-02-01 641 1.2 support custom baud rates (5M,6M,10M,12M)
// 2013-02-23 492 1.1 use RparseUrl
// 2011-12-18 440 1.0.4 add kStatNPort stats; Open(): autoadd /dev/tty,
@@ -26,7 +27,7 @@
/*!
\file
\version $Id: RlinkPortTerm.cpp 641 2015-02-01 22:12:15Z mueller $
\version $Id: RlinkPortTerm.cpp 666 2015-04-12 21:17:54Z mueller $
\brief Implemenation of RlinkPortTerm.
*/
@@ -58,17 +59,13 @@ namespace Retro {
// constants definitions
const uint8_t RlinkPortTerm::kc_xon;
const uint8_t RlinkPortTerm::kc_xoff;
const uint8_t RlinkPortTerm::kc_xesc;
//------------------------------------------+-----------------------------------
//! Default constructor
RlinkPortTerm::RlinkPortTerm()
: RlinkPort()
{
fStats.Define(kStatNPortTxXesc, "NPortTxXesc", "Tx XESC escapes");
fStats.Define(kStatNPortRxXesc, "NPortRxXesc", "Rx XESC escapes");
}
{}
//------------------------------------------+-----------------------------------
//! Destructor
@@ -85,7 +82,7 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg)
{
Close();
if (!fUrl.Set(url, "|baud=|break|cts|xon|", emsg)) return false;
if (!fUrl.Set(url, "|baud=|break|cts|xon|noinit|", emsg)) return false;
// if path doesn't start with a '/' prepend a '/dev/tty'
if (fUrl.Path().substr(0,1) != "/") {
@@ -176,8 +173,7 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg)
bool use_cts = fUrl.FindOpt("cts");
bool use_xon = fUrl.FindOpt("xon");
fUseXon = use_xon;
fPendXesc = false;
fXon = use_xon;
fTiosNew = fTiosOld;
@@ -318,78 +314,6 @@ void RlinkPortTerm::Close()
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkPortTerm::Read(uint8_t* buf, size_t size, double timeout,
RerrMsg& emsg)
{
int irc;
if (fUseXon) {
uint8_t* po = buf;
if (fRxBuf.size() < size) fRxBuf.resize(size);
// repeat read until at least one byte returned (or an error occurs)
// this avoids that the Read() returns with 0 in case only one byte is
// seen and this is a kc_xesc. At most two iterations possible because
// in 2nd iteration fPendXesc must be set and thus po pushed.
while (po == buf) {
irc = RlinkPort::Read(fRxBuf.data(), size, timeout, emsg);
if (irc <= 0) break;
uint8_t* pi = fRxBuf.data();
for (int i=0; i<irc; i++) {
uint8_t c = *pi++;
if (fPendXesc) {
*po++ = ~c;
fPendXesc = false;
} else if (c == kc_xesc) {
fStats.Inc(kStatNPortRxXesc);
fPendXesc = true;
} else {
*po++ = c;
}
}
irc = po - buf; // set irc to # of unescaped bytes
}
} else {
irc = RlinkPort::Read(buf, size, timeout, emsg);
}
return irc;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
int RlinkPortTerm::Write(const uint8_t* buf, size_t size, RerrMsg& emsg)
{
int irc = 0;
if (fUseXon) {
fTxBuf.clear();
const uint8_t* pc = buf;
for (size_t i=0; i<size; i++) {
uint8_t c = *pc++;
if (c==kc_xon || c==kc_xoff || c==kc_xesc) {
fStats.Inc(kStatNPortTxXesc);
fTxBuf.push_back(kc_xesc);
fTxBuf.push_back(~c);
} else {
fTxBuf.push_back(c);
}
}
int irce = RlinkPort::Write(fTxBuf.data(), fTxBuf.size(), emsg);
if (irce == (int)fTxBuf.size()) irc = size;
} else {
irc = RlinkPort::Write(buf, size, emsg);
}
/* tcdrain(fFdWrite);*/
return irc;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void RlinkPortTerm::Dump(std::ostream& os, int ind, const char* text) const
{
RosFill bl(ind);

View File

@@ -1,6 +1,6 @@
// $Id: RlinkPortTerm.hpp 486 2013-02-10 22:34:43Z mueller $
// $Id: RlinkPortTerm.hpp 666 2015-04-12 21:17:54Z mueller $
//
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2015 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
// 2015-04-11 666 1.1 drop xon/xoff excaping, now done in RlinkPacketBuf
// 2011-12-18 440 1.0.2 add kStatNPort stats
// 2011-12-11 438 1.0.1 Read(),Write(): added for xon handling, tcdrain();
// 2011-03-27 374 1.0 Initial version
@@ -21,7 +22,7 @@
/*!
\file
\version $Id: RlinkPortTerm.hpp 486 2013-02-10 22:34:43Z mueller $
\version $Id: RlinkPortTerm.hpp 666 2015-04-12 21:17:54Z mueller $
\brief Declaration of class RlinkPortTerm.
*/
@@ -43,23 +44,12 @@ namespace Retro {
virtual bool Open(const std::string& url, RerrMsg& emsg);
virtual void Close();
virtual int Read(uint8_t* buf, size_t size, double timeout,
RerrMsg& emsg);
virtual int Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const;
// some constants (also defined in cpp)
static const uint8_t kc_xon = 0x11; // XON char -> ^Q = hex 11
static const uint8_t kc_xoff = 0x13; // XOFF char -> ^S = hex 13
static const uint8_t kc_xesc = 0x1b; // XESC char -> ^[ = ESC = hex 1B
// statistics counter indices
enum stats {
kStatNPortTxXesc = RlinkPort::kDimStat,
kStatNPortRxXesc,
kDimStat
};
protected:
void DumpTios(std::ostream& os, int ind, const std::string& name,
@@ -68,10 +58,6 @@ namespace Retro {
protected:
struct termios fTiosOld;
struct termios fTiosNew;
bool fUseXon; //!< xon attribute set
bool fPendXesc; //!< xesc pending
std::vector<uint8_t> fTxBuf; //!< buffer to handle xesc
std::vector<uint8_t> fRxBuf; //!< buffer to handle xesc
};
} // end namespace Retro

View File

@@ -1,4 +1,4 @@
// $Id: RlinkServer.cpp 632 2015-01-11 12:30:03Z mueller $
// $Id: RlinkServer.cpp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), use UnStop()
// 2015-01-10 632 2.2 Exec() without emsg now void, will throw
// 2014-12-30 625 2.1 adopt to Rlink V4 attn logic
// 2014-12-21 617 2.0.1 use kStat_M_RbTout for rbus timeout
@@ -25,7 +26,7 @@
/*!
\file
\version $Id: RlinkServer.cpp 632 2015-01-11 12:30:03Z mueller $
\version $Id: RlinkServer.cpp 662 2015-04-05 08:02:54Z mueller $
\brief Implemenation of RlinkServer.
*/
@@ -67,10 +68,9 @@ RlinkServer::RlinkServer()
fTraceLevel(0),
fStats()
{
fContext.SetStatus(0,
~(RlinkCommand::kStat_M_RbTout |
RlinkCommand::kStat_M_RbNak |
RlinkCommand::kStat_M_RbErr));
fContext.SetStatus(0, RlinkCommand::kStat_M_RbTout |
RlinkCommand::kStat_M_RbNak |
RlinkCommand::kStat_M_RbErr);
fELoop.AddPollHandler(boost::bind(&RlinkServer::WakeupHandler, this, _1),
fWakeupEvent, POLLIN);
@@ -414,6 +414,7 @@ void RlinkServer::StartOrResume(bool resume)
rlinkfd, POLLIN);
// and start server thread
fELoop.UnStop();
fServerThread = boost::thread(boost::bind(&RlinkServerEventLoop::EventLoop,
&fELoop));

View File

@@ -1,6 +1,6 @@
// $Id: RlinkServerEventLoop.cpp 495 2013-03-06 17:13:48Z mueller $
// $Id: RlinkServerEventLoop.cpp 662 2015-04-05 08:02:54Z mueller $
//
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 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
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), use StopPending()
// 2013-03-05 495 1.1.1 add exception catcher to EventLoop
// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
// 2013-01-12 474 1.0 Initial Version
@@ -20,7 +21,7 @@
/*!
\file
\version $Id: RlinkServerEventLoop.cpp 495 2013-03-06 17:13:48Z mueller $
\version $Id: RlinkServerEventLoop.cpp 662 2015-04-05 08:02:54Z mueller $
\brief Implemenation of RlinkServerEventLoop.
*/
@@ -59,13 +60,12 @@ RlinkServerEventLoop::~RlinkServerEventLoop()
void RlinkServerEventLoop::EventLoop()
{
fLoopActive = true;
fUpdatePoll = true;
if (fspLog && fTraceLevel>0) fspLog->Write("eloop: starting", 'I');
try {
while (fLoopActive) {
while (!StopPending()) {
int timeout = (fpServer->AttnPending() ||
fpServer->ActnPending()) ? 0 : -1;
int irc = DoPoll(timeout);