2 * $Id: orteping.c,v 0.0.0.1 2003/10/07
4 * DEBUG: section orteping
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.
33 #include <unistd.h> //getopt.h for DarWin, Solaris, ...
39 Boolean quite=ORTE_FALSE;
42 recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam) {
43 uint32_t *instance=(uint32_t*)vinstance;
45 switch (info->status) {
48 printf("received fresh issue %d\n",*instance);
51 printf("deadline occured\n");
57 sendCallBack(const ORTESendInfo *info,void *vinstance, void *sendCallBackParam) {
58 uint32_t *instance=(uint32_t*)vinstance;
60 switch (info->status) {
64 printf("sent issue %d\n",*instance);
66 case CQL: //criticalQueueLevel
71 static void usage(void) {
72 printf("usage: orteping <parameters> \n");
73 printf(" -d, --domain <domain> working manager domain\n");
74 printf(" -p, --publisher create publisher Ping,PingData\n");
75 printf(" -S, --strength strength of publisher <1>\n");
76 printf(" -D, --delay <ms> delay between two publications <1000>\n");
77 printf(" -s, --subscriber create subscriber Ping,PingData\n");
78 printf(" -R, --refresh <s> refresh period of application\n");
79 printf(" -P, --purge <s> purge time for services\n");
80 printf(" -E, --expiration <s> expiration time of application\n");
81 printf(" -m, --minimumSeparation <s> minimumSeparation between two issues\n");
82 printf(" -v, --verbosity <level> set verbosity level SECTION, up to LEVEL:...\n");
83 printf(" examples: ORTEManager -v 51.7:32.5 sections 51 and 32\n");
84 printf(" ORTEManager -v ALL.7 all sections up to level 7\n");
85 printf(" -q --quiet \n");
86 printf(" -l, --logfile <filename> set log file name\n");
87 printf(" -V, --version show version\n");
88 printf(" -h, --help this usage screen\n");
91 int main(int argc,char *argv[]) {
92 #if defined HAVE_GETOPT_LONG || defined HAVE_GETOPT_LONG_ORTE
93 static struct option long_opts[] = {
94 { "domain",1,0, 'd' },
95 { "publisher",0,0, 'p' },
96 { "strength",1,0, 'S' },
97 { "subscriber",0,0, 's' },
98 { "refresh",1,0, 'R' },
100 { "expiration",1,0, 'E' },
101 { "minimumSeparation",1,0, 'm' },
102 { "delay",1,0, 'D' },
103 { "verbosity",1,0, 'v' },
104 { "quiet",0,0, 'q' },
105 { "logfile",1,0, 'l' },
106 { "version",0,0, 'V' },
107 { "help", 0, 0, 'h' },
113 ORTEPublication *p=NULL;
114 ORTESubscription *s=NULL;
115 int opt,domain=ORTE_DEFAULT_DOMAIN;
117 int32_t instanceSend=0,instanceRecv=0;
118 NtpTime persistence,deadline,minimumSeparation,delay;
119 Boolean havePublisher=ORTE_FALSE;
120 Boolean haveSubscriber=ORTE_FALSE;
123 ORTEDomainPropDefaultGet(&dp);
124 NTPTIME_BUILD(minimumSeparation,0);
125 NTPTIME_BUILD(delay,1); //1s
127 #if defined HAVE_GETOPT_LONG || defined HAVE_GETOPT_LONG_ORTE
128 while ((opt = getopt_long(argc, argv, "m:S:d:v:R:E:P:l:D:Vhpsq",&long_opts[0], NULL)) != EOF) {
130 while ((opt = getopt(argc, argv, "m:S:d:v:R:E:P:l:D:Vhpsq")) != EOF) {
134 strength=strtol(optarg,NULL,0);
137 domain=strtol(optarg,NULL,0);
140 havePublisher=ORTE_TRUE;
143 haveSubscriber=ORTE_TRUE;
146 ORTEVerbositySetOptions(optarg);
149 NtpTimeAssembFromMs(dp.baseProp.refreshPeriod,strtol(optarg,NULL,0),0);
152 NtpTimeAssembFromMs(dp.baseProp.purgeTime,strtol(optarg,NULL,0),0);
155 NtpTimeAssembFromMs(dp.baseProp.expirationTime,strtol(optarg,NULL,0),0);
158 NtpTimeAssembFromMs(minimumSeparation,strtol(optarg,NULL,0),0);
161 NtpTimeAssembFromMs(delay,strtol(optarg,NULL,0)/1000,strtol(optarg,NULL,0)%1000);
164 ORTEVerbositySetLogFile(optarg);
169 printf("Ocera Real-Time Ethernet (%s).\n",dp.version);
175 exit(opt == 'h' ? 0 : 1);
179 d=ORTEDomainAppCreate(domain,&dp,NULL,ORTE_FALSE);
180 //Register ser./deser. rutines with maximal size 4 Bytes
181 ORTETypeRegisterAdd(d,"PingData",NULL,NULL,4);
184 NTPTIME_BUILD(persistence,5);
185 p=ORTEPublicationCreate(
196 if (haveSubscriber) {
197 NTPTIME_BUILD(deadline,3);
198 s=ORTESubscriptionCreate(