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.
30 Boolean quite=ORTE_FALSE;
33 recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam) {
34 u_int32_t *instance=(u_int32_t*)vinstance;
36 switch (info->status) {
39 printf("received fresh issue %d\n",*instance);
42 printf("deadline occured\n");
48 sendCallBack(const ORTESendInfo *info,void *vinstance, void *sendCallBackParam) {
49 u_int32_t *instance=(u_int32_t*)vinstance;
51 switch (info->status) {
55 printf("sent issue %d\n",*instance);
57 case CQL: //criticalQueueLevel
62 static void usage(void) {
63 printf("usage: ORTEPing <parameters> \n");
64 printf(" -d, --domain <domain> working manager domain\n");
65 printf(" -p, --publisher create publisher Ping,PingData\n");
66 printf(" -S, --strength strength of publisher <1>\n");
67 printf(" -D, --delay <ms> delay between two publications <1000>\n");
68 printf(" -s, --subscriber create subscriber Ping,PingData\n");
69 printf(" -R, --refresh <s> refresh period of application\n");
70 printf(" -P, --purge <s> purge time for services\n");
71 printf(" -E, --expiration <s> expiration time of application\n");
72 printf(" -m, --minimumSeparation <s> minimumSeparation between two issues\n");
73 printf(" -v, --verbosity <level> set verbosity level SECTION, up to LEVEL:...\n");
74 printf(" examples: ORTEManager -v 51,7:32,5 sections 51 and 32\n");
75 printf(" ORTEManager -v ALL,7 all sections up to level 7\n");
76 printf(" -q --quiet \n");
77 printf(" -l, --logfile <filename> set log file name\n");
78 printf(" -V, --version show version\n");
79 printf(" -h, --help this usage screen\n");
82 int main(int argc,char *argv[]) {
83 static struct option long_opts[] = {
84 { "domain",1,0, 'd' },
85 { "publisher",0,0, 'p' },
86 { "strength",1,0, 'S' },
87 { "subscriber",0,0, 's' },
88 { "refresh",1,0, 'R' },
90 { "expiration",1,0, 'E' },
91 { "minimumSeparation",1,0, 'm' },
93 { "verbosity",1,0, 'v' },
95 { "logfile",1,0, 'l' },
96 { "version",0,0, 'V' },
97 { "help", 0, 0, 'h' },
102 ORTEPublication *p=NULL;
103 ORTESubscription *s=NULL;
104 int opt,domain=ORTE_DEFAULT_DOMAIN;
106 int32_t instanceSend=0,instanceRecv=0;
107 NtpTime persistence,deadline,minimumSeparation,delay;
108 Boolean havePublisher=ORTE_FALSE;
109 Boolean haveSubscriber=ORTE_FALSE;
112 ORTEDomainPropDefaultGet(&dp);
113 NTPTIME_BUILD(minimumSeparation,0);
114 NTPTIME_BUILD(delay,1); //1s
116 while ((opt = getopt_long(argc, argv, "m:S:d:v:R:E:P:l:D:Vhpsq",&long_opts[0], NULL)) != EOF) {
119 strength=strtol(optarg,NULL,0);
122 domain=strtol(optarg,NULL,0);
125 havePublisher=ORTE_TRUE;
128 haveSubscriber=ORTE_TRUE;
131 ORTEVerbositySetOptions(optarg);
134 NtpTimeAssembFromMs(dp.baseProp.refreshPeriod,strtol(optarg,NULL,0),0);
137 NtpTimeAssembFromMs(dp.baseProp.purgeTime,strtol(optarg,NULL,0),0);
140 NtpTimeAssembFromMs(dp.baseProp.expirationTime,strtol(optarg,NULL,0),0);
143 NtpTimeAssembFromMs(minimumSeparation,strtol(optarg,NULL,0),0);
146 NtpTimeAssembFromMs(delay,strtol(optarg,NULL,0)/1000,strtol(optarg,NULL,0)%1000);
149 ORTEVerbositySetLogFile(optarg);
154 printf("Ocera Real-Time Ethernet (%s).\n",dp.version);
160 exit(opt == 'h' ? 0 : 1);
164 d=ORTEDomainAppCreate(domain,&dp,NULL,ORTE_FALSE);
165 //Register ser./deser. rutines with maximal size 4 Bytes
166 ORTETypeRegisterAdd(d,"PingData",NULL,NULL,4);
169 NTPTIME_BUILD(persistence,5);
170 p=ORTEPublicationCreate(
181 if (haveSubscriber) {
182 NTPTIME_BUILD(deadline,3);
183 s=ORTESubscriptionCreate(