Reduce RXBUF size to match parser and space out log messages

This commit is contained in:
2024-09-23 01:41:13 +02:00
parent 9458db03f7
commit 622bf047f8
3 changed files with 7 additions and 29 deletions

View File

@@ -5,8 +5,8 @@
#include <avr/interrupt.h>
#define USART_BAUDRATE 9600
#define USART_RXBUF_SIZE 512
#define USART_TXBUF_SIZE 512
#define USART_RXBUF_SIZE 128
#define USART_TXBUF_SIZE 128
#define USART_RXBUF_MASK (USART_RXBUF_SIZE - 1)
#define USART_TXBUF_MASK (USART_TXBUF_SIZE - 1)
@@ -41,6 +41,7 @@ char USART_Getc(void)
}
rxtail = (rxtail + 1) & USART_RXBUF_MASK;
return rxbuf[rxtail];
}

View File

@@ -16,9 +16,6 @@ static char *tail = cmdbuf + CMD_MAX_LEN - 1;
static char *head = cmdbuf;
static bool ParseLine(cmd_t *out);
static void StartTimer(void);
static bool IsTimedOut(void);
static void StopTimer(void);
bool CMD_Parse(char ch, cmd_t *out)
{
@@ -30,16 +27,10 @@ bool CMD_Parse(char ch, cmd_t *out)
// means that after a command that is too long, the
// next command will not be parsed properly.
if (head == cmdbuf) {
StartTimer();
}
if (IsTimedOut() ||
(ch == '\n' || ch == '\r')) {
if (ch == '\n' || ch == '\r') {
is_valid = ParseLine(out);
tail = cmdbuf + CMD_MAX_LEN - 1;
head = cmdbuf;
StopTimer();
return is_valid;
}
@@ -87,20 +78,3 @@ static bool ParseLine(cmd_t *out)
return false;
}
static void StartTimer(void)
{
TCNT0 = 0x00;
TCCR0 = BIT(CS00) | BIT(CS02);
}
static bool IsTimedOut(void)
{
return false; // TIFR & BIT(TOV0)
}
static void StopTimer(void)
{
TCNT0 = 0x00;
TIFR = BIT(TOV0);
}

View File

@@ -6,6 +6,7 @@
#include <avr/interrupt.h>
// TODO: Check parser and circular buffer for edge cases.
// TODO: Implement command parser timeout for large input.
// TODO: Config header for chip specifics like EEPROM size.
// TODO: Check thermistor conversion results /w thermometer.
@@ -174,6 +175,7 @@ static void SetTarget(float t, float td)
{
mem_block_t mem;
Print("\r\n");
Info("=======================================");
Info("Setting temperature target to '%.2fC'.", t);
Info("Setting dewpoint target to '%.2fC'.", td);
@@ -201,6 +203,7 @@ static void GetSensorState(void)
word raw;
float t[6], rh[3], dp[3];
Print("\r\n");
Info("Reading sensor values...");
I2C_SetChannel(AHT01);