IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 14, 2005, 10:33:53 AM (21 years ago)
Author:
eugene
Message:

cleanup up communications for speed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r4762 r4763  
    2525  gettimeofday (&stop, (void *) NULL);
    2626  dtime = DTIME (stop, start);
    27   if (VerboseMode()) fprintf (stderr, "check job status %f\n", dtime);
     27  /* if (VerboseMode()) fprintf (stderr, "check job status %f\n", dtime); */
    2828
    2929  if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
     
    3232    gettimeofday (&stop, (void *) NULL);
    3333    dtime = DTIME (stop, start);
    34     if (VerboseMode()) fprintf (stderr, "get stdout %f\n", dtime);
    35 
     34    /* if (VerboseMode()) fprintf (stderr, "get stdout %f\n", dtime); */
     35
     36    gettimeofday (&start, (void *) NULL);
    3637    GetJobOutput ("stderr", job[0].pid, &job[0].stderr, job[0].stderr_size);
     38    gettimeofday (&stop, (void *) NULL);
     39    dtime = DTIME (stop, start);
     40    /* if (VerboseMode()) fprintf (stderr, "get stderr %f\n", dtime); */
     41
     42    gettimeofday (&start, (void *) NULL);
    3743    DeleteControllerJob (job);
     44    gettimeofday (&stop, (void *) NULL);
     45    dtime = DTIME (stop, start);
     46    /* if (VerboseMode()) fprintf (stderr, "delete job %f\n", dtime); */
    3847  } 
    3948  return (TRUE);
     
    138147  if (status == -1) return (CONTROLLER_HUNG);
    139148
    140   if (VerboseMode()) fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd); 
     149  /* if (VerboseMode()) fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd);   */
    141150  /* drop extra bytes from pcontrol (not pclient:job) */
    142151  buffer[0].Nbuffer = Nstart + Nbytes;
     
    328337  FlushIOBuffer (buffer);
    329338
    330   if (VerboseMode()) fprintf (stderr, "send: %s\n", cmd);
    331 
    332339  /* send command, is pipe still open? */
    333340  status = write_fmt (stdin_cntl, "%s\n", cmd);
    334341  if ((status == -1) && (errno == EPIPE)) {
    335     ControllerStatus = FALSE;
     342    StopController ();
    336343    if (VerboseMode()) fprintf (stderr, "controller is down\n");
    337344    return (FALSE);
     
    347354  }
    348355  if (status ==  0) {
    349     ControllerStatus = FALSE;
     356    StopController ();
    350357    if (VerboseMode()) fprintf (stderr, "controller is down\n");
    351358    return (FALSE);
    352359  }
    353360  if (status == -1) {
     361    StopController ();
    354362    if (VerboseMode()) fprintf (stderr, "controller is not responding\n");
    355363    return (FALSE);
     
    362370    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
    363371  }
    364   if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i);
     372  /* if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i); */
    365373  return (TRUE);
    366374}
     
    428436int QuitController () {
    429437
    430   int i, status, waitstatus, result;
     438  int status;
    431439  char cmd[128];
    432440  IOBuffer buffer;
     
    436444  sprintf (cmd, "quit");
    437445  InitIOBuffer (&buffer, 0x100);
    438   status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
    439   FreeIOBuffer (&buffer);
     446  status = ControllerCommand (cmd, "", &buffer);
     447  FreeIOBuffer (&buffer);
     448
     449  /* the quit command does not return a prompt, so we always
     450     get an error on the controller here */
     451  StopController ();
     452  return (TRUE);
     453}
     454
     455int StopController () {
     456
     457  int i, waitstatus, result;
     458
     459  if (!ControllerStatus) return (TRUE);
    440460
    441461  ControllerStatus = FALSE;
     
    451471  FreeIOBuffer (&stdout_buffer);
    452472  FreeIOBuffer (&stderr_buffer);
    453 
    454   return (TRUE);
    455 }
     473  return (TRUE);
     474}
Note: See TracChangeset for help on using the changeset viewer.