OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [tools/] [shserout/] [shserout.c] - Blame information for rev 306

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 305 hellwig
/*
2
 * shserout.c -- show output of serial line in readable format
3
 */
4
 
5
 
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
 
10
 
11
#define LINE_SIZE       200
12
 
13
 
14
int main(int argc, char *argv[]) {
15
  FILE *inFile;
16
  char line[LINE_SIZE];
17
  char *p;
18
  unsigned int n;
19
 
20
  if (argc != 2) {
21
    printf("usage: %s <serial line output file>\n", argv[0]);
22
    exit(1);
23
  }
24
  inFile = fopen(argv[1], "r");
25
  if (inFile == NULL) {
26
    printf("error: cannot open input file '%s'\n", argv[1]);
27
    exit(1);
28
  }
29
  while (fgets(line, LINE_SIZE, inFile) != NULL) {
30
    p = strstr(line, "0x");
31
    if (p == NULL) {
32
      continue;
33
    }
34
    n = strtoul(p, NULL, 0);
35
    printf("%c", n);
36
  }
37
  fclose(inFile);
38
  return 0;
39
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.