mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Add missing options to show configuration
This commit is contained in:
parent
51bfa68bdd
commit
b05f38abd0
6 changed files with 64 additions and 11 deletions
20
src/alert.c
20
src/alert.c
|
|
@ -19,6 +19,7 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "alert.h"
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -28,9 +29,9 @@
|
|||
#include "print.h"
|
||||
#include "options.h"
|
||||
|
||||
enum alert_t alert_option_parse(const char *arg)
|
||||
alert_t alert_option_parse(const char *arg)
|
||||
{
|
||||
enum alert_t alert = option.alert; // Default
|
||||
alert_t alert = option.alert; // Default
|
||||
|
||||
if (arg != NULL)
|
||||
{
|
||||
|
|
@ -108,3 +109,18 @@ void alert_disconnect(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *alert_state_to_string(alert_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case ALERT_NONE:
|
||||
return "none";
|
||||
case ALERT_BELL:
|
||||
return "bell";
|
||||
case ALERT_BLINK:
|
||||
return "blink";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
enum alert_t
|
||||
typedef enum
|
||||
{
|
||||
ALERT_NONE,
|
||||
ALERT_BELL,
|
||||
ALERT_BLINK,
|
||||
ALERT_END,
|
||||
};
|
||||
} alert_t;
|
||||
|
||||
enum alert_t alert_option_parse(const char *arg);
|
||||
alert_t alert_option_parse(const char *arg);
|
||||
void alert_connect(void);
|
||||
void alert_disconnect(void);
|
||||
const char *alert_state_to_string(alert_t state);
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ const char *output_mode_by_string(output_mode_t mode)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
enum script_run_t script_run_option_parse(const char *arg)
|
||||
script_run_t script_run_option_parse(const char *arg)
|
||||
{
|
||||
if (strcmp("once", arg) == 0)
|
||||
{
|
||||
|
|
@ -320,6 +320,7 @@ void options_print()
|
|||
tio_printf(" Parity: %s", option.parity);
|
||||
tio_printf(" Local echo: %s", option.local_echo ? "enabled" : "disabled");
|
||||
tio_printf(" Timestamp: %s", timestamp_state_to_string(option.timestamp));
|
||||
tio_printf(" Timestamp timeout: %u", option.timestamp_timeout);
|
||||
tio_printf(" Output delay: %d", option.output_delay);
|
||||
tio_printf(" Output line delay: %d", option.output_line_delay);
|
||||
tio_printf(" Auto connect: %s", option.no_autoconnect ? "disabled" : "enabled");
|
||||
|
|
@ -331,13 +332,31 @@ void options_print()
|
|||
option.ri_pulse_duration);
|
||||
tio_printf(" Input mode: %s", input_mode_by_string(option.input_mode));
|
||||
tio_printf(" Output mode: %s", output_mode_by_string(option.output_mode));
|
||||
tio_printf(" Alert: %s", alert_state_to_string(option.alert));
|
||||
if (option.map[0] != 0)
|
||||
{
|
||||
tio_printf(" Map flags: %s", option.map);
|
||||
}
|
||||
if (option.log)
|
||||
{
|
||||
tio_printf(" Log file: %s", log_get_filename());
|
||||
if (option.log_directory != NULL)
|
||||
{
|
||||
tio_printf(" Log file directory: %s", option.log_directory);
|
||||
}
|
||||
tio_printf(" Log append: %s", option.log_append ? "enabled" : "disabled");
|
||||
tio_printf(" Log strip: %s", option.log_strip ? "enabled" : "disabled");
|
||||
}
|
||||
if (option.socket)
|
||||
{
|
||||
tio_printf(" Socket: %s", option.socket);
|
||||
}
|
||||
if (option.script_filename != NULL)
|
||||
{
|
||||
tio_printf(" Script file: %s", option.script_filename);
|
||||
tio_printf(" Script run: %s", script_run_state_to_string(option.script_run));
|
||||
}
|
||||
}
|
||||
|
||||
void options_parse(int argc, char *argv[])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,11 +83,11 @@ struct option_t
|
|||
uint32_t rs485_config_flags;
|
||||
int32_t rs485_delay_rts_before_send;
|
||||
int32_t rs485_delay_rts_after_send;
|
||||
enum alert_t alert;
|
||||
alert_t alert;
|
||||
bool complete_sub_configs;
|
||||
const char *script;
|
||||
const char *script_filename;
|
||||
enum script_run_t script_run;
|
||||
script_run_t script_run;
|
||||
unsigned int timestamp_timeout;
|
||||
};
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ void options_parse(int argc, char *argv[]);
|
|||
void options_parse_final(int argc, char *argv[]);
|
||||
|
||||
void line_pulse_duration_option_parse(const char *arg);
|
||||
enum script_run_t script_run_option_parse(const char *arg);
|
||||
script_run_t script_run_option_parse(const char *arg);
|
||||
|
||||
input_mode_t input_mode_option_parse(const char *arg);
|
||||
output_mode_t output_mode_option_parse(const char *arg);
|
||||
|
|
|
|||
16
src/script.c
16
src/script.c
|
|
@ -35,6 +35,7 @@
|
|||
#include "tty.h"
|
||||
#include "xymodem.h"
|
||||
#include "log.h"
|
||||
#include "script.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE 2000 // Maximum size of circular buffer
|
||||
|
||||
|
|
@ -523,3 +524,18 @@ void script_run(int fd)
|
|||
|
||||
lua_close(L);
|
||||
}
|
||||
|
||||
const char *script_run_state_to_string(script_run_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SCRIPT_RUN_ONCE:
|
||||
return "once";
|
||||
case SCRIPT_RUN_ALWAYS:
|
||||
return "always";
|
||||
case SCRIPT_RUN_NEVER:
|
||||
return "never";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
enum script_run_t
|
||||
typedef enum
|
||||
{
|
||||
SCRIPT_RUN_ONCE,
|
||||
SCRIPT_RUN_ALWAYS,
|
||||
SCRIPT_RUN_NEVER,
|
||||
SCRIPT_RUN_END,
|
||||
};
|
||||
} script_run_t;
|
||||
|
||||
void script_run(int fd);
|
||||
const char *script_run_state_to_string(script_run_t state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue