aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-12-07 14:42:02 +0100
committerDan Dennedy <dan@dennedy.org>2008-12-07 23:10:17 -0800
commit38a43c2736aba4a56d4d85e3980c57d8bef55e58 (patch)
tree5e5273423e810271b56ba9660f2a0fea80afb354
parentb63022aeeb7430186d4659fcfe73070a3806df8e (diff)
downloadlibraw1394-38a43c2736aba4a56d4d85e3980c57d8bef55e58.tar.gz
testlibraw: test raw1394_read_cycle_timer()
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Dan Dennedy <dan@dennedy.org>
-rw-r--r--tools/testlibraw.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testlibraw.c b/tools/testlibraw.c
index 9b31a3a..82b8ee5 100644
--- a/tools/testlibraw.c
+++ b/tools/testlibraw.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <sys/poll.h>
#include <stdlib.h>
+#include <time.h>
#include <arpa/inet.h>
#include "../src/raw1394.h"
@@ -137,6 +138,27 @@ test_config_rom(raw1394handle_t handle)
printf(" update_config_rom returned %d\n", retval);
}
+static void
+read_cycle_timer(raw1394handle_t handle)
+{
+ u_int32_t ct;
+ u_int64_t local_time;
+ time_t seconds;
+ int retval;
+
+ retval = raw1394_read_cycle_timer(handle, &ct, &local_time);
+ if (retval < 0) {
+ perror("\n - raw1394_read_cycle_timer failed with error");
+ return;
+ }
+
+ printf("\n - cycle timer: %d seconds, %d cycles, %d sub-cycles\n",
+ ct >> 25, (ct >> 12) & 0x1fff, ct & 0xfff);
+ seconds = local_time / 1000000;
+ printf(" local time: %lld us = %s",
+ (unsigned long long)local_time, ctime(&seconds));
+}
+
int test_card(int card)
{
raw1394handle_t handle;
@@ -223,6 +245,7 @@ int test_card(int card)
test_fcp(handle);
read_topology_map(handle);
test_config_rom(handle);
+ read_cycle_timer(handle);
printf("\n - posting 0xdeadbeef as an echo request\n");
raw1394_echo_request(handle, 0xdeadbeef);