#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <ctype.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/mman.h>
#include "osp.h"
#include "ospShell.h"
#include "ospDbg.h"
#include "ospSoftQue.h"
#include "ospBuf.h"
#include "ospTimer.h"
#include "ospHeap.h"
#include "ospTypes.h"
#include "ucp_printf.h"
#include "ospHeap.h"
#include "ospDump.h"
#include "ospSwQueue.h"
#include "pet_sm_mgt.h"
#include "msg_transfer_layer.h"
#include "ospHeartbeat.h"
#include "ospVersion.h"


/* print软件版本信息 */
void osp_soft_version_show()
{
    char buf[4096];
    int32_t len = 0;

    /* show arm version */
    len = sprintf(buf, "\n\r[ARM]\n\rVersion:\t%s\n\rTag:\t\t%s\n\rBuild Date:\t%s\n\r", ARM_VERSION, ARM_TAG, ARM_BUILD_DATE);
    osp_net_shell_out(buf, len);

    /* show spuversion */
    osp_ape_msg_send("ver_spu");

    return;
}

/*
 * @brief: 获取ARM版本信息
 * @author: haochen.zhang
 * @Date:  2024.5.14
 * @param: pVersion [out] : 版本信息结构体
 */
int32_t osp_arm_version_get(OspVersionInfo_t *pVersion)
{
    if (NULL == pVersion) {
        return OSP_PAR_ILL;
    }

    if ((sizeof(ARM_VERSION) > MAX_BUF_VERSION_LEN) || (sizeof(ARM_TAG) > MAX_BUF_VERSION_LEN) || (sizeof(ARM_BUILD_DATE) > MAX_BUF_VERSION_LEN/2)) {
        return OSP_ERROR;
    }

    memcpy((void *)&pVersion->platform_commit, (void *)ARM_VERSION, sizeof(ARM_VERSION));
    memcpy((void *)&pVersion->platform_tag, (void *)ARM_TAG, sizeof(ARM_TAG));
    memcpy((void *)&pVersion->platform_build_date, (void *)ARM_BUILD_DATE, sizeof(ARM_BUILD_DATE));

    return OSP_OK;
}

