OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [src/] [librlink/] [RlinkConnect.cpp] - Diff between revs 28 and 29

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 28 Rev 29
Line 1... Line 1...
// $Id: RlinkConnect.cpp 626 2015-01-03 14:41:37Z mueller $
// $Id: RlinkConnect.cpp 632 2015-01-11 12:30:03Z 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-01   626   2.1    full rlink v4 implementation
// 2015-01-06   631   2.1    full rlink v4 implementation
// 2014-12-10   611   2.0    re-organize for rlink v4
// 2014-12-10   611   2.0    re-organize for rlink v4
// 2014-08-26   587   1.5    start accept rlink v4 protocol (partially...)
// 2014-08-26   587   1.5    start accept rlink v4 protocol (partially...)
// 2014-08-15   583   1.4    rb_mreq addr now 16 bit
// 2014-08-15   583   1.4    rb_mreq addr now 16 bit
// 2014-07-27   575   1.3.3  ExecPart(): increase packet tout from 5 to 15 sec
// 2014-07-27   575   1.3.3  ExecPart(): increase packet tout from 5 to 15 sec
// 2013-04-21   509   1.3.2  add SndAttn() method
// 2013-04-21   509   1.3.2  add SndAttn() method
Line 31... Line 31...
// 2011-01-15   356   0.1    First draft
// 2011-01-15   356   0.1    First draft
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
 
 
/*!
/*!
  \file
  \file
  \version $Id: RlinkConnect.cpp 626 2015-01-03 14:41:37Z mueller $
  \version $Id: RlinkConnect.cpp 632 2015-01-11 12:30:03Z mueller $
  \brief   Implemenation of RlinkConnect.
  \brief   Implemenation of RlinkConnect.
*/
*/
 
 
#include <iostream>
#include <iostream>
 
 
Line 89... Line 89...
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! Default constructor
//! Default constructor
 
 
RlinkConnect::RlinkConnect()
RlinkConnect::RlinkConnect()
  : fpPort(),
  : fpPort(),
    fpServ(0),
    fpServ(nullptr),
    fSndPkt(),
    fSndPkt(),
    fRcvPkt(),
    fRcvPkt(),
    fContext(),
    fContext(),
    fAddrMap(),
    fAddrMap(),
    fStats(),
    fStats(),
    fLogOpts(),
    fLogBaseAddr(16),
    fspLog(new RlogFile(&cout, "<cout>")),
    fLogBaseData(16),
 
    fLogBaseStat(16),
 
    fPrintLevel(0),
 
    fDumpLevel(0),
 
    fTraceLevel(0),
 
    fspLog(new RlogFile(&cout)),
    fConnectMutex(),
    fConnectMutex(),
    fAttnNotiPatt(0),
    fAttnNotiPatt(0),
    fTsLastAttnNoti(-1),
    fTsLastAttnNoti(-1),
    fSysId(0xffffffff),
    fSysId(0xffffffff),
    fRbufSize(0)
    fRbufSize(2048)
{
{
  for (size_t i=0; i<8; i++) fSeqNumber[i] = 0;
  for (size_t i=0; i<8; i++) fSeqNumber[i] = 0;
 
 
  // Statistic setup
  // Statistic setup
  fStats.Define(kStatNExec,     "NExec",     "Exec() calls");
  fStats.Define(kStatNExec,     "NExec",     "Exec() calls");
Line 150... Line 155...
 
 
  fpPort.reset(RlinkPortFactory::Open(name, emsg));
  fpPort.reset(RlinkPortFactory::Open(name, emsg));
  if (!fpPort) return false;
  if (!fpPort) return false;
 
 
  fpPort->SetLogFile(fspLog);
  fpPort->SetLogFile(fspLog);
  fpPort->SetTraceLevel(fLogOpts.tracelevel);
  fpPort->SetTraceLevel(fTraceLevel);
 
 
  RlinkCommandList clist;
  RlinkCommandList clist;
  clist.AddRreg(kRbaddr_RLSTAT);
  clist.AddRreg(kRbaddr_RLSTAT);
  clist.AddRreg(kRbaddr_RLID1);
  clist.AddRreg(kRbaddr_RLID1);
  clist.AddRreg(kRbaddr_RLID0);
  clist.AddRreg(kRbaddr_RLID0);
Line 333... Line 338...
  }
  }
 
 
  size_t loglevel = 3;
  size_t loglevel = 3;
  if (checkseen) loglevel = 2;
  if (checkseen) loglevel = 2;
  if (errorseen) loglevel = 1;
  if (errorseen) loglevel = 1;
  if (loglevel <= fLogOpts.printlevel) {
  if (loglevel <= fPrintLevel) {
    RlogMsg lmsg(*fspLog);
    RlogMsg lmsg(*fspLog);
    clist.Print(lmsg(), cntx, &AddrMap(), fLogOpts.baseaddr, fLogOpts.basedata,
    clist.Print(lmsg(), cntx, &AddrMap(), fLogBaseAddr, fLogBaseData,
                fLogOpts.basestat);
                fLogBaseStat);
  }
  }
  if (loglevel <= fLogOpts.dumplevel) {
  if (loglevel <= fDumpLevel) {
    RlogMsg lmsg(*fspLog);
    RlogMsg lmsg(*fspLog);
    clist.Dump(lmsg(), 0);
    clist.Dump(lmsg(), 0);
  }
  }
 
 
  return true;
  return true;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx)
void RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx)
{
{
  RerrMsg emsg;
  RerrMsg emsg;
  bool rc = Exec(clist, cntx, emsg);
  bool rc = Exec(clist, cntx, emsg);
  if (!rc) {
  if (!rc) {
    RlogMsg lmsg(*fspLog, 'E');
    RlogMsg lmsg(*fspLog, 'F');
    lmsg << emsg << endl;
    lmsg << emsg << endl;
    lmsg << "Dump of failed clist:" << endl;
    lmsg << "Dump of failed clist:" << endl;
    clist.Dump(lmsg(), 0);
    clist.Dump(lmsg(), 0);
  }
  }
  return rc;
  if (!rc)
 
    throw Rexception("RlinkConnect::Exec", "Exec() failed: ", emsg);
 
  return;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! Wait for an attention notify.
//! Wait for an attention notify.
/*!
/*!
Line 464... Line 471...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
void RlinkConnect::SetLogOpts(const LogOpts& opts)
void RlinkConnect::SetLogBaseAddr(uint32_t base)
{
{
  if (opts.baseaddr!=2 && opts.baseaddr!=8 && opts.baseaddr!=16)
  if (base!=2 && base!=8 && base!=16)
    throw Rexception("RlinkConnect::SetLogOpts()",
    throw Rexception("RlinkConnect::SetLogBaseAddr()",
                     "Bad args: baseaddr != 2,8,16");
                     "Bad args: base != 2,8,16");
  if (opts.basedata!=2 && opts.basedata!=8 && opts.basedata!=16)
  fLogBaseAddr = base;
    throw Rexception("RlinkConnect::SetLogOpts()",
  return;
                     "Bad args: basedata != 2,8,16");
}
  if (opts.basestat!=2 && opts.basestat!=8 && opts.basestat!=16)
 
    throw Rexception("RlinkConnect::SetLogOpts()",
//------------------------------------------+-----------------------------------
                     "Bad args: basestat != 2,8,16");
//! FIXME_docs
 
 
  fLogOpts = opts;
void RlinkConnect::SetLogBaseData(uint32_t base)
  if (fpPort) fpPort->SetTraceLevel(opts.tracelevel);
{
 
  if (base!=2 && base!=8 && base!=16)
 
    throw Rexception("RlinkConnect::SetLogBaseData()",
 
                     "Bad args: base != 2,8,16");
 
  fLogBaseData = base;
  return;
  return;
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
bool RlinkConnect::LogOpen(const std::string& name)
void RlinkConnect::SetLogBaseStat(uint32_t base)
{
{
  if (!fspLog->Open(name)) {
  if (base!=2 && base!=8 && base!=16)
    fspLog->UseStream(&cout, "<cout>");
    throw Rexception("RlinkConnect::SetLogBaseStat()",
 
                     "Bad args: base != 2,8,16");
 
  fLogBaseStat = base;
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
void RlinkConnect::SetPrintLevel(uint32_t lvl)
 
{
 
  fPrintLevel = lvl;
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
void RlinkConnect::SetDumpLevel(uint32_t lvl)
 
{
 
  fDumpLevel = lvl;
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
void RlinkConnect::SetTraceLevel(uint32_t lvl)
 
{
 
  fTraceLevel = lvl;
 
  if (fpPort) fpPort->SetTraceLevel(lvl);
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
bool RlinkConnect::LogOpen(const std::string& name, RerrMsg& emsg)
 
{
 
  if (!fspLog->Open(name, emsg)) {
 
    fspLog->UseStream(&cout);
    return false;
    return false;
  }
  }
  return true;
  return true;
}
}
 
 
Line 505... Line 556...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
 
void RlinkConnect::SetLogFileName(const std::string& name)
 
{
 
  RerrMsg emsg;
 
  if (!LogOpen(name, emsg)) {
 
    throw Rexception("RlinkConnect::SetLogFile",
 
                     emsg.Text() + "', using stdout");
 
  }
 
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
void RlinkConnect::Print(std::ostream& os) const
void RlinkConnect::Print(std::ostream& os) const
{
{
  os << "RlinkConnect::Print(std::ostream& os)" << endl;
  os << "RlinkConnect::Print(std::ostream& os)" << endl;
  return;
  return;
}
}
Line 535... Line 599...
  fSndPkt.Dump(os, ind+2, "fSndPkt: ");
  fSndPkt.Dump(os, ind+2, "fSndPkt: ");
  fRcvPkt.Dump(os, ind+2, "fRcvPkt: ");
  fRcvPkt.Dump(os, ind+2, "fRcvPkt: ");
  fContext.Dump(os, ind+2, "fContext: ");
  fContext.Dump(os, ind+2, "fContext: ");
  fAddrMap.Dump(os, ind+2, "fAddrMap: ");
  fAddrMap.Dump(os, ind+2, "fAddrMap: ");
  fStats.Dump(os, ind+2, "fStats: ");
  fStats.Dump(os, ind+2, "fStats: ");
  os << bl << "  fLogOpts.baseaddr   " << fLogOpts.baseaddr << endl;
  os << bl << "  fLogBaseAddr:    " << fLogBaseAddr << endl;
  os << bl << "          .basedata   " << fLogOpts.basedata << endl;
  os << bl << "  fLogBaseData:    " << fLogBaseData << endl;
  os << bl << "          .basestat   " << fLogOpts.basestat << endl;
  os << bl << "  fLogBaseStat:    " << fLogBaseStat << endl;
  os << bl << "          .printlevel " << fLogOpts.printlevel << endl;
  os << bl << "  fPrintLevel:     " << fPrintLevel << endl;
  os << bl << "          .dumplevel  " << fLogOpts.dumplevel << endl;
  os << bl << "  fDumpLevel       " << fDumpLevel << endl;
  os << bl << "          .tracelevel " << fLogOpts.tracelevel << endl;
  os << bl << "  fTraceLevel      " << fTraceLevel << endl;
  fspLog->Dump(os, ind+2, "fspLog: ");
  fspLog->Dump(os, ind+2, "fspLog: ");
  os << bl << "  fAttnNotiPatt: " << RosPrintBvi(fAttnNotiPatt,16) << endl;
  os << bl << "  fAttnNotiPatt: " << RosPrintBvi(fAttnNotiPatt,16) << endl;
  //FIXME_code: fTsLastAttnNoti not yet in Dump (get formatter...)
  //FIXME_code: fTsLastAttnNoti not yet in Dump (get formatter...)
 
 
  return;
  return;
Line 1014... Line 1078...
      RlogMsg lmsg(*fspLog, 'W');
      RlogMsg lmsg(*fspLog, 'W');
      lmsg << "ProcessAttnNotify: zero attn notify received";
      lmsg << "ProcessAttnNotify: zero attn notify received";
    }
    }
  }
  }
 
 
  if (ok && fLogOpts.printlevel == 3) {
  if (ok && fPrintLevel == 3) {
     RlogMsg lmsg(*fspLog, 'I');
     RlogMsg lmsg(*fspLog, 'I');
     lmsg << "ATTN notify apat = " << RosPrintf(apat,"x0",4)
     lmsg << "ATTN notify apat = " << RosPrintf(apat,"x0",4)
          << "  lams =";
          << "  lams =";
     if (apat) {
     if (apat) {
       char sep = ' ';
       char sep = ' ';

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.