
#pragma once
#include "libSerial/serial.h"

extern void sendString(usart_ctl *ctl, char const *string, int length);

/// @brief storage for a string reader
typedef struct
{
    char *buffer;   // pointer to workspace
    int limit;      // string limit
    int counter;    // byte counter
    char complete;  // flag complete
    char readLines; // true if reading lines with CR at end
} editBuffer;

///
typedef enum
{
    EDIT_NULL = 0, ///< No result
    EDIT_DONE,     ///< All characters read
    EDIT_CR        ///< Characters up to CR read
} editBufferReturn;

// working
extern void initReadLine(editBuffer *context, char *buffer, int limit, char readLines);

extern editBufferReturn readLine(usart_ctl *ctl, editBuffer *context);
