STDIN works in a following loop:
- Warning
- SIGIO reserved for STDIN usage only any attempt to raise it by the target logic shall result the shell recognizing a new key input as such since a key is unknown (or retain previous state) the behaviour is undefined when the shell will start processing a 'new' input. It doesnt apply to EVT_USERCON_KEY event publish i.e. it can be published anywhere anytime during system lifetime
STDOUT logic just outputs characters to the console (see kernel_stdio.h and console.h).
That said anything that publishes EVT_USERCON_KEY event the kernel shell treats it as a new user input.
- Note
- it doesnt care what is the exact source and how many of them are e.g. tty/keyb/network etc.
As such the most sutable place publishing events are services registered by _SERVICE
STDIN target platform service example
#include <stdbool.h>
#include "uart.h"
#include "events.h"
#include "kernel.h"
#include "service.h"
static void uart_service(void);
static inline bool is_charValid(char c);
static void uart_service(void) {
char c;
while((c = _uart_read()) != '\0') {
if (is_charValid(c)) {
}
}
}
static inline bool is_charValid(char c) {
return ((c >= '0') && (c <= '9')) ||
((c >= 'a') && (c <= 'z')) ||
((c >= 'A') && (c <= 'Z')) ||
((c == ' ') || (c == '\n') || (c == '\t') || (c == '\b') || (c == '\x7f'));
}
#define _SERVICE(name, service_main)
Declares and registers a system service.
Definition service.h:93
void _kernel_pubEvt(uint8_t id, evt_data_t *data)
Publishes an event to the kernel event system.
@ EVT_USERCON_KEY
Definition events.h:18
Console key event data.
Definition events.h:50
char code
ASCII character code.
Definition events.h:58
Event payload container.
Definition events.h:82