ebusdump merged into ebusctl.
This commit is contained in:
@@ -13,4 +13,3 @@
|
|||||||
*.o
|
*.o
|
||||||
*.dirstamp
|
*.dirstamp
|
||||||
/ebusctl
|
/ebusctl
|
||||||
/ebusdump
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
ebusd - ChangeLog
|
ebusd - ChangeLog
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
2014-06-26 Roland Jax <roland.jax@liwest.at>
|
||||||
|
* ebusdump merged into ebusctl.
|
||||||
|
|
||||||
2014-06-25 Roland Jax <roland.jax@liwest.at>
|
2014-06-25 Roland Jax <roland.jax@liwest.at>
|
||||||
* ebusctl added (includes ebusd_scan and ebusd_send)
|
* ebusctl added (includes ebusd_scan and ebusd_send)
|
||||||
* Version changed from 0.2.1 to 0.3.0
|
* Version changed from 0.2.1 to 0.3.0
|
||||||
|
|||||||
+1
-8
@@ -5,8 +5,7 @@ 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 \
|
||||||
ebusctl \
|
ebusctl
|
||||||
ebusdump
|
|
||||||
|
|
||||||
ebusd_SOURCES = src/main.cpp \
|
ebusd_SOURCES = src/main.cpp \
|
||||||
src/baseloop.cpp \
|
src/baseloop.cpp \
|
||||||
@@ -31,9 +30,3 @@ ebusctl_SOURCES = tools/ebusctl.cpp \
|
|||||||
|
|
||||||
ebusctl_LDADD = $(LIBEBUS_LIBS)
|
ebusctl_LDADD = $(LIBEBUS_LIBS)
|
||||||
|
|
||||||
|
|
||||||
ebusdump_SOURCES = tools/ebusdump.cpp \
|
|
||||||
lib/appl.cpp
|
|
||||||
|
|
||||||
ebusdump_LDADD = $(LIBEBUS_LIBS)
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
ebusd - NEWS
|
ebusd - NEWS
|
||||||
------------
|
------------
|
||||||
|
|
||||||
2014-06-25 Roland Jax <roland.jax@liwest.at>
|
2014-06-26 Roland Jax <roland.jax@liwest.at>
|
||||||
* ebusctl added (includes ebusd_scan and ebusd_send)
|
* ebusctl added (includes ebusd_scan and ebusd_send)
|
||||||
|
* ebusdump merged into ebusctl.
|
||||||
* Version changed from 0.2.1 to 0.3.0
|
* 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>
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ See ./ebusd -h
|
|||||||
Tools
|
Tools
|
||||||
-----
|
-----
|
||||||
|
|
||||||
ebusctl - client for ebusd.
|
ebusctl - client program for ebusd.
|
||||||
ebusdump - send dump files (virtual serial device) to server for development.
|
|
||||||
|
|
||||||
|
|
||||||
For usage and further information take a look on help page.
|
For usage and further information take a look on help page.
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ void Appl::printArgs()
|
|||||||
if (m_argTxt.size() != 0)
|
if (m_argTxt.size() != 0)
|
||||||
std::cerr << " " << m_argTxt;
|
std::cerr << " " << m_argTxt;
|
||||||
|
|
||||||
std::cerr << std::endl << std::endl;
|
std::cerr << std::endl << std::endl << "Options:" << std::endl << std::endl;
|
||||||
|
|
||||||
for (a_it = m_args.begin(); a_it < m_args.end(); a_it++) {
|
for (a_it = m_args.begin(); a_it < m_args.end(); a_it++) {
|
||||||
const char* c = (strlen(a_it->shortname) == 1) ? a_it->shortname : " ";
|
const char* c = (strlen(a_it->shortname) == 1) ? a_it->shortname : " ";
|
||||||
|
|||||||
+69
-19
@@ -21,9 +21,12 @@
|
|||||||
#include "appl.h"
|
#include "appl.h"
|
||||||
#include "tcpsocket.h"
|
#include "tcpsocket.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace libebus;
|
using namespace libebus;
|
||||||
|
|
||||||
@@ -33,10 +36,24 @@ void define_args()
|
|||||||
{
|
{
|
||||||
A.addArgs("COMMAND {ARGS...}\n\n"
|
A.addArgs("COMMAND {ARGS...}\n\n"
|
||||||
" local commands:\n"
|
" local commands:\n"
|
||||||
" 'scan' scans the bus and identifies the participant\n\n"
|
" 'scan' scans the bus and identifies the participants\n\n"
|
||||||
|
" 'feed' sends a dump file to a local virtual serial device\n"
|
||||||
|
" (hint: socat -d -d pty,raw,echo=0 pty,raw,echo=0)\n\n"
|
||||||
" remote commands:\n"
|
" remote commands:\n"
|
||||||
" send 'help' to server", 1);
|
" send 'help' to server", 1);
|
||||||
|
|
||||||
|
A.addItem("p_device", Appl::Param("/dev/ttyUSB60"), "d", "device",
|
||||||
|
"virtual serial device (/dev/ttyUSB60)",
|
||||||
|
Appl::type_string, Appl::opt_mandatory);
|
||||||
|
|
||||||
|
A.addItem("p_file", Appl::Param(""), "f", "file",
|
||||||
|
"dump file with raw data",
|
||||||
|
Appl::type_string, Appl::opt_mandatory);
|
||||||
|
|
||||||
|
A.addItem("p_time", Appl::Param(10000), "t", "time",
|
||||||
|
"delay between 2 bytes in 'us' (10000)\n",
|
||||||
|
Appl::type_long, Appl::opt_mandatory);
|
||||||
|
|
||||||
A.addItem("p_server", Appl::Param("localhost"), "s", "server",
|
A.addItem("p_server", Appl::Param("localhost"), "s", "server",
|
||||||
"name or ip (localhost)",
|
"name or ip (localhost)",
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
Appl::type_string, Appl::opt_mandatory);
|
||||||
@@ -163,30 +180,44 @@ int main(int argc, char* argv[])
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
addManufacturer();
|
if (strcasecmp(A.getArg(0).c_str(), "feed") == 0) {
|
||||||
|
std::string dev(A.getParam<const char*>("p_device"));
|
||||||
|
Port port(dev, true);
|
||||||
|
|
||||||
|
port.open();
|
||||||
|
if(port.isOpen() == true)
|
||||||
|
std::cout << "openPort successful." << std::endl;
|
||||||
|
|
||||||
|
std::fstream file(A.getParam<const char*>("p_file"), std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
|
if(file.is_open() == true) {
|
||||||
|
|
||||||
|
while (file.eof() == false) {
|
||||||
|
unsigned char byte = file.get();
|
||||||
|
std::cout << std::hex << std::setw(2) << std::setfill('0')
|
||||||
|
<< static_cast<unsigned>(byte) << std::endl;
|
||||||
|
|
||||||
|
port.send(&byte, 1);
|
||||||
|
usleep(A.getParam<long>("p_time"));
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
port.close();
|
||||||
|
if(port.isOpen() == false)
|
||||||
|
std::cout << "closePort successful." << std::endl;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
TCPClient* client = new TCPClient();
|
TCPClient* client = new TCPClient();
|
||||||
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) {
|
||||||
if (strcasecmp(A.getArg(0).c_str(), "scan") != 0) {
|
|
||||||
// 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());
|
if (strcasecmp(A.getArg(0).c_str(), "scan") == 0) {
|
||||||
|
addManufacturer();
|
||||||
|
|
||||||
char data[1024];
|
|
||||||
size_t datalen;
|
|
||||||
|
|
||||||
datalen = socket->recv(data, sizeof(data)-1);
|
|
||||||
data[datalen] = '\0';
|
|
||||||
|
|
||||||
std::cout << data;
|
|
||||||
} else {
|
|
||||||
// send command to all slaves
|
// send command to all slaves
|
||||||
for (size_t i = 0; i < s.size(); i++) {
|
for (size_t i = 0; i < s.size(); i++) {
|
||||||
// build message
|
// build message
|
||||||
@@ -196,7 +227,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
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);
|
||||||
@@ -229,6 +260,23 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 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 socket;
|
||||||
@@ -236,6 +284,8 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
delete client;
|
delete client;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +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 "libebus.h"
|
|
||||||
#include "appl.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
using namespace libebus;
|
|
||||||
|
|
||||||
Appl& A = Appl::Instance();
|
|
||||||
|
|
||||||
void define_args()
|
|
||||||
{
|
|
||||||
A.addArgs("", 0);
|
|
||||||
|
|
||||||
A.addItem("p_device", Appl::Param("/dev/ttyUSB60"), "d", "device",
|
|
||||||
"dummy serial device (/dev/ttyUSB60)\n\t\t(hint: socat -d -d pty,raw,echo=0 pty,raw,echo=0)",
|
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_file", Appl::Param(""), "f", "file",
|
|
||||||
"dump file with raw data",
|
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
|
||||||
|
|
||||||
A.addItem("p_time", Appl::Param(10000), "t", "time",
|
|
||||||
"wait time [ms] (10000)\n",
|
|
||||||
Appl::type_long, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string dev(A.getParam<const char*>("p_device"));
|
|
||||||
Port port(dev, true);
|
|
||||||
|
|
||||||
port.open();
|
|
||||||
if(port.isOpen() == true)
|
|
||||||
std::cout << "openPort successful." << std::endl;
|
|
||||||
|
|
||||||
std::fstream file(A.getParam<const char*>("p_file"), std::ios::in | std::ios::binary);
|
|
||||||
|
|
||||||
if(file.is_open() == true) {
|
|
||||||
|
|
||||||
while (file.eof() == false) {
|
|
||||||
unsigned char byte = file.get();
|
|
||||||
std::cout << std::hex << std::setw(2) << std::setfill('0')
|
|
||||||
<< static_cast<unsigned>(byte) << std::endl;
|
|
||||||
|
|
||||||
port.send(&byte, 1);
|
|
||||||
usleep(A.getParam<long>("p_time"));
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
port.close();
|
|
||||||
if(port.isOpen() == false)
|
|
||||||
std::cout << "closePort successful." << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user