EdgeGateway_FSU/DevicePortGet/TimeAligned_Src/TimeAligned.c

77 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/***************************************************************
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);
}