MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_kprintf

Function rt_kprintf

src/kservice.c:359–385  ·  view source on GitHub ↗

* @brief This function will print a formatted string on system console. * * @param fmt is the format parameters. * * @return The number of characters actually written to buffer. */

Source from the content-addressed store, hash-verified

357 * @return The number of characters actually written to buffer.
358 */
359rt_weak int rt_kprintf(const char *fmt, ...)
360{
361 va_list args;
362 rt_size_t length = 0;
363 static char rt_log_buf[RT_CONSOLEBUF_SIZE];
364
365 va_start(args, fmt);
366 PRINTF_BUFFER_TAKE;
367
368 /* the return value of vsnprintf is the number of bytes that would be
369 * written to buffer had if the size of the buffer been sufficiently
370 * large excluding the terminating null byte. If the output string
371 * would be larger than the rt_log_buf, we have to adjust the output
372 * length. */
373 length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);
374 if (length > RT_CONSOLEBUF_SIZE - 1)
375 {
376 length = RT_CONSOLEBUF_SIZE - 1;
377 }
378
379 _kputs(rt_log_buf, length);
380
381 PRINTF_BUFFER_RELEASE;
382 va_end(args);
383
384 return length;
385}
386RTM_EXPORT(rt_kprintf);
387#endif /* RT_USING_CONSOLE */
388

Callers 15

hello_worldFunction · 0.85
finsh_set_deviceFunction · 0.85
finsh_wait_authFunction · 0.85
shell_auto_completeFunction · 0.85
shell_handle_historyFunction · 0.85
finsh_thread_entryFunction · 0.85
ifFunction · 0.85
finsh_system_initFunction · 0.85
cmd_lnFunction · 0.85
cmd_linkFunction · 0.85
cmd_cpFunction · 0.85
cmd_mvFunction · 0.85

Calls 2

_kputsFunction · 0.85
rt_vsnprintfFunction · 0.50

Tested by 15

dtb_testFunction · 0.68
dtb_dumpFunction · 0.68
utest_helpFunction · 0.68
utest_thr_entryFunction · 0.68
test_netdev_dnsFunction · 0.68
test_netdev_dhcpFunction · 0.68
test_netdev_ifconfig_setFunction · 0.68
test_callback_operationFunction · 0.68
test_callbackFunction · 0.68
test_gethostbynameFunction · 0.68
test_get_free_addrinfoFunction · 0.68