rem: if (resp[0] == STATUS_CMD_OK) {
add: if ((resp[0] == CMD_SIGN_ON) && (resp[1] == STATUS_CMD_OK)) { #if 0 int i; fprintf(stderr, "found programmer type: "); for (i=0; i<resp[2]; i++) { fprintf(stderr, "%c", resp[3+i]); } fprintf(stderr, "\n"); #endif
context: static int stk500v2_getsync(PROGRAMMER * pgm) {  int tries = 0;  unsigned char buf[1], resp[32];  int status;  DEBUG("STK500V2: stk500v2_getsync()\n");retry:  tries++;  // send the sync command and see if we can get there  buf[0] = CMD_SIGN_ON;  stk500v2_send(pgm, buf, 1);  // try to get the response back and see where we got  status = stk500v2_recv(pgm, resp, sizeof(resp));  // if we got bytes returned, check to see what came back  if (status > 0) {    if (resp[0] == STATUS_CMD_OK) {      // success!      return 0;    } else {      if (tries > 33) {        fprintf(stderr,                "%s: stk500v2_getsync(): can't communicate with device: resp=0x%02x\n",                progname, resp[0]);        return -6;      } else        goto retry;    }  // or if we got a timeout  } else if (status == -1) {    if (tries > 33) {      fprintf(stderr,"%s: stk500v2_getsync(): timeout communicating with programmer\n",              progname);      return -1;    } else      goto retry;  // or any other error  } else {    if (tries > 33) {      fprintf(stderr,"%s: stk500v2_getsync(): error communicating with programmer: (%d)\n",              progname,status);    } else      goto retry;  }  return 0;}