This commit is contained in:
Jonas Zeunert
2019-08-15 22:17:09 +02:00
7 changed files with 149 additions and 134 deletions

View File

@@ -12,9 +12,10 @@ set(DEFAULT_BUILD_TYPE DEBUG)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
# Boost configuration IF(NOT_PI)
set(BOOST_COMPONENTS program_options thread timer chrono) add_definitions(-DNOT_PI)
message("Compiling not for Pi")
ENDIF()
project(FlippR-Driver) project(FlippR-Driver)
@@ -69,10 +70,13 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/${LIB_DIR}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/${LIB_DIR})
######################### BOOST ######################### ######################### BOOST #########################
# Boost configuration
set(BOOST_COMPONENTS program_options thread timer chrono)
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS}) find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND) if(Boost_FOUND)
# Include and link with boost # Include and link with boost
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
message ("Boost found and linked.") message ("Boost found and linked.")
else() else()
@@ -85,9 +89,9 @@ if(NOT wiringPi_LIB)
message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.") message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.")
add_definitions(-DNO_WIRING_PI) add_definitions(-DNO_WIRING_PI)
else() else()
message (STATUS "Found wiring pi.") message(STATUS "Found wiring pi.")
target_link_libraries(${PROJECT_NAME} PUBLIC ${wiringPi_LIB})
endif() endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${wiringPi_LIB})
find_library(crypt_LIB crypt) find_library(crypt_LIB crypt)
if(NOT crypt_LIB) if(NOT crypt_LIB)

View File

@@ -3,8 +3,8 @@
[ [
{ {
"name" : "extender_1", "name" : "extender_1",
"i2c_address" : 33, "i2c_address" : 32,
"pin_base" : 82 "pin_base" : 97
} }
], ],
"lamps" : "lamps" :

View File

@@ -4,7 +4,7 @@
[ [
{ {
"name" : "extender_0", "name" : "extender_0",
"i2c_address" : 33, "i2c_address" : 34,
"pin_base" : 81 "pin_base" : 81
} }
], ],
@@ -17,332 +17,332 @@
[ [
{ {
"id" : 0, "id" : 0,
"address" : "22", "address" : 22,
"description" : "Sound 1", "name" : "Sound 1",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 1, "id" : 1,
"address" : "23", "address" : 23,
"description" : "Sound 2", "name" : "Sound 2",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 2, "id" : 2,
"address" : "24", "address" : 24,
"description" : "Sound 3", "name" : "Sound 3",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 3, "id" : 3,
"address" : "25", "address" : 25,
"description" : "Sound 4", "name" : "Sound 4",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 4, "id" : 4,
"address" : "26", "address" : 26,
"description" : "Sound 5", "name" : "Sound 5",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 5, "id" : 5,
"address" : "27", "address" : 27,
"description" : "Sound 6", "name" : "Sound 6",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 6, "id" : 6,
"address" : "28", "address" : 28,
"description" : "Sound 7", "name" : "Sound 7",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 7, "id" : 7,
"address" : "29", "address" : 29,
"description" : "Sound 8", "name" : "Sound 8",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 8, "id" : 8,
"address" : "30", "address" : 30,
"description" : "Sound 9", "name" : "Sound 9",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 9, "id" : 9,
"address" : "31", "address" : 31,
"description" : "Sound 10", "name" : "Sound 10",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 10, "id" : 10,
"address" : "32", "address" : 32,
"description" : "Sound 11", "name" : "Sound 11",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 11, "id" : 11,
"address" : "33", "address" : 33,
"description" : "Sound 12", "name" : "Sound 12",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 12, "id" : 12,
"address" : "34", "address" : 34,
"description" : "Sound 13", "name" : "Sound 13",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 13, "id" : 13,
"address" : "35", "address" : 35,
"description" : "Sound 14", "name" : "Sound 14",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 14, "id" : 14,
"address" : "36", "address" : 36,
"description" : "Sound 15", "name" : "Sound 15",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 15, "id" : 15,
"address" : "37", "address" : 37,
"description" : "Sound 16", "name" : "Sound 16",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 16, "id" : 16,
"address" : "38", "address" : 38,
"description" : "Sound 17", "name" : "Sound 17",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 17, "id" : 17,
"address" : "39", "address" : 39,
"description" : "Sound 18", "name" : "Sound 18",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 18, "id" : 18,
"address" : "40", "address" : 40,
"description" : "Sound 19", "name" : "Sound 19",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 19, "id" : 19,
"address" : "41", "address" : 41,
"description" : "Sound 20", "name" : "Sound 20",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 20, "id" : 20,
"address" : "42", "address" : 42,
"description" : "Sound 21", "name" : "Sound 21",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 21, "id" : 21,
"address" : "43", "address" : 43,
"description" : "Sound 22", "name" : "Sound 22",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 22, "id" : 22,
"address" : "44", "address" : 44,
"description" : "Sound 23", "name" : "Sound 23",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 23, "id" : 23,
"address" : "45", "address" : 45,
"description" : "Sound 24", "name" : "Sound 24",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 24, "id" : 24,
"address" : "46", "address" : 46,
"description" : "Sound 25", "name" : "Sound 25",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 25, "id" : 25,
"address" : "47", "address" : 47,
"description" : "Sound 26", "name" : "Sound 26",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 26, "id" : 26,
"address" : "48", "address" : 48,
"description" : "Sound 27", "name" : "Sound 27",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 27, "id" : 27,
"address" : "49", "address" : 49,
"description" : "Sound 28", "name" : "Sound 28",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 28, "id" : 28,
"address" : "50", "address" : 50,
"description" : "Speech 1: \"You're good! But I'm still the Champ!\"", "name" : "Speech 1: \"You're good! But I'm still the Champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 29, "id" : 29,
"address" : "51", "address" : 51,
"description" : "Speech 2: \"Twenty\"", "name" : "Speech 2: \"Twenty\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 30, "id" : 30,
"address" : "52", "address" : 52,
"description" : "Speech 3: \"Seconds\"", "name" : "Speech 3: \"Seconds\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 31, "id" : 31,
"address" : "53", "address" : 53,
"description" : "Speech 4: \"Five, Four, Three, Two, One.\"", "name" : "Speech 4: \"Five, Four, Three, Two, One.\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 32, "id" : 32,
"address" : "54", "address" : 54,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 33, "id" : 33,
"address" : "55", "address" : 55,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 34, "id" : 34,
"address" : "56", "address" : 56,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 35, "id" : 35,
"address" : "57", "address" : 57,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 36, "id" : 36,
"address" : "58", "address" : 58,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 37, "id" : 37,
"address" : "59", "address" : 59,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 38, "id" : 38,
"address" : "60", "address" : 60,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 39, "id" : 39,
"address" : "61", "address" : 61,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 40, "id" : 40,
"address" : "62", "address" : 62,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 41, "id" : 41,
"address" : "63", "address" : 63,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 42, "id" : 42,
"address" : "64", "address" : 64,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 43, "id" : 43,
"address" : "65", "address" : 65,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 44, "id" : 44,
"address" : "66", "address" : 66,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 45, "id" : 45,
"address" : "67", "address" : 67,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 46, "id" : 46,
"address" : "68", "address" : 68,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 47, "id" : 47,
"address" : "69", "address" : 69,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 48, "id" : 48,
"address" : "70", "address" : 70,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 49, "id" : 49,
"address" : "71", "address" : 71,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 50, "id" : 50,
"address" : "72", "address" : 72,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 51, "id" : 51,
"address" : "73", "address" : 73,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 52, "id" : 52,
"address" : "74", "address" : 74,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 53, "id" : 53,
"address" : "75", "address" : 75,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
}, },
{ {
"id" : 54, "id" : 54,
"address" : "76", "address" : 76,
"description" : "speech 1: \"you're good! but i'm still the champ!\"", "name" : "speech 1: \"you're good! but i'm still the champ!\"",
"extender" : "extender_0" "extender" : "extender_0"
} }
] ]

View File

@@ -257,8 +257,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()
{ {
std::string runtime_dir = std::getenv("XDG_RUNTIME_DIR"); char* runtime_dir = std::getenv("XDG_RUNTIME_DIR");
if(runtime_dir == "") if(&runtime_dir == nullptr)
{ {
runtime_dir = DEFAULT_RUNTIME_DIR; runtime_dir = DEFAULT_RUNTIME_DIR;
} }

View File

@@ -41,8 +41,8 @@ private:
Poco::Net::TCPServer* build_input_server(); Poco::Net::TCPServer* build_input_server();
private: private:
const std::string DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/"; const char * DEFAULT_RUNTIME_DIR = "/tmp/flippR_driver-runtime/";
const std::string SOCKET_NAME = "S.flippR_driver"; const char * SOCKET_NAME = "S.flippR_driver";
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",
"matrix-config", "solenoid-config", "sound-config"}; "matrix-config", "solenoid-config", "sound-config"};
int input_port; int input_port;

View File

@@ -8,7 +8,6 @@
#include "PinController.h" #include "PinController.h"
#include "utility/config.h" #include "utility/config.h"
#ifndef NO_WIRING_PI #ifndef NO_WIRING_PI
#include <wiringPi.h> #include <wiringPi.h>
#include <mcp23017.h> #include <mcp23017.h>

View File

@@ -53,6 +53,7 @@ std::shared_ptr<OutputDriver> get_OutputDriver(std::istream& solenoid_config,
std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::istream & solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller) std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::istream & solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
{ {
solenoid_config.clear();
json solenoid_config_json; json solenoid_config_json;
solenoid_config >> solenoid_config_json; solenoid_config >> solenoid_config_json;
@@ -74,6 +75,7 @@ std::map<std::string, std::shared_ptr<items::Solenoid>> create_solenoids(std::is
std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoid_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds deactivation_time) std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoid_json, nlohmann::json &port_extenders, std::shared_ptr<DriverBoardPinController> &pin_controller, std::chrono::milliseconds deactivation_time)
{ {
solenoid_json;
std::string config_file_name = "solenoid_config.json"; std::string config_file_name = "solenoid_config.json";
uint8_t pin_base = get_pin_base(solenoid_json, port_extenders, config_file_name); uint8_t pin_base = get_pin_base(solenoid_json, port_extenders, config_file_name);
@@ -81,16 +83,18 @@ std::shared_ptr<items::detail::Solenoid> create_solenoid(nlohmann::json &solenoi
auto name = get_value<std::string>("name", solenoid_json, config_file_name); auto name = get_value<std::string>("name", solenoid_json, config_file_name);
auto address = get_value<uint8_t>("address", solenoid_json, config_file_name); auto address = get_value<uint8_t>("address", solenoid_json, config_file_name);
if(solenoid_json.find("deactivation_time_milliseconds") != solenoid_json.end()) if(solenoid_json.find("deactivation_time_milliseconds") != solenoid_json.end())
{ {
deactivation_time = std::chrono::milliseconds(get_value<uint8_t>("deactivation_time_milliseconds", solenoid_json, config_file_name)); deactivation_time = std::chrono::milliseconds(get_value<uint8_t>("deactivation_time_milliseconds", solenoid_json, config_file_name));
} }
return std::make_shared<items::detail::Solenoid>(pin_controller, address, pin_base, name, deactivation_time); return std::make_shared<items::detail::Solenoid>(pin_controller, address, pin_base, name, deactivation_time);
} }
std::map<std::string, std::shared_ptr<items::Flipper>> create_flippers(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller) std::map<std::string, std::shared_ptr<items::Flipper>> create_flippers(std::istream &solenoid_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
{ {
solenoid_config.clear();
solenoid_config.seekg(0, std::ios::beg);
json solenoid_config_json; json solenoid_config_json;
solenoid_config >> solenoid_config_json; solenoid_config >> solenoid_config_json;
@@ -121,6 +125,8 @@ std::shared_ptr<items::detail::Flipper> create_flipper(nlohmann::json &flipper_j
std::map<std::string, std::shared_ptr<items::Lamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &pin_controller) std::map<std::string, std::shared_ptr<items::Lamp>> create_lamps(std::istream &lamp_config, std::shared_ptr<DriverBoardPinController> &pin_controller)
{ {
lamp_config.clear();
lamp_config.seekg(0, std::ios::beg);
json lamp_config_json; json lamp_config_json;
lamp_config >> lamp_config_json; lamp_config >> lamp_config_json;
@@ -152,6 +158,8 @@ std::shared_ptr<items::detail::Lamp> create_lamp(json &lamp_json, json & port_ex
std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller) std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream &sound_config, std::shared_ptr<SoundBoardPinController> &pin_controller)
{ {
sound_config.clear();
sound_config.seekg(0, std::ios::beg);
json sound_config_json; json sound_config_json;
sound_config >> sound_config_json; sound_config >> sound_config_json;
@@ -161,13 +169,13 @@ std::map<std::string, std::shared_ptr<items::Sound>> create_sounds(std::istream
std::chrono::milliseconds deactivation_time{ get_value<int>("deactivation_time_milliseconds", sound_config_json, "solenoid_config.json") }; std::chrono::milliseconds deactivation_time{ get_value<int>("deactivation_time_milliseconds", sound_config_json, "solenoid_config.json") };
json solenoids_json = get_element("sounds", sound_config_json, "sound_config.json"); json sounds_json = get_element("sounds", sound_config_json, "sound_config.json");
std::map<std::string, std::shared_ptr<items::Sound>> sounds; std::map<std::string, std::shared_ptr<items::Sound>> sounds;
for(auto &solenoid_json : solenoids_json) for(auto &sound_json : sounds_json)
{ {
auto solenoid = create_sound(solenoid_json, port_extenders, pin_controller, deactivation_time); auto sound = create_sound(sound_json, port_extenders, pin_controller, deactivation_time);
sounds.emplace(solenoid->get_name(), solenoid); sounds.emplace(sound->get_name(), sound);
} }
return sounds; return sounds;
} }
@@ -186,6 +194,8 @@ std::shared_ptr<items::detail::Sound> create_sound(json &sound_json, json &port_
uint8_t get_sound_fire_address(std::istream &sound_config) uint8_t get_sound_fire_address(std::istream &sound_config)
{ {
sound_config.clear();
sound_config.seekg(0, std::ios::beg);
json sound_config_json; json sound_config_json;
sound_config >> sound_config_json; sound_config >> sound_config_json;
@@ -200,6 +210,8 @@ uint8_t get_sound_fire_address(std::istream &sound_config)
std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_config) std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_config)
{ {
display_config.clear();
display_config.seekg(0, std::ios::beg);
std::string config_file = "display_config.json"; std::string config_file = "display_config.json";
json display_config_json; json display_config_json;
@@ -233,7 +245,8 @@ std::map<std::string, uint8_t> parse_pins_display_board(std::istream &display_co
std::vector<std::shared_ptr<items::OutputDisplay>> create_displays(std::istream &display_config) std::vector<std::shared_ptr<items::OutputDisplay>> create_displays(std::istream &display_config)
{ {
display_config.clear();
display_config.seekg(0, std::ios::beg);
json display_config_json; json display_config_json;
display_config >> display_config_json; display_config >> display_config_json;
@@ -279,7 +292,6 @@ std::map<uint8_t, std::shared_ptr<items::Display>> map_displays(const std::vecto
void initialize_port_extenders(json &port_extenders, PinController * pin_controller, const std::string & file_name) void initialize_port_extenders(json &port_extenders, PinController * pin_controller, const std::string & file_name)
{ {
for (auto & extender_json : port_extenders) for (auto & extender_json : port_extenders)
{ {
auto i2c_address = get_value<uint8_t>("i2c_address", extender_json, file_name); auto i2c_address = get_value<uint8_t>("i2c_address", extender_json, file_name);
@@ -334,7 +346,7 @@ type get_value(const std::string & name, json & object, const std::string & file
} }
catch(json::exception &e) catch(json::exception &e)
{ {
CLOG(ERROR, OUTPUT_LOGGER) << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what(); /*CLOG(ERROR, OUTPUT_LOGGER)*/ std::cerr << "File " << file_name << " seems to be corrupted at " << name << ": " << e.what();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return element; return element;