|
@@ -29,6 +29,7 @@ int main(int argc, char* argv[])
|
29
|
29
|
unsigned count = 0;
|
30
|
30
|
std::cout << "Ready to sniff. Press enter...";
|
31
|
31
|
getchar();
|
|
32
|
+
|
32
|
33
|
signal(SIGINT, signal_handler);
|
33
|
34
|
gettimeofday(&t1, NULL);
|
34
|
35
|
for (; count < n; ++count)
|
|
@@ -38,10 +39,7 @@ int main(int argc, char* argv[])
|
38
|
39
|
}
|
39
|
40
|
gettimeofday(&t2, NULL);
|
40
|
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
|
43
|
unsigned long long ut1 = (__suseconds_t)(1000000L * t1.tv_sec + t1.tv_usec);
|
46
|
44
|
unsigned long long ut2 = (__suseconds_t)(1000000L * t2.tv_sec + t2.tv_usec);
|
47
|
45
|
unsigned long long diff = ut2 - ut1;
|
|
@@ -49,5 +47,10 @@ int main(int argc, char* argv[])
|
49
|
47
|
double mhz = (1000000.0 / unit) / 1000000.0;
|
50
|
48
|
std::cout << "count: " << count << " diff: " << diff << " unit: "
|
51
|
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
|
55
|
return 0;
|
53
|
56
|
}
|