]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/examples/spy/ortespy.c
updated email address - petr@smoliku.cz
[orte.git] / orte / examples / spy / ortespy.c
index dcf1f11ad51dc9939d067d2651a597a3a9da7c04..cfcc751aa5bd9d6671bbb2cdd1c022c1de2f1f3e 100644 (file)
@@ -2,9 +2,19 @@
  *  $Id: ortespy.c,v 0.0.0.1            2003/10/07 
  *
  *  DEBUG:  section                     ortespy
- *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
  *
- *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
+ *  -------------------------------------------------------------------  
+ *                                ORTE                                 
+ *                      Open Real-Time Ethernet                       
+ *                                                                    
+ *                      Copyright (C) 2001-2006                       
+ *  Department of Control Engineering FEE CTU Prague, Czech Republic  
+ *                      http://dce.felk.cvut.cz                       
+ *                      http://www.ocera.org                          
+ *                                                                    
+ *  Author:             Petr Smolik    petr@smoliku.cz             
+ *  Advisor:            Pavel Pisa                                   
+ *  Project Responsible: Zdenek Hanzalek                              
  *  --------------------------------------------------------------------
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -24,7 +34,7 @@
 #ifndef _WIN32
   #include <signal.h>
 #endif
-#include "orte_api.h"
+#include "orte.h"
 #ifdef HAVE_CONFIG_H
   #ifdef HAVE_GETOPT_H
     #include <getopt.h>
 #endif
 #include "string.h"
 
-ORTEDomain              *d;
-NtpTime                 deadline,minimumSeparation;
-int32_t                 instanceRecv;
+#ifdef MAIN_RENAMED
+#define main orte_spy_main
+#define exit return
+#endif
+
+static ORTEDomain              *d;
+static NtpTime                 deadline,minimumSeparation;
+static int32_t                 instanceRecv;
 
-void
+static void
 recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam) {
   char lbuff[MAX_STRING_NTPTIME_LENGTH];
   char rbuff[MAX_STRING_NTPTIME_LENGTH];
@@ -55,15 +70,15 @@ recvCallBack(const ORTERecvInfo *info,void *vinstance, void *recvCallBackParam)
              NtpTimeToStringUs(info->remoteTimePublished, rbuff));
       break;
     case DEADLINE:
-//      printf("deadline occured\n");
+//      printf("deadline occurred\n");
       break;
   }
 }
 
 ORTESubscription*
 subscriptionCallBack(const char *topic, const char *type, void *param) {
-  ORTETypeRegisterAdd(d,type,NULL,NULL,0);   
-  if (strcmp(topic,"Red")==0) return NULL;
+  ORTETypeRegisterAdd(d,type,NULL,NULL,NULL,0);   
+  if (strcmp((const char *)topic, (const char*)"Red")==0) return NULL;
   return ORTESubscriptionCreate(
         d,
         IMMEDIATE,
@@ -74,7 +89,8 @@ subscriptionCallBack(const char *topic, const char *type, void *param) {
         &deadline,
         &minimumSeparation,
         recvCallBack,
-        NULL);
+        NULL,
+        IPADDRESS_INVALID);
 }
 
 static void usage(void) {
@@ -86,6 +102,7 @@ static void usage(void) {
   printf("  -R, --refresh <s>             refresh period in second(s)\n");
   printf("  -P, --purge <s>               purge time in second(s)\n");
   printf("  -e, --expiration <s>          expiration time of manager in second(s)\n");
+  printf("  -I, --metaMulticast <IPAdd>   use multicast IPAddr for metatraffic comm.\n");
   printf("  -l, --logfile <filename>      set log file name\n");
   printf("  -V, --version                 show version\n");
   printf("  -h, --help                    this usage screen\n");
@@ -99,6 +116,7 @@ int main(int argc,char *argv[]) {
     { "refresh",1,0, 'R' },
     { "purge",1,0, 'P' },
     { "expiration",1,0, 'E' },
+    { "metaMulticast",1,0, 'I' },
     { "logfile",1,0, 'l' },
     { "version",0,0, 'V' },
     { "help",  0, 0, 'h' },
@@ -114,9 +132,9 @@ int main(int argc,char *argv[]) {
   NTPTIME_BUILD(minimumSeparation,0); 
 
 #if defined HAVE_GETOPT_LONG || defined HAVE_GETOPT_LONG_ORTE
-  while ((opt = getopt_long(argc, argv, "d:v:R:E:P:l:Vh",&long_opts[0], NULL)) != EOF) {
+  while ((opt = getopt_long(argc, argv, "d:v:R:E:I:P:l:Vh",&long_opts[0], NULL)) != EOF) {
 #else
-  while ((opt = getopt(argc, argv, "d:v:R:E:P:l:Vh")) != EOF) {
+  while ((opt = getopt(argc, argv, "d:v:R:E:I:P:l:Vh")) != EOF) {
 #endif
     switch (opt) {
       case 'd':
@@ -134,10 +152,14 @@ int main(int argc,char *argv[]) {
       case 'E':
         NtpTimeAssembFromMs(dp.baseProp.expirationTime,strtol(optarg,NULL,0),0);
         break;
+      case 'I':
+        dp.multicast.enabled=ORTE_TRUE;
+        dp.multicast.ipAddress=StringToIPAddress(optarg);
+        break; 
       case 'l':
         ORTEVerbositySetLogFile(optarg);
       case 'V':
-        printf("Ocera Real-Time Ethernet (%s).\n",dp.version);
+        printf("Open Real-Time Ethernet (%s).\n",dp.version);
         exit(0);
         break;
       case 'h':
@@ -153,7 +175,7 @@ int main(int argc,char *argv[]) {
   printf("|------------------------------------------------------------------------------|\n");
   d=ORTEDomainAppCreate(domain,&dp,NULL,ORTE_TRUE);
   ORTEDomainAppSubscriptionPatternAdd(d,"*","*",subscriptionCallBack,NULL);
-  ORTEDomainStart(d,ORTE_TRUE,ORTE_TRUE,ORTE_TRUE);
+  ORTEDomainStart(d,ORTE_TRUE,ORTE_FALSE,ORTE_TRUE,ORTE_FALSE,ORTE_TRUE);
   while (1) {
     ORTESleepMs(1000);
   }