examples/TestMasterSlaveLSS/TestMasterSlaveLSS.c
changeset 387 6efc85c5493e
parent 384 83793fc7ce48
child 454 bc000083297a
equal deleted inserted replaced
386:0f56a144ba5f 387:6efc85c5493e
    58 #endif
    58 #endif
    59 
    59 
    60 void help()
    60 void help()
    61 {
    61 {
    62   printf("**************************************************************\n");
    62   printf("**************************************************************\n");
    63   printf("*  TestMasterSlaveLSS                                           *\n");
    63   printf("*  TestMasterSlaveLSS                                        *\n");
    64   printf("*                                                            *\n");
    64   printf("*                                                            *\n");
    65   printf("*  A LSS example for PC. It does implement 3 CanOpen      *\n");
    65   printf("*  A LSS example for PC. It does implement 3 CanOpen         *\n");
    66   printf("*  nodes in the same process. A master and 2 slaves. Both     *\n");
    66   printf("*  nodes in the same process. A master and 2 slaves. All     *\n");
    67   printf("*  communicate together, exchanging periodically NMT, SYNC,  *\n");
    67   printf("*  communicate together, exchanging periodically NMT, SYNC,  *\n");
    68   printf("*  SDO and PDO. Master configure heartbeat producer time     *\n");
    68   printf("*  SDO and PDO. Master configure heartbeat producer time     *\n");
    69   printf("*  at 1000 ms for slave node-id 0x02 by concise DCF.         *\n");                                  
    69   printf("*  at 0 ms for slave node-id 0x02 and 0x03 by concise DCF.   *\n");                                  
    70   printf("*                                                            *\n");
    70   printf("*                                                            *\n");
    71   printf("*   Usage:                                                   *\n");
    71   printf("*   Usage:                                                   *\n");
    72   printf("*   ./TestMasterSlaveLSS  [OPTIONS]                             *\n");
    72   printf("*   ./TestMasterSlaveLSS  [OPTIONS]                          *\n");
    73   printf("*                                                            *\n");
    73   printf("*                                                            *\n");
    74   printf("*   OPTIONS:                                                 *\n");
    74   printf("*   OPTIONS:                                                 *\n");
    75   printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]     *\n");
    75   printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]   *\n");
    76   printf("*                                                            *\n");
    76   printf("*                                                            *\n");
    77   printf("*    SlaveA:                                                  *\n");
    77   printf("*    SlaveA:                                                 *\n");
    78   printf("*     -s : bus name [\"0\"]                                    *\n");
    78   printf("*     -a : bus name [\"0\"]                                  *\n");
    79   printf("*     -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
    79   printf("*     -A : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
       
    80   printf("*                                                            *\n");
       
    81    printf("*    SlaveB:                                                *\n");
       
    82   printf("*     -b : bus name [\"1\"]                                  *\n");
       
    83   printf("*     -B : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
    80   printf("*                                                            *\n");
    84   printf("*                                                            *\n");
    81   printf("*    Master:                                                 *\n");
    85   printf("*    Master:                                                 *\n");
    82   printf("*     -m : bus name [\"1\"]                                    *\n");
    86   printf("*     -m : bus name [\"2\"]                                  *\n");
    83   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
    87   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
    84   printf("*                                                            *\n");
    88   printf("*                                                            *\n");
    85   printf("**************************************************************\n");
    89   printf("**************************************************************\n");
    86 }
    90 }
    87 
    91 
   126 
   130 
   127   int c;
   131   int c;
   128   extern char *optarg;
   132   extern char *optarg;
   129   char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so";
   133   char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so";
   130 
   134 
   131   while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF)
   135   while ((c = getopt(argc, argv, "-m:a:b:M:A:B:l:")) != EOF)
   132   {
   136   {
   133     switch(c)
   137     switch(c)
   134     {
   138     {
   135       case 's' :
   139       case 'a' :
   136         if (optarg[0] == 0)
   140         if (optarg[0] == 0)
   137         {
   141         {
   138           help();
   142           help();
   139           exit(1);
   143           exit(1);
   140         }
   144         }
   141         SlaveBoardA.busname = optarg;
   145         SlaveBoardA.busname = optarg;
   142         break;
   146         break;
       
   147       case 'b' :
       
   148         if (optarg[0] == 0)
       
   149         {
       
   150           help();
       
   151           exit(1);
       
   152         }
       
   153         SlaveBoardB.busname = optarg;
       
   154         break;
   143       case 'm' :
   155       case 'm' :
   144         if (optarg[0] == 0)
   156         if (optarg[0] == 0)
   145         {
   157         {
   146           help();
   158           help();
   147           exit(1);
   159           exit(1);
   148         }
   160         }
   149         MasterBoard.busname = optarg;
   161         MasterBoard.busname = optarg;
   150         break;
   162         break;
   151       case 'S' :
   163       case 'A' :
   152         if (optarg[0] == 0)
   164         if (optarg[0] == 0)
   153         {
   165         {
   154           help();
   166           help();
   155           exit(1);
   167           exit(1);
   156         }
   168         }
   157         SlaveBoardA.baudrate = optarg;
   169         SlaveBoardA.baudrate = optarg;
       
   170         break;
       
   171       case 'B' :
       
   172         if (optarg[0] == 0)
       
   173         {
       
   174           help();
       
   175           exit(1);
       
   176         }
       
   177         SlaveBoardB.baudrate = optarg;
   158         break;
   178         break;
   159       case 'M' :
   179       case 'M' :
   160         if (optarg[0] == 0)
   180         if (optarg[0] == 0)
   161         {
   181         {
   162           help();
   182           help();