IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36145


Ignore:
Timestamp:
Sep 23, 2013, 12:53:45 PM (13 years ago)
Author:
eugene
Message:

deal with some garbage in the pcontrol communication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/Ohana/src/opihi/pantasks/CheckController.c

    r23530 r36145  
    2929  if (p != NULL) goto escape;
    3030
     31  /** skip past any leading garbage? ***/
     32
     33  /** find "Njobs: **/
     34  p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256));
     35  p += strlen("BEGIN BLOCK Njobs:");
     36
    3137  /** parse job list **/
    32   status = sscanf (buffer.buffer, "%*s %d", &Njobs);
     38  status = sscanf (p, "%d", &Njobs);
    3339  if (status != 1) goto escape;
    3440  if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(&start, TRUE));
    3541
    36   p = buffer.buffer;
     42  /* output looks like:
     43     BEGIN BLOCK Njobs: NN\n
     44     ID name machine\n
     45     ID name machine\n
     46  */
     47
     48  // p is currently pointing at "BEGIN BLOCK Njobs"
     49
    3750  for (i = 0; i < Njobs; i++) {
    3851    q = strchr (p, '\n');
     
    6780  if (p != NULL) goto escape;
    6881
     82  /** skip past any leading garbage? ***/
     83
     84  /** find "Njobs: **/
     85  p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256));
     86  p += strlen("BEGIN BLOCK Njobs:");
     87
    6988  /** parse job list **/
    70   status = sscanf (buffer.buffer, "%*s %d", &Njobs);
     89  status = sscanf (p, "%d", &Njobs);
    7190  if (status != 1) goto escape;
    7291  if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(&start, TRUE));
    7392
    74   p = buffer.buffer;
     93  /* output looks like:
     94     BEGIN BLOCK Njobs: NN\n
     95     ID name machine\n
     96     ID name machine\n
     97  */
     98
     99  // p is currently pointing at "BEGIN BLOCK Njobs"
     100
    75101  for (i = 0; i < Njobs; i++) {
    76102    q = strchr (p, '\n');
Note: See TracChangeset for help on using the changeset viewer.