2 * $Id: h_subscriber.c,v 0.0.1.0 2005/01/03
4 * DEBUG: section h_subscriber
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
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
15 * Author: Petr Smolik petr@smoliku.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
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.
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.
32 #ifdef CONFIG_ORTE_RTL
33 #include <linux/module.h>
34 #include <posix/pthread.h>
35 #define printf rtl_printf
36 #elif defined CONFIG_ORTE_RTAI
37 #include <linux/module.h>
38 #include <rtai/compat.h>
39 #define printf rt_printk
45 #define main orte_h_subscriber_main
49 static ORTEDomain *d = NULL;
50 static char instance2Recv[64];
53 recvCallBack(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
55 char *instance = (char *)vinstance;
57 switch (info->status) {
59 printf("%s\n", instance);
62 printf("deadline occurred\n");
69 subscriberCreate(void *arg)
72 NtpTime deadline, minimumSeparation;
74 ORTETypeRegisterAdd(d, "HelloMsg", NULL, NULL, NULL, sizeof(instance2Recv));
75 NTPTIME_BUILD(deadline, 10);
76 NTPTIME_BUILD(minimumSeparation, 0);
77 s = ORTESubscriptionCreate(
90 printf("ORTESubscriptionCreate failed\n");
96 #ifndef CONFIG_ORTE_RT
99 main(int argc, char *args[])
102 ORTEVerbositySetOptions("ALL.10");
103 d = ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN, NULL, NULL, ORTE_FALSE);
105 printf("ORTEDomainAppCreate failed!\n");
108 subscriberCreate(NULL);
115 char *verbosity = "";
116 MODULE_PARM(verbosity, "1s");
117 MODULE_PARM_DESC(verbosity, "set verbosity level SECTION, up to LEVEL:...");
118 char *manager = "127.0.0.1";
119 MODULE_PARM(manager, "s");
120 MODULE_PARM_DESC(manager, "IP address of local manager");
121 MODULE_LICENSE("GPL");
125 domainInit(void *arg)
129 ORTEDomainPropDefaultGet(&dp);
130 ORTEVerbositySetOptions(verbosity);
131 dp.appLocalManager = StringToIPAddress(manager);
132 d = ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN, &dp, NULL, ORTE_TRUE);
137 domainDestroy(void *arg)
141 ORTEDomainAppDestroy(d);
149 pthread_create(&thread, NULL, &domainInit, NULL); //allocate resources in RT
150 pthread_join(thread, NULL);
152 ORTEDomainStart(d, ORTE_TRUE, ORTE_FALSE, ORTE_TRUE, ORTE_FALSE, ORTE_TRUE); //application start
153 if (pthread_create(&thread, NULL, &subscriberCreate, NULL) != 0)
154 printf("pthread_create failed!\n");
156 printf("ORTEDomainAppCreate failed!\n");
166 pthread_join(thread, NULL);
167 pthread_create(&thread, NULL, &domainDestroy, NULL);
168 pthread_join(thread, NULL);
171 #endif /* ifndef CONFIG_ORTE_RT */