Fixed server file erroe
This commit is contained in:
@@ -181,9 +181,11 @@ HTTPServer* FlippRServer::build_output_server()
|
|||||||
{
|
{
|
||||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
|
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
|
||||||
|
|
||||||
output_socket_file = Poco::File(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
|
Poco::File socket_file(this->get_runtime_dir() + OUTPUT_SOCKET_NAME);
|
||||||
|
if (socket_file.exists())
|
||||||
|
socket_file.remove();
|
||||||
|
|
||||||
SocketAddress address(SocketAddress::UNIX_LOCAL, output_socket_file.path());
|
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
|
||||||
ServerSocket server_socket(address);
|
ServerSocket server_socket(address);
|
||||||
|
|
||||||
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
|
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
|
||||||
@@ -193,9 +195,15 @@ TCPServer* FlippRServer::build_input_server()
|
|||||||
{
|
{
|
||||||
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
|
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
|
||||||
|
|
||||||
input_socket_file = Poco::File(this->get_runtime_dir() + INPUT_SOCKET_NAME);
|
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, input_socket_file.path());
|
|
||||||
|
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
|
||||||
ServerSocket server_socket(address);
|
ServerSocket server_socket(address);
|
||||||
|
|
||||||
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), server_socket);
|
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), server_socket);
|
||||||
@@ -261,8 +269,8 @@ void FlippRServer::handle_help(const std::string& name, const std::string& value
|
|||||||
|
|
||||||
std::string FlippRServer::get_runtime_dir()
|
std::string FlippRServer::get_runtime_dir()
|
||||||
{
|
{
|
||||||
return DEFAULT_RUNTIME_DIR;
|
//return DEFAULT_RUNTIME_DIR;
|
||||||
//return std::getenv("XDG_RUNTIME_DIR") ? std::getenv("XDG_RUNTIME_DIR") : DEFAULT_RUNTIME_DIR;
|
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
Poco::Net::TCPServer* build_input_server();
|
Poco::Net::TCPServer* build_input_server();
|
||||||
|
|
||||||
private:
|
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 * INPUT_SOCKET_NAME = "S.flippR_driver.in";
|
||||||
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
|
||||||
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
|
||||||
|
|||||||
@@ -12,30 +12,30 @@
|
|||||||
|
|
||||||
static int wiringPiSetup()
|
static int wiringPiSetup()
|
||||||
{
|
{
|
||||||
std::cout << "WiringPiSetup() called" << std::endl;
|
//std::cout << "WiringPiSetup() called" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pinMode(int pin, int mode)
|
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)
|
int digitalRead(int pin)
|
||||||
{
|
{
|
||||||
std::cout << "Reading pin " << pin << std::endl;
|
//std::cout << "Reading pin " << pin << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void digitalWrite(int pin, int value)
|
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)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user