NRF_LOG_FLUSH not supported anymore. Alternatives?

Hello,

I have the Situation that my System shall go to System off mode but as there are still logging items stored and the logging Output timer is still running, it takes nearly one second to until the System really goes to System off.

In older times there seems to exist a NRF_LOG_FLUSH macro. But now not anymore. BTW: I'm using SDK Version 1.9.1

Practically it's clear what I have to do: 

k_timer_stop(&log_process_thread_timer);
k_sem_give(&log_process_thread_sem);

have to be called. Then the Task is scheduled and all pending items are handled. Unfortunately all this stuff is static/private in log_core.c.

Is there a way to get this done without changing/pathing Zephyr Code?

I have set CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD to 10 and CONFIG_LOG_PROCESS_THREAD_SLEEP_MS to 1000. In principle it's fine to have such a Long Sleep time. When I have other stuff to do logging is not Output. Therefore changing CONFIG_LOG_PROCESS_THREAD_SLEEP_MS to a lower value (50 or even 10) would (I guess, haven't tried yet) also reduce my wait time. But then I have quite often Task switches to the logging Task even there is no item pending.

Any suggestions?

Erwin

  • We don't use pm_state_force. Can it even be that this is not available in SDK Version 1.9.1 (which we still use)? We work with pm_policy_next_state and Keep the rest to Zephyr.

    struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
    {
        if (ticks < 2147483647)  //K_TICKS_FOREVER doesn't work here. It's even normally a 64bit integer
        {
            //There is still something in the system that waits for a dedicated time
            return (struct pm_state_info){PM_STATE_RUNTIME_IDLE, 0, 0, 0};
        }
    
        //No-one is waiting for someone. We can go into system off mode
    
        if (prepareSleep())
        {
            //When this function is called the first time, it simply sends a message to another task
            //that does the real preparation (including some log outputs). prepareSleep returns then 
            //false.
            //When this function is called the second time (so the task has done the preparation)
            //the function returns true
            //Still do here some pin configuration
            gpio_pin_configure_dt(&LedRedPinSpec, GPIO_OUTPUT_LOW);
            gpio_pin_configure_dt(&LedGreenPinSpec, GPIO_OUTPUT_LOW);
            gpio_pin_configure_dt(&LedBluePinSpec, GPIO_OUTPUT_LOW);
            return (struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0, 0};
        }
        return (struct pm_state_info){PM_STATE_RUNTIME_IDLE, 0, 0, 0};
    }
    

Related