]> rtime.felk.cvut.cz Git - orte.git/blob - orte/examples/reliable/r_subscriber_reliable.c
changed name to Open Real-time Ethernet, some source header arranging
[orte.git] / orte / examples / reliable / r_subscriber_reliable.c
1 /*
2  *  $Id: subscriberreliable.c,v 0.0.0.1 2003/12/27 
3  *
4  *  DEBUG:  section                     subscriber reliable
5  *
6  *  -------------------------------------------------------------------  
7  *                                ORTE                                 
8  *                      Open Real-Time Ethernet                       
9  *                                                                    
10  *                      Copyright (C) 2001-2006                       
11  *  Department of Control Engineering FEE CTU Prague, Czech Republic  
12  *                      http://dce.felk.cvut.cz                       
13  *                      http://www.ocera.org                          
14  *                                                                    
15  *  Author:              Petr Smolik    petr.smolik@wo.cz             
16  *  Advisor:             Pavel Pisa                                   
17  *  Project Responsible: Zdenek Hanzalek                              
18  *  --------------------------------------------------------------------
19  *
20  *  This program is free software; you can redistribute it and/or modify
21  *  it under the terms of the GNU General Public License as published by
22  *  the Free Software Foundation; either version 2 of the License, or
23  *  (at your option) any later version.
24  *  
25  *  This program is distributed in the hope that it will be useful,
26  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  *  GNU General Public License for more details.
29  *  
30  */ 
31
32 #include <stdio.h>
33 #ifdef __RTL__
34   #include <posix/pthread.h>
35 #endif
36 #include "orte.h"
37
38 ORTEDomain        *d;
39 char              instance2Recv[64];
40
41 void
42 recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam) {
43   char *instance=(char*)vinstance;
44   
45   switch (info->status) {
46     case NEW_DATA:
47       printf("%s\n",instance);
48       break;
49     case DEADLINE:
50       printf("deadline occurred\n");
51       break;
52   }
53 }
54
55
56 int 
57 main(int argc, char *args[]) {
58   ORTESubscription *s;
59   NtpTime         deadline,minimumSeparation;
60
61   ORTEInit();
62   //ORTEVerbositySetOptions("ALL,10");
63   d=ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);
64   ORTETypeRegisterAdd(d,"HelloMsg",NULL,NULL,NULL,sizeof(instance2Recv));
65   NTPTIME_BUILD(deadline,3); 
66   NTPTIME_BUILD(minimumSeparation,0); 
67   s=ORTESubscriptionCreate(
68        d,
69        IMMEDIATE,
70        STRICT_RELIABLE,
71        "Reliable HelloMsg",
72        "HelloMsg",
73        &instance2Recv,
74        &deadline,
75        &minimumSeparation,
76        recvCallBack,
77        NULL,
78        IPADDRESS_INVALID);
79   #ifndef CONFIG_ORTE_RT
80   while (1) 
81     ORTESleepMs(1000);
82   #endif
83   return 0;
84 }
85
86 #ifdef CONFIG_ORTE_RT
87 void 
88 hello_init(void) {
89   main(0,NULL);
90 }
91 void 
92 hello_exit(void) {
93   ORTEDomainAppDestroy(d);
94 }
95 MODULE_LICENSE("GPL");
96 module_init(hello_init);
97 module_exit(hello_exit);
98 #endif
99