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

Function rt_console_set_device

src/kservice.c:188–207  ·  view source on GitHub ↗

* @brief This function will set a device as console device. * After set a device to console, all output of rt_kprintf will be * redirected to this new device. * * @param name is the name of new console device. * * @return the old console device handler on successful, or RT_NULL on failure. */

Source from the content-addressed store, hash-verified

186 * @return the old console device handler on successful, or RT_NULL on failure.
187 */
188rt_device_t rt_console_set_device(const char *name)
189{
190 rt_device_t old_device = _console_device;
191 rt_device_t new_device = rt_device_find(name);
192
193 if (new_device != RT_NULL && new_device != old_device)
194 {
195 if (old_device != RT_NULL)
196 {
197 /* close old console device */
198 rt_device_close(old_device);
199 }
200
201 /* set new console device */
202 rt_device_open(new_device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
203 _console_device = new_device;
204 }
205
206 return old_device;
207}
208RTM_EXPORT(rt_console_set_device);
209#endif /* RT_USING_DEVICE */
210

Callers 15

rt_ofw_console_setupFunction · 0.85
adb_enterFunction · 0.85
adb_exitFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85

Calls 3

rt_device_findFunction · 0.85
rt_device_closeFunction · 0.85
rt_device_openFunction · 0.85

Tested by 1

test_hdmiFunction · 0.68