Skip to content

Separate buffer for raw data #10

@denravonska

Description

@denravonska

I have been thinking about how to reduce the need for large buffers when reading socket data and I think I have come up with a solution that might work.

Normally when receiving data it goes into the parser RX buffer so it needs to be capped in order to avoid flooding it. It also has the side effect that you need to be able to buffer at least twice the amount you want to read (depending on how you use the library); once for putting reply+data into the parser and once to copy the data from the RX buffer to the caller's buffer.

I want to introduce a rawdata buffer that can optionally be passed to the parser. If a rawdata buffer is set and AT_RESPONSE_RAWDATA_FOLLOWS is returned from a handler then data is put into the raw buffer rather than the parser buffer until the rawdata buffer runs out of space. This allows you to use a relatively small parser buffer while still being being able to read kilobytes of raw data from modem sockets.

Would you be interested in something like that? It will introduce a pointer and two size variables which could be hidden behind a define if you want to keep the struct small.

struct at_parser {
    ...
    char *rawdata_buf;
    size_t rawdata_buf_used;
    size_t rawdata_buf_size;
};

If no raw data pointer is assigned then it would behave exactly as it does today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions