2 * $Id: ortespy.c,v 0.0.0.1 2003/10/07
4 * DEBUG: section ortespy
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 NtpTime deadline,minimumSeparation;
37 recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam) {
38 char lbuff[MAX_STRING_NTPTIME_LENGTH];
39 char rbuff[MAX_STRING_NTPTIME_LENGTH];
40 switch (info->status) {
42 printf("| %-10s | %-9s | %-9s | %-18s | %-18s |\n",
46 NtpTimeToStringUs(info->localTimeReceived, lbuff),
47 NtpTimeToStringUs(info->remoteTimePublished, rbuff));
50 // printf("deadline occured\n");
56 subscriptionCallBack(const char *topic, const char *type, void *param) {
57 ORTETypeRegisterAdd(d,type,NULL,NULL,0);
58 if (strcmp(topic,"Red")==0) return NULL;
59 return ORTESubscriptionCreate(
72 static void usage(void) {
73 printf("usage: ORTESpy <parameters> \n");
74 printf(" -d, --domain <domain> working manager domain\n");
75 printf(" -v, --verbosity <level> set verbosity level SECTION, up to LEVEL:...\n");
76 printf(" examples: ORTEManager -v 51,7:32,5 sections 51 and 32\n");
77 printf(" ORTEManager -v ALL,7 all sections up to level 7\n");
78 printf(" -R, --refresh <s> refresh period in second(s)\n");
79 printf(" -P, --purge <s> purge time in second(s)\n");
80 printf(" -e, --expiration <s> expiration time of manager in second(s)\n");
81 printf(" -l, --logfile <filename> set log file name\n");
82 printf(" -V, --version show version\n");
83 printf(" -h, --help this usage screen\n");
86 int main(int argc,char *argv[]) {
87 static struct option long_opts[] = {
88 { "domain",1,0, 'd' },
89 { "verbosity",1,0, 'v' },
90 { "refresh",1,0, 'R' },
92 { "expiration",1,0, 'E' },
93 { "logfile",1,0, 'l' },
94 { "version",0,0, 'V' },
95 { "help", 0, 0, 'h' },
99 int opt,domain=ORTE_DEFAULT_DOMAIN;
102 ORTEDomainPropDefaultGet(&dp);
103 NTPTIME_BUILD(deadline,3);
104 NTPTIME_BUILD(minimumSeparation,0);
106 while ((opt = getopt_long(argc, argv, "d:v:R:E:P:l:Vh",&long_opts[0], NULL)) != EOF) {
109 domain=strtol(optarg,NULL,0);
112 ORTEVerbositySetOptions(optarg);
115 NtpTimeAssembFromMs(dp.baseProp.refreshPeriod,strtol(optarg,NULL,0),0);
118 NtpTimeAssembFromMs(dp.baseProp.purgeTime,strtol(optarg,NULL,0),0);
121 NtpTimeAssembFromMs(dp.baseProp.expirationTime,strtol(optarg,NULL,0),0);
124 ORTEVerbositySetLogFile(optarg);
126 printf("Ocera Real-Time Ethernet (%s).\n",dp.version);
132 exit(opt == 'h' ? 0 : 1);
136 printf("|------------------------------------------------------------------------------|\n");
137 printf("| %-10s | %-9s | %-9s | %-18s | %-18s |\n",
138 "status", "type","topic","time received", "time sent");
139 printf("|------------------------------------------------------------------------------|\n");
140 d=ORTEDomainAppCreate(domain,&dp,NULL,ORTE_TRUE);
141 ORTEDomainAppSubscriptionPatternAdd(d,"*","*",subscriptionCallBack,NULL);
142 ORTEDomainStart(d,ORTE_TRUE,ORTE_TRUE,ORTE_TRUE);