From 70609f1b0398a1e2e2bff93b2beab36b34fc2c9c Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 31 Jan 2015 19:04:14 +0100 Subject: [PATCH] added state command, nicer help --- src/ebusd/mainloop.cpp | 41 ++++++++++++++++++++++++++--------------- src/ebusd/mainloop.h | 7 +++++++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index 1a5b33a7..fad44d97 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -167,6 +167,8 @@ string MainLoop::decodeMessage(const string& data, bool& listening) return executeFind(args); if (strcasecmp(str, "L") == 0 || strcasecmp(str, "LISTEN") == 0) return executeListen(args, listening); + if (strcasecmp(str, "STATE") == 0) + return executeState(); if (strcasecmp(str, "SCAN") == 0) return executeScan(args); if (strcasecmp(str, "LOG") == 0) @@ -467,6 +469,14 @@ string MainLoop::executeListen(vector &args, bool& listening) return "listen stopped"; } +string MainLoop::executeState() +{ + if (m_busHandler->hasSignal() == true) + return "signal acquired"; + + return "no signal"; +} + string MainLoop::executeScan(vector &args) { if (args.size() <= 1) { @@ -553,21 +563,22 @@ string MainLoop::executeReload(vector &args) string MainLoop::executeHelp() { return "commands:\n" - " read - read ebus values 'read [-v] [-f] [-m seconds] [-c class] name [field]'\n" - " write - write ebus values 'write class name value[;value]*' or 'write -h ZZPBSBNNDx'\n" - " find - find ebus values 'find [-v] [-r] [-w] [-p] [-d] [-c class] [name]'\n" - " listen - listen for updates 'listen [stop]'\n" - " scan - scan ebus known addresses 'scan'\n" - " - scan ebus all addresses 'scan full'\n" - " - show scan results 'scan result'\n" - " log - change log areas 'log areas area,area,..' (area: main|network|bus|update|all)\n" - " - change log level 'log level level' (level: error|notice|info|debug)\n" - " raw - toggle log raw data 'raw'\n" - " dump - toggle dump state 'dump'\n" - " reload - reload ebus configuration 'reload'\n" - " stop - stop daemon 'stop'\n" - " quit - close connection 'quit'\n" - " help - print this page 'help'"; + " read read value(s) 'read [-v] [-f] [-m seconds] [-c class] name [field]'\n" + " write write value(s) 'write class name value[;value]*' or 'write -h ZZPBSBNNDx'\n" + " find find value(s) 'find [-v] [-r] [-w] [-p] [-d] [-c class] [name]'\n" + " listen listen for updates 'listen [stop]'\n" + " state report bus state 'state'\n" + " scan scan seen slaves 'scan'\n" + " scan all slaves 'scan full'\n" + " show scan results 'scan result'\n" + " log set log areas 'log areas area,area,..' (area: main|network|bus|update|all)\n" + " set log level 'log level level' (level: error|notice|info|debug)\n" + " raw toggle log raw data 'raw'\n" + " dump toggle dump state 'dump'\n" + " reload reload config files 'reload'\n" + " stop stop daemon 'stop'\n" + " quit close connection 'quit'\n" + " help print this page 'help'"; } string MainLoop::getUpdates(time_t since, time_t until) diff --git a/src/ebusd/mainloop.h b/src/ebusd/mainloop.h index 5e995071..a8663caf 100644 --- a/src/ebusd/mainloop.h +++ b/src/ebusd/mainloop.h @@ -126,6 +126,13 @@ private: */ string executeListen(vector &args, bool& listening); + /** + * Execute the state command. + * @param args the arguments passed to the command (starting with the command itself). + * @return the result string. + */ + string executeState(); + /** * Execute the scan command. * @param args the arguments passed to the command (starting with the command itself).