EdgeGateway_FSU/DevicePortGet/TimeAligned_Src/TimeAligned.c

77 lines
2.6 KiB
C
Raw Normal View History

2024-03-15 17:25:04 +08:00
/***************************************************************
Copyright © huijue Network Co., Ltd. 1998-2129. All rights reserved.
Copyright © 1998-2129. All rights reserved.
: TimeAligned.c
: kooloo
: V1.0
: /FSU
: iMX6ULL
: linux-imx-4.1.15-2.1.0-g3dc0a4b-v2.7
gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf
: V1.0 2023/7/15 kooloo
***************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "public.h" //公共函数头文件
#include "mslog.h"
int main(int argc, char *argv[])
{
int ret;
//设置日志级别为more打开标准输出、打印所在行数和函数名、文件日志功能
//设置日志目录为:/tmp/mslog;
//设置日志文件为mslog_sample.txt;
//FLAG为LOG_API_TEST或TAG_TEST2的日志不进行打印;
// mslog_api_init((mslog_level_warn|mslog_enable_stdprint|mslog_enable_linefunc|mslog_enable_filelog),
// "/tmp/mslog","mslog_fsu.txt","LOG_API_TEST|TAG_TEST2");
mslog_api_init(C_MSLOG_FLAG_TA,S_MSLOGDIR_PATH,S_MSLOGFILE_NAME_TA,"LOG_API_TEST|TAG_TEST2");
printf("TimeAlignedApp \n"); //开机 程序打印信息 做区分使用
/* 打印进程信息及编译时间 */
ms_info1("TimeAlignedApp process\n");
ms_info1("Make time is: %s %s\n", __DATE__, __TIME__);
ms_info1("Boot time calibration!\n");
ret=system("ntpdate time.pool.aliyun.com");
if (-1 == ret)
{
ms_error1("System Time cal Fail!\n");
ret=system("ntpdate time.windows.com");
if (-1 == ret)
{
ms_error1("System Time cal Fail!\n");
ret=system("ntpdate ntp1.aliyun.com");
if (-1 == ret)
{
ms_error1("System Time cal Fail!\n");
// ret=system("date -s '2023-10-20 18:04:20'");
goto EXIT; //无法更新时间 直接退出
}
else
{
ms_info1("Time Calibration Successful!\n");
}
}
else
{
ms_info1("Time Calibration Successful!\n");
}
}
else
{
ms_info1("Time Calibration Successful!\n");
}
ret=system("hwclock --localtime --systohc");
if (-1 == ret)
{
ms_error1("RTC Set Fail!\n");
}
else
{
ms_info1("RTC Set Successful!\n");
}
EXIT:
exit(0);
}