46using namespace std::placeholders;
136 while (args.
NextOpt(opt, optset)) {
137 if (opt ==
"-clear") fclear =
true;
210 fupObj->Dump(sos, 0,
"", 0);
239 sos <<
"logfile: " <<
fspLog->Name()
254 fGets.
Add<
const string&> (
"logfile",
256 fSets.
Add<
const string&> (
"logfile",
271 if (
fupObj && (!testopen ||
fupObj->IsOpen()))
return true;
282 if (!
fspLog->Open(name, emsg)) {
285 emsg.
Text() +
"', using stdout");
305 vector<uint8_t> rdata;
308 if (!args.
GetArg(
"bsize", rsize, 1, 4096))
return kERR;
309 if (!args.
GetArg(
"varData", rvname))
return kERR;
313 while (args.
NextOpt(opt, optset)) {
314 if (opt ==
"-timeout") {
315 if (!args.
GetArg(
"tsec", timeout, 0.))
return kERR;
324 int irc = port.
RawRead(rdata.data(), rdata.size(),
false,
Rtime(timeout),
329 if (irc < 0)
return args.
Quit(emsg);
348 vector<uint8_t> rdata;
349 vector<uint8_t> edata;
350 vector<uint8_t> emask;
353 if (!args.
GetArg(
"bsize", rsize, 1, 4096))
return kERR;
354 if (!args.
GetArg(
"??varData", rvname))
return kERR;
358 while (args.
NextOpt(opt, optset)) {
359 if (opt ==
"-edata") {
360 if (!args.
GetArg(
"data", edata, 0, rsize))
return kERR;
361 if (!args.
GetArg(
"??mask", emask, 0, rsize))
return kERR;
362 }
else if (opt ==
"-timeout") {
363 if (!args.
GetArg(
"tsec", timeout, 0.))
return kERR;
372 int irc = port.
RawRead(rdata.data(), rdata.size(),
true,
Rtime(timeout),
376 if (irc < 0)
return args.
Quit(emsg);
378 if (rvname.length()) {
384 for (
size_t i=0; i<rdata.size(); i++) {
385 if (i >= edata.size())
break;
386 uint8_t eval = edata[i];
387 uint8_t emsk = (i < emask.size()) ? emask[i] : 0x00;
388 if ((rdata[i]|emsk) != (eval|emsk)) nerr += 1;
390 if (nerr) errcnt += 1;
402 vector<uint8_t> wdata;
403 if (!args.
GetArg(
"data", wdata, 1, 4096))
return kERR;
406 int irc = port.
RawWrite(wdata.data(), wdata.size(), emsg);
407 if (irc !=
int(wdata.size()))
return args.
Quit(emsg);
const std::string & Text() const
FIXME_docs.
static RlinkPort::port_uptr_t Open(const std::string &url, RerrMsg &emsg)
FIXME_docs.
int RawRead(uint8_t *buf, size_t size, bool exactsize, const Rtime &timeout, Rtime &tused, RerrMsg &emsg)
FIXME_docs.
int RawWrite(const uint8_t *buf, size_t size, RerrMsg &emsg)
FIXME_docs.
static const int kEof
return code: end-of-file
void SetTraceLevel(uint32_t level)
FIXME_docs.
static const int kTout
return code: time out
uint32_t TraceLevel() const
FIXME_docs.
bool NextOpt(std::string &val)
FIXME_docs.
void AppendResultLines(const std::string &str)
FIXME_docs.
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
void AppendResult(const char *str,...)
FIXME_docs.
bool OptValid() const
FIXME_docs.
int Quit(const std::string &str)
FIXME_docs.
void SetResult(const std::string &str)
FIXME_docs.
size_t NOptMiss() const
FIXME_docs.
Tcl_Interp * Interp() const
FIXME_docs.
bool AllDone()
FIXME_docs.
void AddMeth(const std::string &name, methfo_t &&methfo)
FIXME_docs.
bool GetArgsDump(RtclArgs &args, int &detail)
FIXME_docs.
int M_get(RtclArgs &args)
FIXME_docs.
void Add(const std::string &name, get_uptr_t &&upget)
FIXME_docs.
Implemenation (inline) of RtclOPtr.
void CreateObjectCmd(Tcl_Interp *interp, const char *name)
FIXME_docs.
int M_errcnt(RtclArgs &args)
FIXME_docs.
int M_dump(RtclArgs &args)
FIXME_docs.
int M_log(RtclArgs &args)
FIXME_docs.
int M_rawread(RtclArgs &args)
FIXME_docs.
static int DoRawWblk(RtclArgs &args, RlinkPort &port)
FIXME_docs.
int M_open(RtclArgs &args)
FIXME_docs.
const std::string & LogFileName() const
FIXME_docs.
bool TestPort(RtclArgs &args, bool testopen=true)
FIXME_docs.
static int DoRawRblk(RtclArgs &args, RlinkPort &port, size_t &errcnt)
FIXME_docs.
int M_default(RtclArgs &args)
FIXME_docs.
int M_rawrblk(RtclArgs &args)
FIXME_docs.
int M_rawwblk(RtclArgs &args)
FIXME_docs.
RlinkPort::port_uptr_t fupObj
uptr to managed port
size_t fErrCnt
error count
RtclRlinkPort(Tcl_Interp *interp, const char *name)
Default constructor.
~RtclRlinkPort()
Destructor.
std::shared_ptr< RlogFile > fspLog
port log file
int M_close(RtclArgs &args)
FIXME_docs.
int M_stats(RtclArgs &args)
FIXME_docs.
void SetupGetSet()
FIXME_docs.
static int DoRawRead(RtclArgs &args, RlinkPort &port)
FIXME_docs.
int M_get(RtclArgs &args)
FIXME_docs.
uint32_t fTraceLevel
0=off,1=buf,2=char
int M_set(RtclArgs &args)
FIXME_docs.
void SetLogFileName(const std::string &name)
FIXME_docs.
void Add(const std::string &name, set_uptr_t &&upset)
FIXME_docs.
int M_set(RtclArgs &args)
FIXME_docs.
static bool Exec(RtclArgs &args, const Context &cntx, Rstats &stats)
FIXME_docs.
static bool GetArgs(RtclArgs &args, Context &cntx)
FIXME_docs.
bool SetVar(Tcl_Interp *interp, const std::string &varname, Tcl_Obj *pobj)
Tcl_Obj * NewListIntObj(const uint8_t *data, size_t size)
Declaration of class ReventLoop.