ebusctl added. Version changed from 0.2.1 to 0.3.0
This commit is contained in:
+2
-3
@@ -12,6 +12,5 @@
|
|||||||
.deps/
|
.deps/
|
||||||
*.o
|
*.o
|
||||||
*.dirstamp
|
*.dirstamp
|
||||||
/ebusd_feed
|
/ebusctl
|
||||||
/ebusd_send
|
/ebusdump
|
||||||
/ebusd_scan
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
ebusd - ChangeLog
|
ebusd - ChangeLog
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
2014-06-25 Roland Jax <roland.jax@liwest.at>
|
||||||
|
* ebusctl added (includes ebusd_scan and ebusd_send)
|
||||||
|
* Version changed from 0.2.1 to 0.3.0
|
||||||
|
|
||||||
2014-06-22 Roland Jax <roland.jax@liwest.at>
|
2014-06-22 Roland Jax <roland.jax@liwest.at>
|
||||||
* 'stop' daemon command added.
|
* 'stop' daemon command added.
|
||||||
|
|
||||||
|
|||||||
+11
-13
@@ -5,9 +5,8 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
|||||||
AM_CXXFLAGS = $(LIBEBUS_CFLAGS) -I$(top_srcdir)/lib -fpic -Wall -Wextra
|
AM_CXXFLAGS = $(LIBEBUS_CFLAGS) -I$(top_srcdir)/lib -fpic -Wall -Wextra
|
||||||
|
|
||||||
bin_PROGRAMS = ebusd \
|
bin_PROGRAMS = ebusd \
|
||||||
ebusd_feed \
|
ebusctl \
|
||||||
ebusd_send \
|
ebusdump
|
||||||
ebusd_scan
|
|
||||||
|
|
||||||
ebusd_SOURCES = src/main.cpp \
|
ebusd_SOURCES = src/main.cpp \
|
||||||
src/baseloop.cpp \
|
src/baseloop.cpp \
|
||||||
@@ -25,17 +24,16 @@ ebusd_LDADD = $(LIBEBUS_LIBS) \
|
|||||||
|
|
||||||
dist_noinst_SCRIPTS = autogen.sh
|
dist_noinst_SCRIPTS = autogen.sh
|
||||||
|
|
||||||
ebusd_feed_SOURCES = tools/ebusd_feed.cpp \
|
|
||||||
lib/appl.cpp
|
|
||||||
|
|
||||||
ebusd_feed_LDADD = $(LIBEBUS_LIBS)
|
ebusctl_SOURCES = tools/ebusctl.cpp \
|
||||||
|
lib/appl.cpp \
|
||||||
|
lib/tcpsocket.cpp
|
||||||
|
|
||||||
ebusd_send_SOURCES = tools/ebusd_send.cpp \
|
ebusctl_LDADD = $(LIBEBUS_LIBS)
|
||||||
lib/appl.cpp \
|
|
||||||
lib/tcpsocket.cpp
|
|
||||||
|
|
||||||
ebusd_scan_SOURCES = tools/ebusd_scan.cpp \
|
|
||||||
lib/appl.cpp \
|
|
||||||
lib/tcpsocket.cpp
|
|
||||||
|
|
||||||
ebusd_scan_LDADD = $(LIBEBUS_LIBS)
|
ebusdump_SOURCES = tools/ebusdump.cpp \
|
||||||
|
lib/appl.cpp
|
||||||
|
|
||||||
|
ebusdump_LDADD = $(LIBEBUS_LIBS)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
ebusd - NEWS
|
ebusd - NEWS
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
2014-06-25 Roland Jax <roland.jax@liwest.at>
|
||||||
|
* ebusctl added (includes ebusd_scan and ebusd_send)
|
||||||
|
* Version changed from 0.2.1 to 0.3.0
|
||||||
|
|
||||||
2014-06-03 Roland Jax <roland.jax@liwest.at>
|
2014-06-03 Roland Jax <roland.jax@liwest.at>
|
||||||
* ebusd_send, ebusd_scan added.
|
* ebusd_send, ebusd_scan added.
|
||||||
* Version changed from 0.2.0 to 0.2.1
|
* Version changed from 0.2.0 to 0.2.1
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ See ./ebusd -h
|
|||||||
Tools
|
Tools
|
||||||
-----
|
-----
|
||||||
|
|
||||||
ebusd_feed - send dump files via virtual serial device for debugging purpose.
|
ebusctl - client for ebusd.
|
||||||
ebusd_send - small client for sending commands to ebusd.
|
ebusdump - send dump files (virtual serial device) to server for development.
|
||||||
ebusd_scan - scans the bus and identifies the participant.
|
|
||||||
|
|
||||||
For usage and further information take a look on help page.
|
For usage and further information take a look on help page.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
AC_PREREQ([2.65])
|
AC_PREREQ([2.65])
|
||||||
AC_INIT([ebusd], [0.2.1], [roland.jax@liwest.at], [ebusd], [https://github.com/yuhu-/ebusd])
|
AC_INIT([ebusd], [0.3.0], [roland.jax@liwest.at], [ebusd], [https://github.com/yuhu-/ebusd])
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([src/main.cpp])
|
AC_CONFIG_SRCDIR([src/main.cpp])
|
||||||
AC_CONFIG_AUX_DIR([build])
|
AC_CONFIG_AUX_DIR([build])
|
||||||
|
|||||||
@@ -29,6 +29,28 @@ using namespace libebus;
|
|||||||
|
|
||||||
Appl& A = Appl::Instance();
|
Appl& A = Appl::Instance();
|
||||||
|
|
||||||
|
void define_args()
|
||||||
|
{
|
||||||
|
A.addArgs("COMMAND {ARGS...}\n\n"
|
||||||
|
" local commands:\n"
|
||||||
|
" 'scan' scans the bus and identifies the participant\n\n"
|
||||||
|
" remote commands:\n"
|
||||||
|
" send 'help' to server", 1);
|
||||||
|
|
||||||
|
A.addItem("p_server", Appl::Param("localhost"), "s", "server",
|
||||||
|
"name or ip (localhost)",
|
||||||
|
Appl::type_string, Appl::opt_mandatory);
|
||||||
|
|
||||||
|
A.addItem("p_port", Appl::Param(8888), "p", "port",
|
||||||
|
"port (8888)\n",
|
||||||
|
Appl::type_int, Appl::opt_mandatory);
|
||||||
|
|
||||||
|
A.addItem("p_help", Appl::Param(false), "h", "help",
|
||||||
|
"print this message",
|
||||||
|
Appl::type_bool, Appl::opt_none);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, size_t N>T * end(T (&ra)[N]) { return ra + N; }
|
template<typename T, size_t N>T * end(T (&ra)[N]) { return ra + N; }
|
||||||
|
|
||||||
const char *sinit[] = {"02", "04", "05", "06", "08", "09", "0A", "0B", "0C",
|
const char *sinit[] = {"02", "04", "05", "06", "08", "09", "0A", "0B", "0C",
|
||||||
@@ -90,23 +112,6 @@ static void addManufacturer()
|
|||||||
manufacturer.insert(std::make_pair("b5", "Joh. Vaillant GmbH & Co."));
|
manufacturer.insert(std::make_pair("b5", "Joh. Vaillant GmbH & Co."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void define_args()
|
|
||||||
{
|
|
||||||
A.addArgs("", 0);
|
|
||||||
|
|
||||||
A.addItem("p_server", Appl::Param("localhost"), "s", "server",
|
|
||||||
"name or ip (localhost)",
|
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_port", Appl::Param(8888), "p", "port",
|
|
||||||
"port (8888)\n",
|
|
||||||
Appl::type_int, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_help", Appl::Param(false), "h", "help",
|
|
||||||
"print this message",
|
|
||||||
Appl::type_bool, Appl::opt_none);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scanVaillant(TCPSocket* socket, const std::string address)
|
void scanVaillant(TCPSocket* socket, const std::string address)
|
||||||
{
|
{
|
||||||
Decode* help = NULL;
|
Decode* help = NULL;
|
||||||
@@ -140,6 +145,7 @@ void scanVaillant(TCPSocket* socket, const std::string address)
|
|||||||
std::cout << " s/n: '" << sstr.str().substr(1,28) << "' item: '" << sstr.str().substr(7,10) << "'";
|
std::cout << " s/n: '" << sstr.str().substr(1,28) << "' item: '" << sstr.str().substr(7,10) << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// define Arguments and Application variables
|
// define Arguments and Application variables
|
||||||
@@ -163,47 +169,66 @@ int main(int argc, char* argv[])
|
|||||||
TCPSocket* socket = client->connect(A.getParam<const char*>("p_server"), A.getParam<int>("p_port"));
|
TCPSocket* socket = client->connect(A.getParam<const char*>("p_server"), A.getParam<int>("p_port"));
|
||||||
|
|
||||||
if (socket != NULL) {
|
if (socket != NULL) {
|
||||||
// send command to all slaves
|
if (strcasecmp(A.getArg(0).c_str(), "scan") != 0) {
|
||||||
for (size_t i = 0; i < s.size(); i++) {
|
|
||||||
// build message
|
// build message
|
||||||
std::string message("hex ms ");
|
std::string message(A.getArg(0));
|
||||||
message += s[i];
|
for (size_t i = 1; i < A.numArg(); i++) {
|
||||||
message += "070400";
|
message += " ";
|
||||||
|
message += A.getArg(i);
|
||||||
|
}
|
||||||
|
|
||||||
socket->send(message.c_str(), message.size());
|
socket->send(message.c_str(), message.size());
|
||||||
|
|
||||||
char data[256];
|
char data[1024];
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
|
|
||||||
datalen = socket->recv(data, sizeof(data)-1);
|
datalen = socket->recv(data, sizeof(data)-1);
|
||||||
data[datalen] = '\0';
|
data[datalen] = '\0';
|
||||||
|
|
||||||
// decode answer
|
std::cout << data;
|
||||||
if (strncmp(&data[0], "-", 1) != 0) {
|
} else {
|
||||||
std::string item(data);
|
// send command to all slaves
|
||||||
|
for (size_t i = 0; i < s.size(); i++) {
|
||||||
|
// build message
|
||||||
|
std::string message("hex ms ");
|
||||||
|
message += s[i];
|
||||||
|
message += "070400";
|
||||||
|
|
||||||
std::ostringstream ident;
|
socket->send(message.c_str(), message.size());
|
||||||
Decode* help = NULL;
|
|
||||||
|
|
||||||
help = new DecodeSTR(item.substr(18,10));
|
char data[256];
|
||||||
ident << help->decode();
|
size_t datalen;
|
||||||
delete help;
|
|
||||||
|
|
||||||
std::cout << s[i] << ": '" << manufacturer.find(item.substr(16,2))->second
|
datalen = socket->recv(data, sizeof(data)-1);
|
||||||
<< "' ident: '" << std::setw(5) << std::setfill(' ') << ident.str()
|
data[datalen] = '\0';
|
||||||
<< "' sw: '" << item.substr(28,2)
|
|
||||||
<< "." << item.substr(30,2)
|
|
||||||
<< "' hw: '" << item.substr(32,2)
|
|
||||||
<< "." << item.substr(34,2)
|
|
||||||
<< "'";
|
|
||||||
|
|
||||||
if (item.substr(16,2) == "b5")
|
// decode answer
|
||||||
scanVaillant(socket, s[i]);
|
if (strncmp(&data[0], "-", 1) != 0) {
|
||||||
|
std::string item(data);
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::ostringstream ident;
|
||||||
|
Decode* help = NULL;
|
||||||
|
|
||||||
|
help = new DecodeSTR(item.substr(18,10));
|
||||||
|
ident << help->decode();
|
||||||
|
delete help;
|
||||||
|
|
||||||
|
std::cout << s[i] << ": '" << manufacturer.find(item.substr(16,2))->second
|
||||||
|
<< "' ident: '" << std::setw(5) << std::setfill(' ') << ident.str()
|
||||||
|
<< "' sw: '" << item.substr(28,2)
|
||||||
|
<< "." << item.substr(30,2)
|
||||||
|
<< "' hw: '" << item.substr(32,2)
|
||||||
|
<< "." << item.substr(34,2)
|
||||||
|
<< "'";
|
||||||
|
|
||||||
|
if (item.substr(16,2) == "b5")
|
||||||
|
scanVaillant(socket, s[i]);
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Roland Jax 2012-2014 <roland.jax@liwest.at>
|
|
||||||
*
|
|
||||||
* This file is part of ebusd.
|
|
||||||
*
|
|
||||||
* ebusd is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* ebusd is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with ebusd. If not, see http://www.gnu.org/licenses/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "appl.h"
|
|
||||||
#include "tcpsocket.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
Appl& A = Appl::Instance();
|
|
||||||
|
|
||||||
void define_args()
|
|
||||||
{
|
|
||||||
A.addArgs("COMMAND {ARGS...}\n\n"
|
|
||||||
" send 'help' for available commands", 1);
|
|
||||||
|
|
||||||
A.addItem("p_server", Appl::Param("localhost"), "s", "server",
|
|
||||||
"name or ip (localhost)",
|
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_port", Appl::Param(8888), "p", "port",
|
|
||||||
"port (8888)\n",
|
|
||||||
Appl::type_int, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_help", Appl::Param(false), "h", "help",
|
|
||||||
"print this message",
|
|
||||||
Appl::type_bool, Appl::opt_none);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
// define Arguments and Application variables
|
|
||||||
define_args();
|
|
||||||
|
|
||||||
// parse Arguments
|
|
||||||
if (A.parseArgs(argc, argv) == false) {
|
|
||||||
A.printArgs();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// print Help
|
|
||||||
if (A.getParam<bool>("p_help") == true) {
|
|
||||||
A.printArgs();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
TCPClient* client = new TCPClient();
|
|
||||||
TCPSocket* socket = client->connect(A.getParam<const char*>("p_server"), A.getParam<int>("p_port"));
|
|
||||||
|
|
||||||
if (socket != NULL) {
|
|
||||||
// build message
|
|
||||||
std::string message(A.getArg(0));
|
|
||||||
for (size_t i = 1; i < A.numArg(); i++) {
|
|
||||||
message += " ";
|
|
||||||
message += A.getArg(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
socket->send(message.c_str(), message.size());
|
|
||||||
|
|
||||||
char data[1024];
|
|
||||||
size_t datalen;
|
|
||||||
|
|
||||||
datalen = socket->recv(data, sizeof(data)-1);
|
|
||||||
data[datalen] = '\0';
|
|
||||||
|
|
||||||
std::cout << data;
|
|
||||||
|
|
||||||
delete socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete client;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user