Merge branch 'local-dev'
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include <Poco/Net/HTTPServer.h>
|
||||
#include <Poco/Util/HelpFormatter.h>
|
||||
#include <Poco/JSON/Parser.h>
|
||||
#include <Poco/File.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -183,6 +182,8 @@ HTTPServer* FlippRServer::build_output_server()
|
||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
|
||||
|
||||
Poco::File socket_file(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
|
||||
if (socket_file.exists())
|
||||
socket_file.remove();
|
||||
|
||||
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
|
||||
ServerSocket server_socket(address);
|
||||
@@ -195,6 +196,12 @@ TCPServer* FlippRServer::build_input_server()
|
||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
|
||||
|
||||
Poco::File socket_file(this->get_runtime_dir() + INPUT_SOCKET_NAME);
|
||||
if (socket_file.exists())
|
||||
{
|
||||
socket_file.remove();
|
||||
logger().information("Seems that server is already running. Make sure that only one instance of server is running.");
|
||||
}
|
||||
|
||||
|
||||
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
|
||||
ServerSocket server_socket(address);
|
||||
@@ -262,7 +269,8 @@ void FlippRServer::handle_help(const std::string& name, const std::string& value
|
||||
|
||||
std::string FlippRServer::get_runtime_dir()
|
||||
{
|
||||
return std::getenv("XDG_RUNTIME_DIR") ? std::getenv("XDG_RUNTIME_DIR") : DEFAULT_RUNTIME_DIR;
|
||||
//return DEFAULT_RUNTIME_DIR;
|
||||
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Poco/Util/ServerApplication.h>
|
||||
#include <Poco/Net/HTTPServer.h>
|
||||
#include <Poco/Dynamic/Struct.h>
|
||||
#include <Poco/File.h>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -42,7 +43,7 @@ private:
|
||||
Poco::Net::TCPServer* build_input_server();
|
||||
|
||||
private:
|
||||
const char * DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/";
|
||||
const char * DEFAULT_RUNTIME_DIR = "/tmp/";
|
||||
const char * INPUT_SOCKET_NAME = "S.flippR_driver.in";
|
||||
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
||||
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
||||
@@ -62,6 +63,8 @@ private:
|
||||
std::unique_ptr<Poco::Net::HTTPServer> output_server;
|
||||
std::unique_ptr<Poco::Net::TCPServer> input_server;
|
||||
|
||||
Poco::File output_socket_file, input_socket_file;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
//
|
||||
// Created by johannes on 29.08.19.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
#define FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
|
||||
#include <Poco/Dynamic/VarHolder.h>
|
||||
#include <memory>
|
||||
|
||||
#include "output/items/Item.h"
|
||||
|
||||
|
||||
template <>
|
||||
class Poco::Dynamic::VarHolderImpl<std::shared_ptr<flippR_driver::output::items::Item>> : public Poco::Dynamic::VarHolder
|
||||
{
|
||||
public:
|
||||
VarHolderImpl(const std::shared_ptr<flippR_driver::output::items::Item> & item) :
|
||||
item(item)
|
||||
{}
|
||||
|
||||
void convert(std::string & val) const override
|
||||
{
|
||||
val = this->item->get_name();
|
||||
}
|
||||
|
||||
VarHolder * clone(Placeholder < VarHolder > * pHolder = 0) const override
|
||||
{
|
||||
return cloneHolder(pHolder, item);
|
||||
}
|
||||
|
||||
const std::type_info & type() const override
|
||||
{
|
||||
return typeid(item);
|
||||
}
|
||||
|
||||
const std::shared_ptr<flippR_driver::output::items::Item> & value() const
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<flippR_driver::output::items::Item> item;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
@@ -12,30 +12,30 @@
|
||||
|
||||
static int wiringPiSetup()
|
||||
{
|
||||
std::cout << "WiringPiSetup() called" << std::endl;
|
||||
//std::cout << "WiringPiSetup() called" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pinMode(int pin, int mode)
|
||||
{
|
||||
std::cout << "Set pin " << pin << " into mode " << mode << std::endl;
|
||||
//std::cout << "Set pin " << pin << " into mode " << mode << std::endl;
|
||||
}
|
||||
|
||||
int digitalRead(int pin)
|
||||
{
|
||||
std::cout << "Reading pin " << pin << std::endl;
|
||||
//std::cout << "Reading pin " << pin << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void digitalWrite(int pin, int value)
|
||||
{
|
||||
std::cout << "Writing pin " << pin << " with value " << value << std::endl;
|
||||
//std::cout << "Writing pin " << pin << " with value " << value << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int mcp23017Setup(const int pinBase, const int i2cAddress)
|
||||
{
|
||||
std::cout << "mcp23017Setup called with pinBase " << pinBase << " and i2cAddress " << i2cAddress << std::endl;
|
||||
//std::cout << "mcp23017Setup called with pinBase " << pinBase << " and i2cAddress " << i2cAddress << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user