Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Commit 3c59e53

Browse files
authored
Merge pull request #96 from akloniex/read-stdin
logger: Implement possibility to read log data from stdin
2 parents b6046db + 5e4995f commit 3c59e53

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

rmbox/convert.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct convert_config {
3535
#ifdef LOGGER_FORMAT
3636
const char *ldc_file;
3737
FILE* ldc_fd;
38+
int input_std;
3839
#endif
3940
};
4041

rmbox/logger_convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static inline void print_table_header(FILE *out_fd)
7070
"DELTA",
7171
"FILE_NAME",
7272
"CONTENT");
73+
fflush(out_fd);
7374
}
7475

7576
#define CASE(x) \
@@ -137,6 +138,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log,
137138
break;
138139
}
139140
fprintf(out_fd, "\n");
141+
fflush(out_fd);
140142
}
141143

142144
static int fetch_entry(struct convert_config *config, uint32_t base_address,
@@ -241,7 +243,6 @@ static int logger_read(struct convert_config *config,
241243
{
242244
struct dma_log dma_log;
243245
int ret = 0;
244-
245246
print_table_header(config->out_fd);
246247
uint64_t last_timestamp = 0;
247248

rmbox/rmbox.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static void usage(void)
4242
fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME);
4343
#ifdef LOGGER_FORMAT
4444
fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME);
45+
fprintf(stdout, "%s:\t -p \tinput from stdin\n", APP_NAME);
4546
#endif
4647
fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME);
4748
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[])
122123
config.in_fd = NULL;
123124
#ifdef LOGGER_FORMAT
124125
config.ldc_file = NULL;
126+
config.input_std = 0;
125127
#endif
126128

127129
#ifdef LOGGER_FORMAT
128-
while ((opt = getopt(argc, argv, "ho:i:l:s:m:c:t")) != -1) {
130+
while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) {
129131
#else
130132
while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) {
131133
#endif
@@ -148,6 +150,9 @@ int main(int argc, char *argv[])
148150
case 'l':
149151
config.ldc_file = optarg;
150152
break;
153+
case 'p':
154+
config.input_std = 1;
155+
break;
151156
#endif
152157
case 'h':
153158
default: /* '?' */
@@ -190,7 +195,12 @@ int main(int argc, char *argv[])
190195
if (!config.in_file)
191196
config.in_file = "/sys/kernel/debug/sof/etrace";
192197

193-
if (config.in_file) {
198+
#ifdef LOGGER_FORMAT
199+
if (config.input_std) {
200+
config.in_fd = stdin;
201+
} else
202+
#endif
203+
{
194204
config.in_fd = fopen(config.in_file, "r");
195205
if (!config.in_fd) {
196206
fprintf(stderr, "error: Unable to open in file %s\n",

0 commit comments

Comments
 (0)