Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use kprintf in Component

Shulou Source: shulou.com Published: 2022-06-01 10:29:44 09月26日 Update

This article mainly introduces how to use kprintf in Component. It is very detailed and has a certain reference value. Friends who are interested must finish it!

When debugging a program, one of the most commonly used means is to print some debug statements, and the most commonly used print function should be printf (). The purpose of printf () is to output formatted debug statements to the standard output device. This standard output device defaults to PC Console or serial port

You can also modify it, such as changing to a file or pipe

When logMsg () is executed in ISR, debug statements are sent to task tLogTask with priority 0 through the underlying msgQSend (logMsgQId, msg, sizeof (msg), NO_WAIT,MSG_PRI_NORMAL).

However, to use logMsg (), you need to use it after usrRoot () calls logInit (); using printf (), you need to use usrRoot () after calling usrSerialInit () or usrPcConsoleInit ().

This component simply provides the developer with two functions, kputs () and kprintf (). The declarations of these two functions are similar to the puts and printf () defined by ANSI, respectively, and they are used to print statements for debugging.

As you can see, kprintf () can be used after sysHwInit () in the usrInit () phase and before usrCacheEnable (), much earlier than when printf () / logMsg () is available.

In addition, logMsg () uses the NO_WAIT method when calling msgQSend (), so it is possible to discard some messages

Let's take a look at an example of output to the RAM reservation.

Finally, compare the three of them.

Printf ()

Tags: Output message statement function common use system device two serial port function content that is standard article almost personnel value task priority example Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Huawei Apple Linux