Closed jonathanperret closed 4 months ago
The changes mainly reduce the maximum message buffer length in the Com
class from 255 to 64, aiming to enhance performance and memory management. The member variable for packet serial communication is also updated to a templated class, incorporating this new buffer size, indicating a more efficient handling mechanism for packet communications within the application.
File | Change Summary |
---|---|
src/ayab/com.h |
Updated MAX_MSG_BUFFER_LEN from 255 to 64. Changed m_packetSerial from SLIPPacketSerial to PacketSerial_<SLIP, SLIP::END, MAX_MSG_BUFFER_LEN> . |
sequenceDiagram
participant App
participant Com
participant PacketSerial
App->>Com: Send Message
Com->>PacketSerial: Process Packet (Using MAX_MSG_BUFFER_LEN)
PacketSerial-->>Com: Acknowledge
Com-->>App: Message Sent Confirmation
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
This should help quite a bit with #190 as well.
I'm all for this as long as we also update the api docs to clarify the message limit :)
Will do!
@X-sam here's a manual PR to document the message size limit: https://github.com/AllYarnsAreBeautiful/ayab-manual/pull/39 , please let me know what you think!
Issue
As shown in #191 the memory usage of the firmware needs to be brought under control. A significant contributor to the allocated RAM is the set of message buffers used by the serial communication layer.
Proposed solution
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.This PR therefore reduces both the outgoing message buffer (
Com::msgBuffer
) and the incoming message buffer in thePacketSerial
instance to 64 bytes each.If the objects are statically alllocated as proposed in #191 , it can be seen that the memory used goes from
91.3% (used 1869 bytes from 2048 bytes)
to72.5% (used 1485 bytes from 2048 bytes)
with this change.Summary by CodeRabbit
These changes aim to optimize communication within the application.