From 38a43c2736aba4a56d4d85e3980c57d8bef55e58 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sun, 7 Dec 2008 14:42:02 +0100 Subject: [PATCH] testlibraw: test raw1394_read_cycle_timer() Signed-off-by: Stefan Richter Signed-off-by: Dan Dennedy --- tools/testlibraw.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 #include #include +#include #include #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);