Browse Source

Makefile

master
Robin Thoni 9 years ago
parent
commit
f9f41e1163
3 changed files with 18 additions and 4 deletions
  1. 11
    0
      Makefile
  2. 0
    0
      gpio-raw.cpp
  3. 7
    4
      main.cpp

+ 11
- 0
Makefile View File

1
+CXXFLAGS = -O3
2
+EXE = gpio-analyser
3
+SRC = main.cpp gpio-raw.cpp
4
+OBJS = $(SRC:.cpp=.o)
5
+
6
+${EXE}: ${OBJS}
7
+	${LINK.cpp} ${OBJS} ${OUTPUT_OPTION}
8
+
9
+clean:
10
+	rm -rf ${OBJS}
11
+	rm -rf ${EXE}

gpio-raw.c → gpio-raw.cpp View File


main.c → main.cpp View File

29
   unsigned count = 0;
29
   unsigned count = 0;
30
   std::cout << "Ready to sniff. Press enter...";
30
   std::cout << "Ready to sniff. Press enter...";
31
   getchar();
31
   getchar();
32
+
32
   signal(SIGINT, signal_handler);
33
   signal(SIGINT, signal_handler);
33
   gettimeofday(&t1, NULL);
34
   gettimeofday(&t1, NULL);
34
     for (; count < n; ++count)
35
     for (; count < n; ++count)
38
     }
39
     }
39
   gettimeofday(&t2, NULL);
40
   gettimeofday(&t2, NULL);
40
   signal(SIGINT, SIG_DFL);
41
   signal(SIGINT, SIG_DFL);
41
-  std::cout << "Saving file..." << std::endl;
42
-  int fd = open("gpio.out", O_CREAT | O_WRONLY);
43
-  write(fd, (void*)v, count * sizeof(*v));
44
-  close(fd);
42
+
45
   unsigned long long ut1 = (__suseconds_t)(1000000L * t1.tv_sec + t1.tv_usec);
43
   unsigned long long ut1 = (__suseconds_t)(1000000L * t1.tv_sec + t1.tv_usec);
46
   unsigned long long ut2 = (__suseconds_t)(1000000L * t2.tv_sec + t2.tv_usec);
44
   unsigned long long ut2 = (__suseconds_t)(1000000L * t2.tv_sec + t2.tv_usec);
47
   unsigned long long diff = ut2 - ut1;
45
   unsigned long long diff = ut2 - ut1;
49
   double mhz = (1000000.0 / unit) / 1000000.0;
47
   double mhz = (1000000.0 / unit) / 1000000.0;
50
   std::cout << "count: " << count << " diff: " << diff << " unit: "
48
   std::cout << "count: " << count << " diff: " << diff << " unit: "
51
     << unit << " Mhz: " << mhz << std::endl;
49
     << unit << " Mhz: " << mhz << std::endl;
50
+
51
+  std::cout << "Saving file..." << std::endl;
52
+  int fd = open("gpio.out", O_CREAT | O_WRONLY);
53
+  write(fd, (void*)v, count * sizeof(*v));
54
+  close(fd);
52
   return 0;
55
   return 0;
53
 }
56
 }

Loading…
Cancel
Save