]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
added tcp server to trbcmd, Boris, Jan
authorhadeshyp <hadeshyp>
Wed, 3 Feb 2010 18:37:29 +0000 (18:37 +0000)
committerhadeshyp <hadeshyp>
Wed, 3 Feb 2010 18:37:29 +0000 (18:37 +0000)
libtrbnet/trbcmd.c

index 7ff39b61db5144d2d436ceee7ab0acb978c17b6e..cfc4502dce8a833e4ff62af0c541c311fe5b59b6 100644 (file)
@@ -1,9 +1,9 @@
 /*
-*              Changes by Boris:
+*              Changes by Boris and Jan:
 *
 *                      1. Original code is in a sub-routine called start()
-*                      2. usage has a tcp parameter
-*                      3. main() can enter a tcp loop or just call start()
+*                      2. main() can enter a tcp loop (if called with attribute \"tcp\") or just call start() (otherwise)
+*
 *
 */
 
@@ -45,7 +45,7 @@ static FILE * STDERR;
 
 static int hexMode = HEXMODE;
 
-static const char trbcmd_version[] = "$Revision: 2.40 $";
+static const char trbcmd_version[] = "$Revision: 2.41 $";
 
 /* ---- User Buffer Size ----------------------------------------------- */
 
@@ -59,8 +59,8 @@ void usage(const char *progName)
   fprintf(STDOUT, "Usage: %s [-h] [-f script-file] [-n number] [-d level] "
          "[-H] [-V] <COMMAND>\n", progName);
   fprintf(STDOUT, "Options:\n");
+  fprintf(STDOUT, "  --tcp  start in TCP/IP-server mode (!)\n");
   fprintf(STDOUT, "  -h    give this help\n");
-  fprintf(STDOUT, "  -tcp  start in TCP/IP-server mode (!)\n");
   fprintf(STDOUT, "  -f    execute commands given in script-file\n");
   fprintf(STDOUT, "  -n    repeat COMMAND number times, -1 = endless loop\n");
   fprintf(STDOUT, "  -M    turn on HighMemoryMode (maximum usage is 20MByte, default: "
@@ -375,27 +375,7 @@ int start(int argc, char ** argv, char* command){
                     trb_strterm(trb_term));
           }
         }
-        
-//<<<<<<< trbcmd.c
-//        for (i = 0; i < status; i += 2) {
-//          fprintf(STDOUT, "0x%04x  0x%08x\n",
-//                  data[i], data[i + 1]);
-//        }
-             
-        /* Check Status-Bits */
-        /////////////////////////////////////////////////////////////////////////////////
-        // BORIS for the HUB:
-        /*if ((trb_term.status_common != 0x01) || 
-            (trb_term.status_channel != 0)) {
-          if (scriptFile != NULL) {
-            fprintf(STDERR, "Line #%d: ", lineCtr);
-          }
-          fprintf(STDERR, "WARNING Status-Bits:\n%s\n", trb_strterm(trb_term));
-        }*/
-                               //end BORIS /////////////////////////////////////////////////////////////////////
-//=======
         free(data);
-//>>>>>>> 2.39
 
       } else if (strncmp(cmd[0], "rm", CMD_SIZE) == 0) {
       
@@ -462,18 +442,6 @@ int start(int argc, char ** argv, char* command){
                       reg_address + i, *p++);
             }
           }
-//<<<<<<< trbcmd.c
-//        }
-        
-        /* Check Status-Bits */
-        /////////////////////////////////////////////////////////////////////////////////
-        // BORIS for the HUB:
-        /*if ((trb_term.status_common != 0x01) || 
-            (trb_term.status_channel != 0)) {
-          if (scriptFile != NULL) {
-            fprintf(STDERR, "Line #%d: ", lineCtr);
-//=======
-          
           /* Check Status-Bits */
           if ((trb_term.status_common != 0x01) || 
               (trb_term.status_channel != 0)) {
@@ -482,19 +450,10 @@ int start(int argc, char ** argv, char* command){
             }
             fprintf(STDERR, "WARNING Status-Bits:\n%s\n",
                     trb_strterm(trb_term));
-//>>>>>>> 2.39
           }
-//<<<<<<< trbcmd.c
-//          fprintf(STDERR, "WARNING Status-Bits:\n%s\n", trb_strterm(trb_term));
-//        }*/
-        /////////////////////////////////////////////////////////////////////////////////
-//        if (data != NULL) free(data);
-//=======
         }
-        
         free(data);
 
-//>>>>>>> 2.39
       } else if (strncmp(cmd[0], "wm", CMD_SIZE) == 0) {
     
         /*******************************************/
@@ -1154,7 +1113,7 @@ int main(int argc, char ** argv)
        
        
        
-       if (argc == 2 && strcmp(argv[1], "tcp") == 0){
+       if (argc == 2 && strcmp(argv[1], "--tcp") == 0){
        
        
        // TCP/IP SERVER INIT
@@ -1203,13 +1162,9 @@ int main(int argc, char ** argv)
                // Init values and memory
                //***********************
                int mainStatus = 1;
-               int len, bytes_sent;
                char command[256];
                int bytes_got;
        int status = 1;
-               int i,j;
-               char buffer[32];
-               char response[256000];
   
                // Enter an infinite loop
                // to acquire instructions