Merge pull request #321 from brandonchuang/as7312_54x

[as7312-54x] Support PSU serial number
This commit is contained in:
Jeffrey Townsend
2018-03-08 12:51:11 -08:00
committed by GitHub
3 changed files with 31 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
#include <onlp/onlp.h>
#include <onlplib/file.h>
#include <unistd.h>
#include <fcntl.h>
#include "platform_lib.h"
@@ -173,3 +175,28 @@ int psu_ym2651y_pmbus_info_set(int id, char *node, int value)
return ONLP_STATUS_OK;
}
#define PSU_SERIAL_NUMBER_LEN 18
int psu_serial_number_get(int id, char *serial, int serial_len)
{
int size = 0;
int ret = ONLP_STATUS_OK;
char *prefix = NULL;
if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) {
return ONLP_STATUS_E_PARAM;
}
prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX;
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial");
if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) {
return ONLP_STATUS_E_INTERNAL;
}
serial[PSU_SERIAL_NUMBER_LEN] = '\0';
return ONLP_STATUS_OK;
}

View File

@@ -72,6 +72,7 @@ typedef enum psu_type {
} psu_type_t;
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
int psu_serial_number_get(int id, char *serial, int serial_len);
//#define DEBUG_MODE 1

View File

@@ -102,7 +102,9 @@ psu_ym2651y_info_get(onlp_psu_info_t* info)
if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) {
info->mpout = val;
info->caps |= ONLP_PSU_CAPS_POUT;
}
}
psu_serial_number_get(index, info->serial, sizeof(info->serial));
return ONLP_STATUS_OK;
}