2 * $Id: HelloWorldPublisher.c,v 0.0.0.1 2003/12/26
4 * DEBUG: section HelloWorldPublisher
5 * AUTHOR: Petr Smolik petr.smolik@wo.cz
7 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
8 * --------------------------------------------------------------------
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.
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.
23 #include <orte_config.h>
26 #ifdef CONFIG_ORTE_RTL
27 #include <linux/module.h>
28 #include <posix/pthread.h>
29 #define printf rtl_printf
30 #elif defined CONFIG_ORTE_RTAI
31 #include <linux/module.h>
32 #include <rtai/compat.h>
33 #define printf rt_printk
39 char instance2Send[64];
43 sendCallBack(const ORTESendInfo *info,void *vinstance, void *sendCallBackParam) {
44 char *instance=(char*)vinstance;
46 switch (info->status) {
48 printf("Sampling publication, count %d\n", counter);
49 sprintf(instance,"Hello Universe! (%d)",counter++);
51 case CQL: //criticalQueueLevel
57 publisherCreate(void *arg) {
59 NtpTime persistence, delay;
61 ORTETypeRegisterAdd(d,"HelloMsg",NULL,NULL,64);
62 NTPTIME_BUILD(persistence,3);
63 NTPTIME_BUILD(delay,1);
64 p=ORTEPublicationCreate(
78 #ifndef CONFIG_ORTE_RT
81 main(int argc, char *args[]) {
83 d=ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);
85 printf("ORTEDomainAppCreate failed!\n");
88 publisherCreate((void*)d);
96 char *manager="127.0.0.1";
97 MODULE_PARM(manager,"1s");
98 MODULE_PARM_DESC(manager,"IP address of local manager");
99 MODULE_LICENSE("GPL");
103 domainDestroy(void *arg) {
105 ORTEDomainAppDestroy(d);
113 ORTEDomainPropDefaultGet(&dp);
114 dp.appLocalManager=StringToIPAddress(manager);
115 d=ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN,&dp,NULL,ORTE_FALSE);
117 pthread_create(&thread,NULL,&publisherCreate,NULL);
119 printf("ORTEDomainAppCreate failed!\n");
125 cleanup_module(void) {
127 pthread_join(thread,NULL);
128 pthread_create(&thread,NULL,&domainDestroy,NULL);
129 pthread_join(thread,NULL);