logger: Implement possibility to read log data from stdin

Signed-off-by: ArturX Kloniecki <arturx.kloniecki@linux.intel.com>
This commit is contained in:
ArturX Kloniecki 2018-10-08 14:18:08 +02:00
parent e37aa3f422
commit 5e4995f995
3 changed files with 15 additions and 3 deletions

View File

@ -35,6 +35,7 @@ struct convert_config {
#ifdef LOGGER_FORMAT
const char *ldc_file;
FILE* ldc_fd;
int input_std;
#endif
};

View File

@ -70,6 +70,7 @@ static inline void print_table_header(FILE *out_fd)
"DELTA",
"FILE_NAME",
"CONTENT");
fflush(out_fd);
}
#define CASE(x) \
@ -137,6 +138,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log,
break;
}
fprintf(out_fd, "\n");
fflush(out_fd);
}
static int fetch_entry(struct convert_config *config, uint32_t base_address,
@ -241,7 +243,6 @@ static int logger_read(struct convert_config *config,
{
struct dma_log dma_log;
int ret = 0;
print_table_header(config->out_fd);
uint64_t last_timestamp = 0;

View File

@ -42,6 +42,7 @@ static void usage(void)
fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME);
#ifdef LOGGER_FORMAT
fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME);
fprintf(stdout, "%s:\t -p \tinput from stdin\n", APP_NAME);
#endif
fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME);
fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME);
@ -122,10 +123,11 @@ int main(int argc, char *argv[])
config.in_fd = NULL;
#ifdef LOGGER_FORMAT
config.ldc_file = NULL;
config.input_std = 0;
#endif
#ifdef LOGGER_FORMAT
while ((opt = getopt(argc, argv, "ho:i:l:s:m:c:t")) != -1) {
while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) {
#else
while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) {
#endif
@ -148,6 +150,9 @@ int main(int argc, char *argv[])
case 'l':
config.ldc_file = optarg;
break;
case 'p':
config.input_std = 1;
break;
#endif
case 'h':
default: /* '?' */
@ -190,7 +195,12 @@ int main(int argc, char *argv[])
if (!config.in_file)
config.in_file = "/sys/kernel/debug/sof/etrace";
if (config.in_file) {
#ifdef LOGGER_FORMAT
if (config.input_std) {
config.in_fd = stdin;
} else
#endif
{
config.in_fd = fopen(config.in_file, "r");
if (!config.in_fd) {
fprintf(stderr, "error: Unable to open in file %s\n",