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

Function _default_console_setup

components/drivers/serial/serial_tty.c:414–441  ·  view source on GitHub ↗

* @brief The default console is only a backup device with lowest priority. * It's always recommended to scratch the console from the boot arguments. * And dont forget to register the device with a higher priority. */

Source from the content-addressed store, hash-verified

412 * And dont forget to register the device with a higher priority.
413 */
414static int _default_console_setup(void)
415{
416 rt_err_t rc;
417 rt_device_t bakdev;
418 rt_device_t ttydev;
419
420 bakdev = rt_console_get_device();
421 if (!bakdev)
422 {
423 return -RT_ENOENT;
424 }
425
426 ttydev = bakdev;
427 rt_object_for_each(RT_Object_Class_Device, _match_tty_iter, &ttydev);
428
429 if (ttydev != bakdev)
430 {
431 LOG_I("Using /dev/%.*s as default console", RT_NAME_MAX, ttydev->parent.name);
432 lwp_console_register_backend(ttydev, LWP_CONSOLE_LOWEST_PRIOR);
433 rc = RT_EOK;
434 }
435 else
436 {
437 rc = -RT_EINVAL;
438 }
439
440 return rc;
441}
442
443INIT_COMPONENT_EXPORT(_default_console_setup);

Callers

nothing calls this directly

Calls 3

rt_console_get_deviceFunction · 0.85
rt_object_for_eachFunction · 0.85

Tested by

no test coverage detected