avr-fw-modules/core/include/hwo/konsole.h

125 lines
2.9 KiB
C
Executable File

#pragma once
/*******************************************************************************************************
konsole.h Definitionen un Deklarationen der integrierten seriellen Konsole für ANSI/vt100
*******************************************************************************************************/
#include <stdio.h>
#include <hwo/systick.h>
#include <util/list.h>
#define KON_TYPE_EMPTY 0x00
#define KON_TYPE_INT8 0x01
#define KON_TYPE_INT16 0x02
#define KON_TYPE_INT32 0x03
#define KON_TYPE_INT64 0x04
#define KON_TYPE_FLOAT 0x05
#define KON_TYPE_PTR 0x06
#define KON_TYPE_STRING 0x07
#define KON_TYPE_REF 0x20 // Referenzierung durch <ptr>
#define KON_TYPE_HEX 0x40 // Darstellung in 0x...
#define KON_TYPE_SPEC 0x80 // Spezielles Feld
#define KON_SPEC_TICKS 0x80
#define KON_SPEC_BRKVAL 0x81
#define KON_SPEC_SPLIM 0x82
struct avr_konsole;
struct avr_konsole_field;
struct avr_konsole_command;
struct avr_konsole_commandline;
struct avr_konsole_command_define;
typedef struct avr_konsole KONSOLE;
typedef struct avr_konsole_commandline KON_CMDLINE;
typedef struct avr_konsole_command_define
KON_CMD_DEFINE;
#define KON_CMD_DEFINE(ptr) ((KON_CMD_DEFINE*)ptr)
typedef struct avr_konsole_field avrKonsoleField;
typedef struct avr_konsole_command avrKonsoleCommand;
//typedef uint8_t (*cbKonsoleCommand)(avrKonsole* konsole,avrKonsoleCommand *command); // Callback für benutzerdefinierte Befehle
typedef uint8_t (*cbKonsoleUpdateField)(avrKonsoleField *field);
typedef uint8_t (*cbKonsoleCommandEx)(KONSOLE* konsole,KON_CMD_DEFINE *cmddef,KON_CMDLINE *cmdline);
struct avr_konsole_field
{
char *label;
uint8_t type;
uint8_t code; // USER Byte for identification
uint8_t width;
union
{
void *ptr;
char *pString;
int8_t i8;
int16_t i16;
int32_t i32;
int64_t i64;
float f;
};
};
struct avr_konsole_commandline
{
char *first,
*second,
*third,
*fourth;
char *last;
};
struct avr_konsole_command_define
{
list_t list;
char cmdWord[12];
list_t subcmds;
cbKonsoleCommandEx
cbCommand;
};
struct avr_konsole
{
FILE *stream; // FILE struktur für <serial>
FILE *pipe;
avrWAIT wait_status; // Timer für Neuzeichnen der Statusfelder
char cmdline[128]; // Buffer für Eingabezeile
uint8_t pCmdline; // Zeiger auf nächstes freies zeichen in <cmdline>
char *greeting; // Begrüßung nach Konsolenstart
KON_CMD_DEFINE
commandroot;
cbKonsoleUpdateField cbUpdate;
avrKonsoleField *statusfields[4]; // Zeiger auf Statusfelder für die ersten 6 Zeilen
};
KONSOLE* konsole_create (FILE *stream);
uint8_t konsole_set_command (KONSOLE *konsole, char *command, cbKonsoleCommandEx cbCommandEx);
uint8_t konsole_start(KONSOLE *konsole);
uint8_t konsole_cmdline(KONSOLE *konsole);
uint8_t konsole_read_line (FILE *stream, char *buffer, uint8_t maxsize);
void dbg_print_threads(FILE *stream);