summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
807425c)
We have now two redundant structures that hold the configuration data
for log-plotter. Remove the redundant one and use only one structure
for holding all configuration data.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
char *device_path;
int baudrate;
char *log_path;
char *device_path;
int baudrate;
char *log_path;
+ char *config_file_path;
+int read_args(int argc, char *argv[], struct plotter_config *cfg);
int populate_config_data_from_file(const char *path,
struct plotter_config *cfg);
int populate_config_data_from_file(const char *path,
struct plotter_config *cfg);
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include "config.h"
#include "baud.h"
#include "trace.h"
#include "config.h"
#include "baud.h"
#include "trace.h"
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
- struct plotter_options options;
struct plotter_config cfg;
int fd, baud, ret = 0;
bzero(&cfg, sizeof(cfg));
struct plotter_config cfg;
int fd, baud, ret = 0;
bzero(&cfg, sizeof(cfg));
- if (read_args(argc, argv, &options))
+ if (read_args(argc, argv, &cfg))
- if (options.config_file_path)
- populate_config_data_from_file(options.config_file_path, &cfg);
+ if (cfg.config_file_path)
+ populate_config_data_from_file(cfg.config_file_path, &cfg);
- baud = options.baud_rate;
- fd = open_at_baud(options.device_path, &baud);
+ baud = cfg.baudrate;
+ fd = open_at_baud(cfg.device_path, &baud);
- if (baud != options.baud_rate) {
+ if (baud != cfg.baudrate) {
pr_err("Failed to set baudrate to %d, only got %d\n",
pr_err("Failed to set baudrate to %d, only got %d\n",
- options.baud_rate, baud);
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "trace.h"
void print_help_and_die(const char *exec_name)
#include "trace.h"
void print_help_and_die(const char *exec_name)
-static void set_default_options(struct plotter_options *opts)
+static void set_default_options(struct plotter_config *opts)
{
bzero(opts, sizeof(*opts));
{
bzero(opts, sizeof(*opts));
- opts->baud_rate = 128000;
+ opts->baudrate = 128000;
opts->device_path = "/dev/ttyUSB0";
}
opts->device_path = "/dev/ttyUSB0";
}
-int read_args(int argc, char *argv[], struct plotter_options *opts)
+int read_args(int argc, char *argv[], struct plotter_config *opts)
{
int option_index = 0, c;
static struct option long_options[] = {
{
int option_index = 0, c;
static struct option long_options[] = {
opts->device_path = optarg;
break;
case 'o':
opts->device_path = optarg;
break;
case 'o':
- opts->output_path = optarg;
+ opts->log_path = optarg;
- opts->baud_rate = atoi(optarg);
+ opts->baudrate = atoi(optarg);
break;
case 'v':
trace_level++;
break;
case 'v':
trace_level++;
+++ /dev/null
-#ifndef _OPTIONS_H
-#define _OPTIONS_H
-
-struct plotter_options {
- char *device_path;
- char *output_path;
- int baud_rate;
- char *config_file_path;
-};
-
-int read_args(int argc, char *argv[], struct plotter_options *opts);
-
-#endif