Ejemplo n.º 1
0
int
main(int argc, char **argv) {

  uint8_t slot_id;
  char tstr[64] = {0};

  if (argc < 3) {
    goto err_exit;
  }

  if (!strcmp(argv[1], "slot1")) {
    slot_id = 1;
  } else if (!strcmp(argv[1] , "slot2")) {
    slot_id = 2;
  } else if (!strcmp(argv[1] , "slot3")) {
    slot_id = 3;
  } else if (!strcmp(argv[1] , "slot4")) {
    slot_id = 4;
  } else if (!strcmp(argv[1] , "sled")) {
    slot_id = 0;
  } else {
    goto err_exit;
  }

  if (!strcmp(argv[2], "--usb")) {
    printf("fpc-util: switching USB channel to slot%d\n", slot_id);
    return pal_switch_usb_mux(slot_id);
  } else if (!strcmp(argv[2], "--identify")) {
    if (argc != 4) {
      goto err_exit;
    }
    printf("fpc-util: identification for %s is %s\n", argv[1], argv[3]);
    if (slot_id == 0) {
      sprintf(tstr, "identify_sled");
    } else {
      sprintf(tstr, "identify_slot%d", slot_id);
    }

    if (strcmp(argv[3] , "on") && strcmp(argv[3] , "off")) {
      goto err_exit;
    }

    return pal_set_key_value(tstr, argv[3]);
  } else {
    goto err_exit;
  }

  return 0;
err_exit:
  print_usage_help();
  return -1;
}
Ejemplo n.º 2
0
static int
set_last_pwr_state(uint8_t fru, char * state) {

  int ret;
  char key[MAX_KEY_LEN] = {0};

  sprintf(key, "pwr_server%d_last_state", (int) fru);

  ret = pal_set_key_value(key, state);
  if (ret < 0) {
    syslog(LOG_ALERT, "set_last_pwr_state: pal_set_key_value failed for "
        "fru %u", fru);
  }
  return ret;
}