|
|
|
@ -56,9 +56,7 @@
|
|
|
|
|
#include "main.h"
|
|
|
|
|
#include "hwgpio.h"
|
|
|
|
|
#include "fifo.h"
|
|
|
|
|
|
|
|
|
|
#include "pd_main.h"
|
|
|
|
|
#include "hwgpio.h"
|
|
|
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
@ -133,7 +131,7 @@ void reboot_system(int module, REBOOT_MSG type)
|
|
|
|
|
|
|
|
|
|
if (pmsg)
|
|
|
|
|
{
|
|
|
|
|
log_out(module, LOG_LVL_WARN, pmsg);
|
|
|
|
|
log_out(module, LOG_LVL_WARN, "%s", pmsg);
|
|
|
|
|
system("sync");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -141,75 +139,6 @@ void reboot_system(int module, REBOOT_MSG type)
|
|
|
|
|
system("reboot -f");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通过RTC-pcf8563系统驱动读写寄存器
|
|
|
|
|
|
|
|
|
|
int32_t rtc_time_set(struct tm tm)
|
|
|
|
|
{
|
|
|
|
|
int rtc_fd;
|
|
|
|
|
struct tm rtc_tm = tm;
|
|
|
|
|
|
|
|
|
|
// 打开 RTC 设备
|
|
|
|
|
rtc_fd = open("/dev/rtc0", O_RDWR);
|
|
|
|
|
if (rtc_fd == -1) {
|
|
|
|
|
DBG(DBG_M_DBG, "Unable to open RTC device\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (ioctl(rtc_fd, RTC_SET_TIME, &rtc_tm) == -1) {
|
|
|
|
|
DBG(DBG_M_DBG, "Unable to set RTC time\n");
|
|
|
|
|
close(rtc_fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_DBG, "RTC time set successfully\n");
|
|
|
|
|
|
|
|
|
|
close(rtc_fd);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t rtc_time_get(struct tm tm)
|
|
|
|
|
{
|
|
|
|
|
time_t timestamp;
|
|
|
|
|
// 定义存储时间的结构体
|
|
|
|
|
struct tm rtc_tm;
|
|
|
|
|
memset(&rtc_tm, 0, sizeof(struct rtc_time));
|
|
|
|
|
|
|
|
|
|
//DBG(DBG_M_DBG, "rtc_time_get start!!!!!!!!\r\n");
|
|
|
|
|
int fd = open("/dev/rtc0", O_RDONLY);
|
|
|
|
|
if (fd == -1) {
|
|
|
|
|
DBG(DBG_M_DBG, "打开设备文件失败 errno: %d\r\n", errno);
|
|
|
|
|
char * mesg = strerror(errno);
|
|
|
|
|
printf("Mesg:%s\n",mesg);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
// 使用 ioctl 调用 RTC_RD_TIME 命令读取时间
|
|
|
|
|
if (ioctl(fd, RTC_RD_TIME, &rtc_tm) == -1) {
|
|
|
|
|
DBG(DBG_M_DBG, "读取时间失败errno: %d\r\n", errno);
|
|
|
|
|
char * mesg = strerror(errno);
|
|
|
|
|
printf("Mesg:%s\n",mesg);
|
|
|
|
|
close(fd);
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
memcpy(&tm, &rtc_tm, sizeof(rtc_tm));
|
|
|
|
|
// 转换为 Unix 时间戳
|
|
|
|
|
timestamp = mktime(&rtc_tm);
|
|
|
|
|
if (timestamp == -1) {
|
|
|
|
|
DBG(DBG_M_DBG, "make Unix time failed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 输出读取到的时间
|
|
|
|
|
#if 0
|
|
|
|
|
DBG(DBG_M_DBG, "当前时间: %04d-%02d-%02d %02d:%02d:%02d\n",
|
|
|
|
|
rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday,
|
|
|
|
|
rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
|
|
|
|
|
//DBG(DBG_M_DBG, "Unix timestamp: %ld\n", timestamp);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
// 关闭设备文件
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* description: 数据处理预初始化.
|
|
|
|
|
param:
|
|
|
|
|
return: (E_NONE)成功,(其他)失败 */
|
|
|
|
@ -266,10 +195,6 @@ int32_t main(int32_t argc, char **argv)
|
|
|
|
|
log_open();
|
|
|
|
|
|
|
|
|
|
log_out(LOG_DEFAULT, LOG_LVL_WARN, "System start!");
|
|
|
|
|
#if 0
|
|
|
|
|
system("/etc/ppp/peers/quectel-ppp-kill");
|
|
|
|
|
sleep(2);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* 设置信号处理的回调函数 */
|
|
|
|
|
act.sa_handler = _signal_handler;
|
|
|
|
@ -306,19 +231,6 @@ int32_t main(int32_t argc, char **argv)
|
|
|
|
|
/* 初始化完成 */
|
|
|
|
|
version_hex = version_str_to_int();
|
|
|
|
|
is_system_init = TRUE;
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
struct tm rtc_tm;
|
|
|
|
|
// 设置当前时间(设置为2025年2月24日 12:00:00)
|
|
|
|
|
rtc_tm.tm_year = 2025 - 1900; // 年份需要减去1900
|
|
|
|
|
rtc_tm.tm_mon = 1; // 2月
|
|
|
|
|
rtc_tm.tm_mday = 24; // 24号
|
|
|
|
|
rtc_tm.tm_wday = 1; //星期一
|
|
|
|
|
rtc_tm.tm_hour = 12;
|
|
|
|
|
rtc_tm.tm_min = 5;
|
|
|
|
|
rtc_tm.tm_sec = 30;
|
|
|
|
|
rtc_time_set(rtc_tm);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* 主循环, 点灯喂狗. */
|
|
|
|
|
for(;;)
|
|
|
|
@ -326,12 +238,6 @@ int32_t main(int32_t argc, char **argv)
|
|
|
|
|
sleep(1);
|
|
|
|
|
start_time++;
|
|
|
|
|
cnt++;
|
|
|
|
|
/* 喂狗. */
|
|
|
|
|
if (0 == (cnt & 0x1F))
|
|
|
|
|
{
|
|
|
|
|
feed_dog();
|
|
|
|
|
//rtc_time_get(rtc_tm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|