root/trunk/libffado/src/libieee1394/test-cyclecalc.cpp

Revision 790, 3.7 kB (checked in by ppalmers, 13 years ago)

add debugging code

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "cycletimer.h"
25 #include "debugmodule/debugmodule.h"
26 #include <stdio.h>
27
28 DECLARE_GLOBAL_DEBUG_MODULE;
29
30 int main() {
31     setDebugLevel(DEBUG_LEVEL_VERY_VERBOSE);
32     printf("Cycle timer operation tests (incomplete)\n");
33    
34     /* TEST 1
35      * check reconstruction of SYT RECEIVE timestamp
36      *
37      * The now_ctr has wrapped, while the cycle and syt have not
38      *
39      */
40
41     uint32_t now_ctr = 0x140001DA;
42     uint64_t now = CYCLE_TIMER_TO_TICKS(0x140001DA);
43     unsigned int cycle = 7968;
44     uint16_t syt = 0x583B;
45    
46     debugOutput(DEBUG_LEVEL_VERBOSE,"NOW_CTR          : %08X (%03us %04uc %04ut)\n",
47                           now_ctr,
48                           (unsigned int)CYCLE_TIMER_GET_SECS(now_ctr),
49                           (unsigned int)CYCLE_TIMER_GET_CYCLES(now_ctr),
50                           (unsigned int)CYCLE_TIMER_GET_OFFSET(now_ctr));
51
52     debugOutput(DEBUG_LEVEL_VERBOSE,"NOW              : %011llu (%03us %04uc %04ut)\n",
53                           now,
54                           (unsigned int)TICKS_TO_SECS(now),
55                           (unsigned int)TICKS_TO_CYCLES(now),
56                           (unsigned int)TICKS_TO_OFFSET(now));
57     debugOutput(DEBUG_LEVEL_VERBOSE,"SYT              : %08X (%03us %04uc %04ut)\n",
58                           syt,
59                           (unsigned int)CYCLE_TIMER_GET_SECS(syt),
60                           (unsigned int)CYCLE_TIMER_GET_CYCLES(syt),
61                           (unsigned int)CYCLE_TIMER_GET_OFFSET(syt));
62     debugOutput(DEBUG_LEVEL_VERBOSE,"CYCLE            : %uc\n",
63                           cycle);
64
65     uint64_t calc_ts = sytRecvToFullTicks(syt, cycle, now_ctr);
66
67     debugOutput(DEBUG_LEVEL_VERBOSE,"CALC_TS          : %011llu (%03us %04uc %04ut)\n",
68                           calc_ts,
69                           (unsigned int)TICKS_TO_SECS(calc_ts),
70                           (unsigned int)TICKS_TO_CYCLES(calc_ts),
71                           (unsigned int)TICKS_TO_OFFSET(calc_ts));
72
73    
74 // BL: 1211722982: Debug (IsoHandler.cpp)[ 420] putPacket: received packet: length=168, channel=0, cycle=7968
75 // BL: 1211723031: Debug (cycletimer.h)[ 308] sytRecvToFullTicks: SYT=583B CY=7968 CTR=140001DA
76 // BL: 1211723037: Debug (StreamProcessor.cpp)[ 346] putPacket: RECV: CY=7968 TS=00245679163
77 // BL: 1211723043: Debug (AmdtpReceiveStreamProcessor.cpp)[ 135] processPacketData: STMP: 245679163ticks | syt_interval=8, tpf=557.254395
78 // BL: 1211723051: Debug (TimestampedBuffer.cpp)[1153] incrementFrameCounter:  nbframes: 8, m_update_period: 8
79 // BL: 1211723052: Debug (AmdtpTransmitStreamProcessor.cpp)[ 250] generatePacketHeader: Too early: CY=0254, TC=0257, CUT=0003, TST=00271126073 (0257), TSP=00271137849 (0261)
80 // BL: 1211723055: Debug (TimestampedBuffer.cpp)[1155] incrementFrameCounter:  tail TS:  270250705.174, next tail TS:  270255163.209
81 // BL: 1211723062: Debug (TimestampedBuffer.cpp)[1157] incrementFrameCounter:  new TS:  245679163.000, wrapped new TS:  245679163.000
82 //     
83
84 }
Note: See TracBrowser for help on using the browser.