231 putenv(const_cast<char*>(
"POSIXLY_CORRECT="));
233 while ((opt =
getopt(argc, argv,
":hvVM:r:w:tp:qdF:f:ns")) != -1) {
239 outmode = pvd::PVStructure::Formatter::Raw;
243 fprintf(
stdout,
"pvAccess %u.%u.%u%s\n",
244 EPICS_PVA_MAJOR_VERSION,
245 EPICS_PVA_MINOR_VERSION,
246 EPICS_PVA_MAINTENANCE_VERSION,
247 (EPICS_PVA_DEVELOPMENT_FLAG)?
"-SNAPSHOT":
"");
248 fprintf(
stdout,
"pvData %u.%u.%u%s\n",
249 EPICS_PVD_MAJOR_VERSION,
250 EPICS_PVD_MINOR_VERSION,
251 EPICS_PVD_MAINTENANCE_VERSION,
252 (EPICS_PVD_DEVELOPMENT_FLAG)?
"-SNAPSHOT":
"");
253 fprintf(
stdout,
"Base %s\n", EPICS_VERSION_FULL);
257 if(strcmp(
optarg,
"raw")==0) {
258 outmode = pvd::PVStructure::Formatter::Raw;
259 }
else if(strcmp(
optarg,
"nt")==0) {
260 outmode = pvd::PVStructure::Formatter::NT;
261 }
else if(strcmp(
optarg,
"json")==0) {
262 outmode = pvd::PVStructure::Formatter::JSON;
265 outmode = pvd::PVStructure::Formatter::Raw;
273 fprintf(
stderr,
"'%s' is not a valid timeout value " 274 "- ignored. ('pvput -h' for help.)\n",
optarg);
298 fprintf(
stderr,
"Unsupported option -f\n");
306 "Unrecognized option: '-%c'. ('pvput -h' for help.)\n",
311 "Option '-%c' requires an argument. ('pvput -h' for help.)\n",
322 fprintf(
stderr,
"No pv name specified. ('pvput -h' for help.)\n");
328 std::string pvName(pv);
330 int nVals = argc -
optind;
333 fprintf(
stderr,
"No value(s) specified. ('pvput -h' for help.)\n");
337 std::vector<std::string> values;
339 for (
int n = 0; optind < argc; n++, optind++)
340 values.push_back(argv[optind]);
344 for(
size_t i=0, N=values.size();
i<N;
i++)
346 size_t sep = values[
i].find_first_of(
'=');
347 if(sep==std::string::npos) {
348 thework.bare.push_back(values[
i]);
350 thework.pairs.push_back(std::make_pair(values[
i].substr(0, sep),
351 values[
i].substr(sep+1)));
355 if(!thework.bare.empty() && !thework.pairs.empty()) {
357 fprintf(
stderr,
"\nCan't mix bare values and field=value pairs\n");
360 }
else if(thework.bare.size()==1 && thework.bare[0][0]==
'[') {
362 thework.pairs.push_back(std::make_pair(
"value", thework.bare[0]));
363 thework.bare.clear();
366 pvd::PVStructure::shared_pointer pvRequest;
369 }
catch(std::exception& e){
370 fprintf(
stderr,
"failed to parse request string: %s\n", e.what());
376 std::cout << std::boolalpha;
385 std::cout <<
"Old : ";
386 printValue(pvName, chan.get(
timeout, pvRequest));
393 while(!thework.done) {
395 if(!thework.wait.wait(
timeout)) {
396 fprintf(
stderr,
"Put timeout\n");
403 fprintf(
stderr,
"Error: %s\n", thework.message.c_str());
407 std::cout <<
"New : ";
409 printValue(pvName, chan.get(
timeout, pvRequest));
412 }
catch(std::exception& e) {
413 std::cerr<<
"Error: "<<e.what()<<
"\n";
int getopt(int nargc, char *const *nargv, const char *ostr)
#define SET_LOG_LEVEL(level)
#define epicsScanDouble(str, to)
PVStructure::shared_pointer createRequest(std::string const &request)
Handle for in-progress get/put/rpc operation.
request ends in failure. Check message
ChannelPut::shared_pointer op
static void start()
start provider ca
std::string defaultProvider
pvd::PVStructure::Formatter::format_t outmode