add: vendor directory
add: cli (argparse) add: test runner
This commit is contained in:
parent
25ba0ff723
commit
ec720e7617
15 changed files with 658 additions and 13 deletions
23
main.c
23
main.c
|
@ -16,6 +16,7 @@
|
|||
#include <handlers.h>
|
||||
#include <drivers.h>
|
||||
#include <enums.h>
|
||||
#include <runners.h>
|
||||
#include <helpers.h>
|
||||
#include <wiringPi.h>
|
||||
#include <piFace.h>
|
||||
|
@ -56,7 +57,7 @@ terminate(int signum)
|
|||
* @return Statuscode to indicate success (0) or failure (!0)
|
||||
*/
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
main(int argc, const char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
@ -67,16 +68,19 @@ main(int argc, char** argv)
|
|||
|
||||
/******************** LOAD CONFIG ********************/
|
||||
|
||||
char ini_file_name[] = "controller.ini";
|
||||
FILE * const ini_file = fopen(ini_file_name, "rb");
|
||||
global_config.file = "controller.ini";
|
||||
|
||||
helpers_parse_cli(argc, argv, &global_config);
|
||||
|
||||
FILE * const ini_file = fopen(global_config.file, "rb");
|
||||
if(ini_file == NULL)
|
||||
{
|
||||
LOG_ERROR("%s file was not found", ini_file_name);
|
||||
LOG_FATAL("config file '%s' was not found", global_config.file);
|
||||
exit(1);
|
||||
}
|
||||
if(load_ini_file( ini_file, INI_DEFAULT_FORMAT, NULL, helper_load_config, &global_config))
|
||||
{
|
||||
LOG_ERROR("unable to parse ini file");
|
||||
LOG_FATAL("unable to parse ini file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -120,6 +124,15 @@ main(int argc, char** argv)
|
|||
poll_fds[POLL_FDS_COMMAND].events = POLLIN;
|
||||
LOG_DEBUG("setup fd_command as %i on index %i", fd_command, POLL_FDS_COMMAND);
|
||||
|
||||
|
||||
/******************** CHECK FOR TESTING RUN ********************/
|
||||
|
||||
if(global_config.run_type == RUN_TYPE_TEST)
|
||||
{
|
||||
runner_test(this_controller);
|
||||
}
|
||||
|
||||
|
||||
/******************** START MAIN LOOP ********************/
|
||||
|
||||
for(;;)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue