Keep Open TCP Implementation #496
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "eive/fsfw:mueller/tcp-keep-open-pr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #470
This refactoring keeps the TCP connection opened until the client closes
it. It also increased the robustness of the TCP reception.
Because TCP is stream based and usually applied to newline separated
data, a special way to handle binary space packets is required.
The new SpacePacketParser class takes care of this by taking TC packet
IDs as optional start markers to parse for space packets in a given
buffer.
The refactored TCP server uses a ring buffer, a reception buffer and the
new parser to extract space packets from a stream in a safer and more robust way.
If the server is idle, it will use a configurable delay to decrease the CPU load.
A new reception mode state was introduced which could be used in the future to support newline separated data or other packet formats.
The changes were tested on Embedded Linux, Desktop Linux and Desktop Windows.
Unit tests for the new parser will follow in a separate PR
Added some improvements suggested by @Jakob.Meier
@ -0,0 +44,4 @@
foundSize = packetSize;
}
*buffer += foundSize;
readLen += idx + foundSize;
What does readLen mean? If you add += idx you might have more bytes than the buffer size.
Total read length in buffer. If the packet does not start with the start marker, idx will be incremented until a start marker is detected. It then needs to be added on top of the found size
LGTM