diff --git a/src/clientget.cpp b/src/clientget.cpp index 2ba14ff..5ba563b 100644 --- a/src/clientget.cpp +++ b/src/clientget.cpp @@ -188,12 +188,12 @@ void Connection::handle_GPR(pva_app_msg_t cmd) // INIT of PUT or GET, store type description info->prototype = data; - } else if(M.good() && cmd!=CMD_RPC && !init && sts.isSuccess()) { - // GET/PUT reply + } else if(M.good() && cmd==CMD_GET && !init && sts.isSuccess()) { + // GET reply data = info->prototype.cloneEmpty(); if(data) - from_wire_full(M, rxRegistry, data); + from_wire_valid(M, rxRegistry, data); } } @@ -224,7 +224,7 @@ void Connection::handle_GPR(pva_app_msg_t cmd) } else if(gpr->state==GPROp::GetOPut && !get) { M.fault(); - } else if(gpr->state!=GPROp::Exec) { + } else if(gpr->state!=GPROp::Exec && gpr->state!=GPROp::Creating) { M.fault(); } } @@ -337,7 +337,7 @@ std::shared_ptr GetBuilder::_exec_get() auto op = std::make_shared(Operation::Get, chan); op->done = std::move(_result); - // TODO pvRequest + op->pvRequest = _build(); chan->pending.push_back(op); chan->createOperations(); @@ -362,7 +362,7 @@ std::shared_ptr PutBuilder::exec() op->done = std::move(_result); op->builder = std::move(_builder); op->getOput = _doGet; - // TODO pvRequest + op->pvRequest = _build(); chan->pending.push_back(op); chan->createOperations(); @@ -383,7 +383,7 @@ std::shared_ptr RPCBuilder::exec() auto op = std::make_shared(Operation::Put, chan); op->done = std::move(_result); op->rpcarg = std::move(_argument); - // TODO pvRequest + op->pvRequest = _build(); chan->pending.push_back(op); chan->createOperations(); diff --git a/tools/Makefile b/tools/Makefile index 49ca932..d7a90dd 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -16,6 +16,9 @@ pvxvct_SRCS += pvxvct.cpp PROD += pvxinfo pvxinfo_SRCS += info.cpp +PROD += pvxget +pvxget_SRCS += get.cpp + PROD_SYS_LIBS += event_core PROD_SYS_LIBS_DEFAULT += event_pthreads diff --git a/tools/get.cpp b/tools/get.cpp new file mode 100644 index 0000000..57bc862 --- /dev/null +++ b/tools/get.cpp @@ -0,0 +1,108 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * pvxs is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include "utilpvt.h" + +using namespace pvxs; + +namespace { + +void usage(const char* argv0) +{ + std::cerr<<"Usage: "< [pvname ...]\n" + "\n" + " -h Show this message.\n" + " -v Make more noise.\n" + " -d Shorthand for $PVXS_LOG=\"pvxs.*=DEBUG\". Make a lot of noise.\n" + " -w Operation timeout in seconds. default 5 sec.\n" + ; +} + +} + +int main(int argc, char *argv[]) +{ + logger_config_env(); // from $PVXS_LOG + double timeout = 5.0; + bool verbose = false; + + { + int opt; + while ((opt = getopt(argc, argv, "hvdw:")) != -1) { + switch(opt) { + case 'h': + usage(argv[0]); + return 0; + case 'v': + verbose = true; + break; + case 'd': + logger_level_set("pvxs.*", Level::Debug); + break; + case 'w': + if(epicsParseDouble(optarg, &timeout, nullptr)) { + std::cerr<<"Invalid timeout value: "<> ops; + + std::atomic remaining{argc-optind}; + epicsEvent done; + + for(auto n : range(optind, argc)) { + + ops.push_back(ctxt.get(argv[n]) + .result([&argv, n, &remaining, &done](client::Result&& result) { + std::cout<