rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
page_console.h
Go to the documentation of this file.
1
67#ifndef RCBENCH_PAGE_CONSOLE_H
68#define RCBENCH_PAGE_CONSOLE_H
69
70#include <stdarg.h>
71#include <stdbool.h>
72#include <stddef.h>
73#include <stdint.h>
74
75#include "link_dev.h"
76#include "link_pages.h"
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
83#define PAGE_CONSOLE_LINE_MAX 160u
85#define PAGE_CONSOLE_OUT_LINE 200u
87#define PAGE_CONSOLE_OUT_MAX 2048u
88
93typedef struct {
94 const link_dev_t *dev;
95 char line[PAGE_CONSOLE_LINE_MAX + 1u];
96 uint16_t len;
97 uint8_t overlong;
99 uint16_t head;
100 uint16_t used;
101 uint32_t dropped;
103 uint8_t watch;
104 /* Work space, here rather than on the caller's stack. */
105 char fmt[PAGE_CONSOLE_OUT_LINE];
106 link_msg_t req;
107 link_msg_t reply;
108 uint16_t regs[LINK_HT_COUNT];
109 uint16_t data[3][16];
111
118void page_console_init(page_console_t *c, const link_dev_t *dev);
119
129void page_console_key(page_console_t *c, int ch);
130
137
148void page_console_say(page_console_t *c, const char *fmt, ...)
149 __attribute__((format(printf, 2, 3)));
150
158void page_console_vsay(page_console_t *c, const char *fmt, va_list ap)
159 __attribute__((format(printf, 2, 0)));
160
172size_t page_console_take(page_console_t *c, char *buf, size_t room);
173
188size_t page_console_take_part(page_console_t *c, char *buf, size_t room);
189
190#ifdef __cplusplus
191}
192#endif
193
194#endif /* RCBENCH_PAGE_CONSOLE_H */
void page_console_poll(page_console_t *c)
Once a pass: the report of a HITEC operation that has ended.
Definition page_console.c:1257
#define PAGE_CONSOLE_OUT_LINE
The longest output line, with its LF.
Definition page_console.h:85
void page_console_key(page_console_t *c, int ch)
One character in.
Definition page_console.c:1224
void page_console_vsay(page_console_t *c, const char *fmt, va_list ap)
page_console_say() with a va_list.
Definition page_console.c:44
size_t page_console_take_part(page_console_t *c, char *buf, size_t room)
The first room bytes of output, a line cut where the room ends: a line longer than room leaves in pie...
Definition page_console.c:123
void page_console_say(page_console_t *c, const char *fmt,...)
One line of output from outside the console, formatted as printf() formats: the LF is added,...
Definition page_console.c:66
#define PAGE_CONSOLE_OUT_MAX
The output buffer.
Definition page_console.h:87
#define PAGE_CONSOLE_LINE_MAX
The longest command line, without its end.
Definition page_console.h:83
size_t page_console_take(page_console_t *c, char *buf, size_t room)
Whole lines of output, at most room bytes; the bytes copied.
Definition page_console.c:97
void page_console_init(page_console_t *c, const link_dev_t *dev)
An empty console on the pages of dev.
Definition page_console.c:1215
The console state: the command line being read, the output buffer, the staged HITEC registers and the...
Definition page_console.h:93
uint16_t used
Definition page_console.h:100
uint16_t head
Definition page_console.h:99
uint8_t watch
Definition page_console.h:103
uint16_t staged[LINK_HT_W_STAGED]
Definition page_console.h:102
uint32_t dropped
Definition page_console.h:101
uint8_t overlong
Definition page_console.h:97
char out[PAGE_CONSOLE_OUT_MAX]
Definition page_console.h:98