Line 1... |
Line 1... |
// $Id: RlinkCommand.cpp 628 2015-01-04 16:22:09Z mueller $
|
// $Id: RlinkCommand.cpp 643 2015-02-07 17:41:53Z mueller $
|
//
|
//
|
// Copyright 2011-2015 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
|
// 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
|
// the terms of the GNU General Public License as published by the Free
|
Line 11... |
Line 11... |
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for complete details.
|
// for complete details.
|
//
|
//
|
// Revision History:
|
// Revision History:
|
// Date Rev Version Comment
|
// Date Rev Version Comment
|
// 2015-01-04 628 1.2.3 Print(): adopt large nblk;
|
// 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-21 617 1.2.2 use kStat_M_RbTout for rbus timeout
|
// 2014-12-20 616 1.2.1 Print(): display BlockDone; add kFlagChkDone
|
// 2014-12-20 616 1.2.1 Print(): display BlockDone; add kFlagChkDone
|
// 2014-12-06 609 1.2 new rlink v4 iface
|
// 2014-12-06 609 1.2 new rlink v4 iface
|
// 2014-08-15 583 1.1 rb_mreq addr now 16 bit
|
// 2014-08-15 583 1.1 rb_mreq addr now 16 bit
|
// 2013-05-06 495 1.0.2 add RlinkContext to Print() args
|
// 2013-05-06 495 1.0.2 add RlinkContext to Print() args
|
Line 24... |
Line 24... |
// 2011-01-15 355 0.1 First draft
|
// 2011-01-15 355 0.1 First draft
|
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
|
|
/*!
|
/*!
|
\file
|
\file
|
\version $Id: RlinkCommand.cpp 628 2015-01-04 16:22:09Z mueller $
|
\version $Id: RlinkCommand.cpp 643 2015-02-07 17:41:53Z mueller $
|
\brief Implemenation of class RlinkCommand.
|
\brief Implemenation of class RlinkCommand.
|
*/
|
*/
|
|
|
// debug
|
// debug
|
#include <iostream>
|
#include <iostream>
|
Line 89... |
Line 89... |
RlinkCommand::RlinkCommand()
|
RlinkCommand::RlinkCommand()
|
: fRequest(0),
|
: fRequest(0),
|
fAddress(0),
|
fAddress(0),
|
fData(0),
|
fData(0),
|
fBlock(),
|
fBlock(),
|
fpBlockExt(0),
|
fpBlockExt(nullptr),
|
fBlockExtSize(0),
|
fBlockExtSize(0),
|
fBlockDone(0),
|
fBlockDone(0),
|
fStatus(0),
|
fStatus(0),
|
fFlags(0),
|
fFlags(0),
|
fRcvSize(0),
|
fRcvSize(0),
|
fpExpect(0)
|
fpExpect(nullptr)
|
{}
|
{}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! Copy constructor
|
//! Copy constructor
|
|
|
Line 112... |
Line 112... |
fBlockExtSize(rhs.fBlockExtSize),
|
fBlockExtSize(rhs.fBlockExtSize),
|
fBlockDone(rhs.fBlockDone),
|
fBlockDone(rhs.fBlockDone),
|
fStatus(rhs.fStatus),
|
fStatus(rhs.fStatus),
|
fFlags(rhs.fFlags),
|
fFlags(rhs.fFlags),
|
fRcvSize(rhs.fRcvSize),
|
fRcvSize(rhs.fRcvSize),
|
fpExpect(rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : 0)
|
fpExpect(rhs.fpExpect ? new RlinkCommandExpect(*rhs.fpExpect) : nullptr)
|
{}
|
{}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! Destructor
|
//! Destructor
|
|
|
Line 173... |
Line 173... |
if (cmd > kCmdInit)
|
if (cmd > kCmdInit)
|
throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid cmd");
|
throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid cmd");
|
fRequest = cmd;
|
fRequest = cmd;
|
fAddress = addr;
|
fAddress = addr;
|
fData = data;
|
fData = data;
|
fpBlockExt = 0;
|
fpBlockExt = nullptr;
|
fBlockExtSize = 0;
|
fBlockExtSize = 0;
|
fBlockDone = 0;
|
fBlockDone = 0;
|
fStatus = 0;
|
fStatus = 0;
|
fFlags = kFlagInit;
|
fFlags = kFlagInit;
|
fRcvSize = 0;
|
fRcvSize = 0;
|
delete fpExpect;
|
delete fpExpect;
|
fpExpect = 0;
|
fpExpect = nullptr;
|
return;
|
return;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_docs
|
//! FIXME_docs
|
Line 202... |
Line 202... |
{
|
{
|
if (block.size() == 0 || block.size() > 65535)
|
if (block.size() == 0 || block.size() > 65535)
|
throw Rexception("RlinkCommand::SetBlockWrite()",
|
throw Rexception("RlinkCommand::SetBlockWrite()",
|
"Bad args: invalid block size");
|
"Bad args: invalid block size");
|
fBlock = block;
|
fBlock = block;
|
fpBlockExt = 0;
|
fpBlockExt = nullptr;
|
fBlockExtSize = 0;
|
fBlockExtSize = 0;
|
fBlockDone = 0;
|
fBlockDone = 0;
|
return;
|
return;
|
}
|
}
|
|
|
Line 218... |
Line 218... |
if (size == 0 || size > 65535)
|
if (size == 0 || size > 65535)
|
throw Rexception("RlinkCommand::SetBlockRead()",
|
throw Rexception("RlinkCommand::SetBlockRead()",
|
"Bad args: invalid block size");
|
"Bad args: invalid block size");
|
fBlock.clear();
|
fBlock.clear();
|
fBlock.resize(size);
|
fBlock.resize(size);
|
fpBlockExt = 0;
|
fpBlockExt = nullptr;
|
fBlockExtSize = 0;
|
fBlockExtSize = 0;
|
fBlockDone = 0;
|
fBlockDone = 0;
|
return;
|
return;
|
}
|
}
|
|
|
Line 443... |
Line 443... |
os << bl << " fRcvSize: " << RosPrintf(fRcvSize,"d",4) << endl;
|
os << bl << " fRcvSize: " << RosPrintf(fRcvSize,"d",4) << endl;
|
if (BlockSize() > 0) {
|
if (BlockSize() > 0) {
|
size_t ncol = max(1, (80-ind-4-5)/(4+1));
|
size_t ncol = max(1, (80-ind-4-5)/(4+1));
|
os << bl << " block data:";
|
os << bl << " block data:";
|
for (size_t i=0; i<BlockSize(); i++) {
|
for (size_t i=0; i<BlockSize(); i++) {
|
if (i%ncol == 0) os << "\n" << bl << " " << RosPrintf(i,"d",3) << ": ";
|
if (i%ncol == 0) os << "\n" << bl << " " << RosPrintf(i,"d",4) << ": ";
|
os << RosPrintBvi(BlockPointer()[i],16) << " ";
|
os << RosPrintBvi(BlockPointer()[i],16) << " ";
|
}
|
}
|
os << endl;
|
os << endl;
|
}
|
}
|
if (fpExpect) fpExpect->Dump(os, ind+2, "fpExpect: ");
|
if (fpExpect) fpExpect->Dump(os, ind+2, "fpExpect: ");
|