* @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. */
| 412 | * And dont forget to register the device with a higher priority. |
| 413 | */ |
| 414 | static 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 | |
| 443 | INIT_COMPONENT_EXPORT(_default_console_setup); |
nothing calls this directly
no test coverage detected