Skip to content

Commit

Permalink
com: shrink send/receive buffers from 256 to 64 bytes
Browse files Browse the repository at this point in the history
The largest message that is generated by the current protocol is a `cnfLine`
containing 25 bytes of pattern, plus 5 bytes of other data.
Even assuming a worst case of having to SLIP-escape all the bytes, this fits
in a 64-byte buffer.
  • Loading branch information
jonathanperret committed Jul 22, 2024
1 parent e960ad4 commit 4b36905
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ayab/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ constexpr uint8_t API_VERSION = 6U;
constexpr uint32_t SERIAL_BAUDRATE = 115200U;

constexpr uint8_t MAX_LINE_BUFFER_LEN = 25U;
constexpr uint8_t MAX_MSG_BUFFER_LEN = 255U;
constexpr uint8_t MAX_MSG_BUFFER_LEN = 64U;

enum class AYAB_API : unsigned char {
reqStart = 0x01,
Expand Down Expand Up @@ -136,7 +136,7 @@ class Com : public ComInterface {
void onPacketReceived(const uint8_t *buffer, size_t size) final;

private:
SLIPPacketSerial m_packetSerial;
PacketSerial_<SLIP, SLIP::END, MAX_MSG_BUFFER_LEN> m_packetSerial;
uint8_t lineBuffer[MAX_LINE_BUFFER_LEN] = {0};
uint8_t msgBuffer[MAX_MSG_BUFFER_LEN] = {0};

Expand Down

0 comments on commit 4b36905

Please sign in to comment.