Line data Source code
1 0 : /* 2 : * Copyright (c) 2017 Intel Corporation 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_DRIVERS_CONSOLE_CONSOLE_H_ 8 : #define ZEPHYR_INCLUDE_DRIVERS_CONSOLE_CONSOLE_H_ 9 : 10 : #ifdef __cplusplus 11 : extern "C" { 12 : #endif 13 : 14 0 : #define CONSOLE_MAX_LINE_LEN CONFIG_CONSOLE_INPUT_MAX_LINE_LEN 15 : 16 : /** @brief Console input representation 17 : * 18 : * This struct is used to represent an input line from a console. 19 : * Recorded line must be NULL terminated. 20 : */ 21 1 : struct console_input { 22 : /** FIFO uses first word itself, reserve space */ 23 : intptr_t _unused; 24 : /** Whether this is an mcumgr command */ 25 1 : uint8_t is_mcumgr : 1; 26 : /** Buffer where the input line is recorded */ 27 1 : char line[CONSOLE_MAX_LINE_LEN]; 28 : }; 29 : 30 : /** @brief Console input processing handler signature 31 : * 32 : * Input processing is started when string is typed in the console. 33 : * Carriage return is translated to NULL making string always NULL 34 : * terminated. Application before calling register function need to 35 : * initialize two fifo queues mentioned below. 36 : * 37 : * @param avail k_fifo queue keeping available input slots 38 : * @param lines k_fifo queue of entered lines which to be processed 39 : * in the application code. 40 : * @param completion callback for tab completion of entered commands 41 : */ 42 1 : typedef void (*console_input_fn)(struct k_fifo *avail, struct k_fifo *lines, 43 : uint8_t (*completion)(char *str, uint8_t len)); 44 : 45 : #ifdef __cplusplus 46 : } 47 : #endif 48 : 49 : #endif /* ZEPHYR_INCLUDE_DRIVERS_CONSOLE_CONSOLE_H_ */