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

Revision 742, 3.1 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

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 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <endian.h>
32
33 #include <signal.h>
34 #include "src/debugmodule/debugmodule.h"
35
36 #include <netinet/in.h>
37
38 #include "src/threads.h"
39
40 #include "src/libieee1394/configrom.h"
41 #include "src/libieee1394/ieee1394service.h"
42 #include "src/libieee1394/ARMHandler.h"
43
44 #include <libraw1394/raw1394.h>
45
46 DECLARE_GLOBAL_DEBUG_MODULE;
47
48 int run=1;
49 static void sighandler (int sig)
50 {
51     run = 0;
52 }
53
54 class MyFunctor : public Functor
55 {
56 public:
57     MyFunctor() {}
58     virtual ~MyFunctor() {}
59
60     void operator() () {
61         printf("hello from the functor (%p)\n", this);
62     };
63 };
64
65 int main(int argc, char *argv[])
66 {
67     signal (SIGINT, sighandler);
68     signal (SIGPIPE, sighandler);
69
70     printf("FFADO Ieee1394Service test application\n");
71
72     Ieee1394Service *m_service=NULL;
73
74     m_service=new Ieee1394Service();
75     m_service->initialize(2);
76
77     MyFunctor *test_busreset=new MyFunctor();
78
79     printf(" adding (%p) as busreset handler\n", test_busreset);
80
81     m_service->addBusResetHandler(test_busreset);
82
83     nodeaddr_t addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 );
84
85     ARMHandler *test_arm=new ARMHandler(addr,
86                          4,
87                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
88                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
89                          0);
90
91     printf(" adding (%p) as arm handler\n", test_arm);
92
93     if (!m_service->registerARMHandler(test_arm)) {
94         printf("  failed\n");
95     }
96
97     addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 );
98
99     ARMHandler *test_arm2=new ARMHandler(addr,
100                          4,
101                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
102                          RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK,
103                          0);
104
105     printf(" adding (%p) as arm handler\n", test_arm2);
106
107     if (!m_service->registerARMHandler(test_arm2)) {
108         printf("  failed\n");
109     }
110
111     while(run) {
112         fflush(stderr);
113         fflush(stdout);
114         sleep(1);
115     }
116
117     delete m_service;
118     delete test_busreset;
119     delete test_arm;
120     delete test_arm2;
121
122     printf("Bye...\n");
123
124     return EXIT_SUCCESS;
125 }
Note: See TracBrowser for help on using the browser.