root/trunk/libffado/tests/test-ieee1394service.cpp

Revision 445, 3.1 kB (checked in by pieterpalmers, 16 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

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  * FFADO 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 2 of the License, or
12  * (at your option) any later version.
13  * FFADO is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with FFADO; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA.
22  *
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <endian.h>
33
34 #include <signal.h>
35 #include "src/debugmodule/debugmodule.h"
36
37 #include <netinet/in.h>
38
39 #include "src/threads.h"
40
41 #include "src/libieee1394/configrom.h"
42 #include "src/libieee1394/ieee1394service.h"
43 #include "src/libieee1394/ARMHandler.h"
44
45 #include <libraw1394/raw1394.h>
46
47 DECLARE_GLOBAL_DEBUG_MODULE;
48
49 int run=1;
50 static void sighandler (int sig)
51 {
52     run = 0;
53 }
54
55 class MyFunctor : public Functor
56 {
57 public:
58     MyFunctor() {}
59     virtual ~MyFunctor() {}
60
61     void operator() () {
62         printf("hello from the functor (%p)\n", this);
63     };
64 };
65
66 int main(int argc, char *argv[])
67 {
68     signal (SIGINT, sighandler);
69     signal (SIGPIPE, sighandler);
70
71     printf("FFADO Ieee1394Service test application\n");
72
73     Ieee1394Service *m_service=NULL;
74
75     m_service=new Ieee1394Service();
76     m_service->initialize(2);
77
78     MyFunctor *test_busreset=new MyFunctor();
79
80     printf(" adding (%p) as busreset handler\n", test_busreset);
81
82     m_service->addBusResetHandler(test_busreset);
83
84     nodeaddr_t addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 );
85
86     ARMHandler *test_arm=new ARMHandler(addr,
87                          4,
88                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
89                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
90                          0);
91
92     printf(" adding (%p) as arm handler\n", test_arm);
93
94     if (!m_service->registerARMHandler(test_arm)) {
95         printf("  failed\n");
96     }
97
98     addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 );
99
100     ARMHandler *test_arm2=new ARMHandler(addr,
101                          4,
102                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
103                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
104                          0);
105
106     printf(" adding (%p) as arm handler\n", test_arm2);
107
108     if (!m_service->registerARMHandler(test_arm2)) {
109         printf("  failed\n");
110     }
111
112     while(run) {
113         fflush(stderr);
114         fflush(stdout);
115         sleep(1);
116     }
117
118     delete m_service;
119     delete test_busreset;
120     delete test_arm;
121     delete test_arm2;
122
123     printf("Bye...\n");
124
125     return EXIT_SUCCESS;
126 }
Note: See TracBrowser for help on using the browser.