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