Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion firmware/open_evse/open_evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,13 @@ extern AutoCurrentCapacityController g_ACCController;
// 10-byte MCU id needs only 33 for $GI, so the LCD-derived 34 still fits;
// keep AVR unchanged so its RAM footprint does not grow. See the matching
// #error guard in rapi_proc.cpp.
#ifdef TARGET_SAMD
//
// Select from the MCU id length rather than the target name: take the
// LCD-derived size unless the $GI reply needs more. Values are unchanged
// from when this was keyed on TARGET_SAMD -- a 16-byte id needs 45 and so
// selects 48, a 10-byte id needs 33 and so keeps the LCD-derived 34.
#define TMP_BUF_GI_REPLYLEN (3 + 1 + (2*MCU_ID_LEN) + 4 + 4 + 1)
#if defined(MCU_ID_LEN) && (TMP_BUF_GI_REPLYLEN > ((LCD_MAX_CHARS_PER_LINE+1)*2))
#define TMP_BUF_SIZE 48
#else
#define TMP_BUF_SIZE ((LCD_MAX_CHARS_PER_LINE+1)*2)
Expand Down
16 changes: 11 additions & 5 deletions firmware/open_evse/rapi_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,17 @@ Z0 closems holdpwm

// buffer[] holds an inbound RAPI command and is reused to build the
// outbound response text. The longest response text is $GI (get MCU id),
// whose #else branch writes 2*MCU_ID_LEN hex chars plus a NUL. On SAMD
// MCU_ID_LEN is 16, so that is 2*16+1 = 33 bytes and the historic 32-byte
// buffer overflowed by one, corrupting the adjacent bufCnt member. Size
// per target so AVR RAM cost stays zero.
#ifdef TARGET_SAMD
// whose #else branch writes 2*MCU_ID_LEN hex chars plus a NUL. With a
// 16-byte MCU id that is 2*16+1 = 33 bytes and the historic 32-byte buffer
// overflowed by one, corrupting the adjacent bufCnt member.
//
// Size from the MCU id length rather than the target name, so any target
// inherits the right buffer automatically. The values are unchanged from
// when this was keyed on TARGET_SAMD: a 16-byte id selects 40, a 10-byte
// id selects 32, so AVR RAM cost stays zero (ESRAPI_BUFLEN sizes three
// buffers there -- buffer[], g_rapiSerialBuffer and g_rapiI2ClBuffer).
#define ESRAPI_GI_RESPLEN (2*MCU_ID_LEN + 1)
#if defined(MCU_ID_LEN) && (ESRAPI_GI_RESPLEN > 32)
#define ESRAPI_BUFLEN 40
#else
#define ESRAPI_BUFLEN 32
Expand Down