Beispiel #1
0
cs_int32 cs_sys_log_init()
{
#if 0
    struct stat file_stat;
    DIR *pDir = NULL;

    pDir = opendir("/log");
    if(pDir == NULL)
    {
        if(mkdir("/log", 0) != 0)
        {
            cs_printf("\r\n Open log directory failed.");
            return 0;
        }
    }

    sys_log_ctrl.log_fp = (void *)fopen(sys_log_file,"r+");
    if(sys_log_ctrl.log_fp == NULL)
    {
        sys_log_ctrl.log_fp = (void *)fopen(sys_log_file,"w+");
    }
    fstat(fileno((FILE *)sys_log_ctrl.log_fp), &file_stat);

    if(file_stat.st_size >= MAX_LOG_FILE_SIZE)
    {
        fseek((FILE *)sys_log_ctrl.log_fp , 0 , SEEK_SET);
        fp_cursor = 0;
    }
    else
    {
        fseek((FILE *)sys_log_ctrl.log_fp , 0 , SEEK_END);
        fp_cursor = file_stat.st_size;
    }

    return 0;
#else
    cs_uint32 part_index = flash_part_id_to_part_index(IROS_FLASH_PARTITION_LOG_ID);
    pSysLog = (cs_sys_log_t *)malloc(sizeof(cs_sys_log_t));
    if(pSysLog == NULL)
    {
        cs_printf("Allocate sys log memory failed.\n");
        return 0;
    }
    memcpy(pSysLog , flash_dev.info.super_block.part_tab[part_index].part_loc , sizeof(cs_sys_log_t));
    if(pSysLog->log_magic != 0x12345678)
    {
        memset(pSysLog , 0 , sizeof(cs_sys_log_t));
        pSysLog->log_magic = 0x12345678;
        pSysLog->log_cursor = 0;
    }
    cs_mutex_init(&sys_log_mutex, "syslogmutex", 0);
    cs_circle_timer_add(CS_LOG_WRITE_INTERVAL*1000, cs_sys_log_timer_notify, NULL);
    return 0;
#endif
}
Beispiel #2
0
gw_int32 gw_circle_timer_add(gw_uint32 timeout, void (*callback)(void *), void *data)
{
	return cs_circle_timer_add(timeout, callback, data);
}
Beispiel #3
0
void test_one_cycle_timer()
{
    cs_circle_timer_add(1000,test_timer_proc, &data[1]);
}