@@ -342,16 +342,23 @@ Peripherals
342
342
343
343
The following peripherals are currently provided with this board:
344
344
345
- **Console/printk driver **:
346
- A driver is provided that redirects any printk write to the native
347
- host application's stdout.
345
+ **Console driver **:
346
+ A console driver is provided which by default is configured to:
347
+
348
+ - Redirect any :c:func: `printk ` write to the native host application's
349
+ `stdout `.
350
+
351
+ - Feed any input from the native application `stdin ` to a possible
352
+ running :ref: `Shell `. For more information refer to the section
353
+ `Shell support `_.
348
354
349
355
**Simple timer **:
350
356
A simple timer provides the kernel with a 10ms tick.
351
357
This peripheral driver also provides the needed functionality for this
352
358
architecture-specific :c:func: `k_busy_wait `.
353
359
354
- This timer, is configured by default with NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME _
360
+ This timer, is configured by default with
361
+ :option: `CONFIG_NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME `
355
362
to slow down the execution to real host time.
356
363
This will provide the illusion that the simulated time is running at the same
357
364
speed as the real host time.
@@ -361,11 +368,66 @@ The following peripherals are currently provided with this board:
361
368
Normally the Zephyr application and HW models run in very little time
362
369
on the host CPU, so this is a good enough approach.
363
370
364
- .. _NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME :
365
- ../../../../reference/kconfig/CONFIG_NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME.html
366
-
367
371
**Interrupt controller **:
368
372
A simple yet generic interrupt controller is provided. It can nest interrupts
369
373
and provides interrupt priorities. Interrupts can be individually masked or
370
374
unmasked. SW interrupts are also supported.
371
375
376
+ Shell support
377
+ *************
378
+
379
+ When the :ref: `Shell ` subsystem is compiled with your application, the native
380
+ standard input (`stdin `) will be redirected to the shell.
381
+ You may use the shell interactively through the console,
382
+ by piping another process output to it, or by feeding it a file.
383
+
384
+ When using it interactively you may want to select the option
385
+ :option: `CONFIG_NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME `.
386
+
387
+ When feeding `stdin ` from a pipe or file, the console driver will ensure
388
+ reproducibility between runs of the process:
389
+
390
+ - The execution of the process will be stalled while waiting for new `stdin `
391
+ data to be ready.
392
+
393
+ - Commands will be fed to the shell as fast as the shell can process them.
394
+ To allow controlling the flow of commands to the shell, you may use the
395
+ driver directive ``!wait <ms> ``.
396
+
397
+ - When the file ends, or the pipe is closed the driver will stop attempting to
398
+ read it.
399
+
400
+ Driver directives
401
+ =================
402
+
403
+ The console driver understands a set of special commands: driver directives.
404
+ These directives are captured by the console driver itself and are not
405
+ forwarded to the shell.
406
+ These directives are:
407
+
408
+ - ``!wait <ms> ``: When received, the driver will pause feeding commands to the
409
+ shell for `<ms> ` milliseconds.
410
+
411
+ - ``!quit ``: When received the driver will cause the application to gracefully
412
+ exit by calling :c:func: `posix_exit `.
413
+
414
+
415
+ Use example
416
+ ===========
417
+
418
+ For example, you can build the shell sample app:
419
+
420
+ .. zephyr-app-commands ::
421
+ :zephyr-app: samples/subsys/shell/shell_module
422
+ :host-os: unix
423
+ :board: native_posix
424
+ :goals: build
425
+ :compact:
426
+
427
+ And feed it the following set of commands through a pipe:
428
+
429
+ .. code-block :: console
430
+
431
+ echo -e \
432
+ 'select kernel\nuptime\n!wait 500\nuptime\n!wait 1000\nuptime\n!quit' \
433
+ | zephyr/zephyr.exe
0 commit comments