root/branches/streaming-rework/tests/test-ieee1394service.cpp

Revision 414, 3.6 kB (checked in by pieterpalmers, 17 years ago)

extended ARM handler functionality

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