-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document everything. Tweak use of lambdas to better enforce stack all…
…ocation.
- Loading branch information
1 parent
824752e
commit edd1295
Showing
20 changed files
with
278 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Basic interface | ||
=============== | ||
|
||
The framing methods are exposed through the `PacketPrint` and `PacketStream` interfaces. | ||
|
||
.. doxygenclass:: packetio::PacketPrint | ||
:members: | ||
:undoc-members: | ||
|
||
.. doxygenclass:: packetio::PacketStream | ||
:members: | ||
:undoc-members: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
Welcome to PacketIO's documentation! | ||
==================================== | ||
PacketIO | ||
======== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
.. default-domain:: cpp | ||
A C++ library distributed with PlatformIO_, for framing packets sent or received over an Arduino `Stream`, such as `Serial`. | ||
|
||
Basic interface | ||
===================== | ||
The key feature of this library over other framing implementations it that it operates on streams. This means that if your application layer is able to produce or consume streams, you can push these streams right the way through your program. Put simply, this means you can send arbitrarily large packets, without having to worry about allocating buffers. | ||
|
||
.. doxygenclass:: packetio::PacketPrint | ||
:members: | ||
:undoc-members: | ||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
.. doxygenclass:: packetio::PacketStream | ||
:members: | ||
:undoc-members: | ||
basics | ||
protocols | ||
listening | ||
internals | ||
|
||
Indices and tables | ||
================== | ||
.. default-domain:: cpp | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` | ||
.. _PlatformIO: https://platformio.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Internals | ||
========= | ||
|
||
Callback functions | ||
------------------ | ||
|
||
The :class:`LambdaPointer` class is used to provide contextfull callback functions, using c++11 lambdas | ||
|
||
.. doxygenclass:: packetio::LambdaPointer< Out(In...)> | ||
:members: | ||
|
||
Mirror of the Arduino interface | ||
------------------------------- | ||
|
||
These classes, found in :file:`_compat`, allow testing on the desktop, and potentially execution on | ||
non-Arduino platforms | ||
|
||
.. doxygenclass:: Print | ||
:members: | ||
:undoc-members: | ||
|
||
.. doxygenclass:: Stream | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Listening for packets | ||
===================== | ||
|
||
.. doxygenclass:: packetio::PacketListener_ | ||
:members: | ||
:undoc-members: | ||
|
||
Example usage: | ||
|
||
.. code-block:: cpp | ||
#include <packet_interface.h> | ||
#include <PacketListener.h> | ||
#include <cobs/Stream.h> | ||
using namespace packetio; | ||
void setup () { | ||
COBSStream cobs_serial_in(Serial); | ||
PacketListener handler(cobs_serial_in); | ||
int message_count = 0; | ||
auto message_handler = [&](const uint8_t* buffer, size_t len) { | ||
message_count++; | ||
}; | ||
handler.onMessage(&message_handler); | ||
while(true) { | ||
handler.update(); | ||
Serial.print("Message recieved: "); | ||
Serial.print(message_count); | ||
Serial.println(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Framing Protocols | ||
================= | ||
|
||
COBS | ||
---- | ||
|
||
.. include:: ../src/cobs/README.rst | ||
:start-line: 2 | ||
|
||
.. doxygenclass:: packetio::COBSPrint | ||
.. doxygenclass:: packetio::COBSStream | ||
|
||
Escaped | ||
------- | ||
|
||
.. include:: ../src/escaped/README.rst | ||
:start-line: 2 | ||
|
||
.. doxygenstruct:: packetio::EscapeCodes | ||
.. doxygenclass:: packetio::EscapedPrint | ||
.. doxygenclass:: packetio::EscapedStream | ||
|
||
SLIP | ||
---- | ||
|
||
.. include:: ../src/slip/README.rst | ||
:start-line: 2 | ||
|
||
.. doxygentypedef:: packetio::SLIPEscapeCodes | ||
.. doxygentypedef:: packetio::SLIPPrint | ||
.. doxygentypedef:: packetio::SLIPStream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Consistent-Overhead Byte Stuffing | ||
================================= | ||
|
||
This is an implementation of `Consistent-Overhead Byte Stuffing`_. | ||
|
||
This uses a null byte as an end of packet marker, and uses a clever technique | ||
to encode null bytes within the packet with minimal overhead. See the link | ||
above for more information. | ||
|
||
.. _Consistent-Overhead Byte Stuffing: http://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Escaping packet framer | ||
====================== | ||
|
||
This packet framer uses a special character to indicate end-of-frame, and an | ||
escape character to allow this to appear within a message. In the worst-case, | ||
this causes the packet to be twice the data size. | ||
|
||
The choice of these special characters is parameterizable through template | ||
arguments. :file:`encoded/codes.h` contains some example choices of values, including | ||
an implementation of SLIP_. To define your own, you can use code like the | ||
following:: | ||
|
||
#include <escaped/Print.h> | ||
#include <escaped/Stream.h> | ||
#include <escaped/codes.h> | ||
|
||
using namespace packetio; | ||
|
||
// end, escape, escaped end, escaped escape | ||
typedef EscapeCodes<'A','/','a','\\'> MyCodes; | ||
|
||
EscapedPrint<MyCodes> printer(Serial); | ||
EscapedStream<MyCodes> reader(Serial); | ||
|
||
|
||
In this example, we use ``A`` to end a packet. So the packet ``ABCD/EFGH`` is | ||
encoded to ``/aBCD/\EFGHA``. Here, the first `A` is replaced by the escape | ||
sequence ``/a``, and the ``/`` is replaced with ``/\``. Finally, an ``A`` is | ||
appended to end the packet. | ||
|
||
.. _SLIP: https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol |
Oops, something went wrong.