-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrian Vazquez
authored and
Adrian Vazquez
committed
Mar 4, 2022
1 parent
337da65
commit 86bf9ce
Showing
2 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from ait.core.server.plugins import Plugin | ||
from ait.core import log | ||
|
||
|
||
class PacketPadder(Plugin): | ||
def __init__(self, inputs=None, outputs=None, zmq_args=None, pad_octets=0, **kwargs): | ||
if pad_octets >= 0: | ||
self.size_pad_octets = pad_octets | ||
else: | ||
self.size_pad_octets = 0 | ||
log.error(f"PacketPadder -> Pad value{pad_octets} octets must be a \ | ||
positive integer! Bypassing padding!") | ||
super().__init__(inputs, outputs, zmq_args) | ||
|
||
def process(self, data, topic=None): | ||
if len(data) < self.size_pad_octets: | ||
fill = bytearray(self.size_pad_octets - len(data)) | ||
data = data + fill | ||
self.publish(data) |
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,21 @@ | ||
Packet Padder Plugin | ||
======================== | ||
The packet padder plugin pads command processing pipeline data to a user configured size in octets. | ||
|
||
If the size of pipeline data in octets is less than the user specified value, the pipline will pad 0s to achieve the specified size. | ||
|
||
Configuration | ||
------------- | ||
|
||
Add and customize the following template in your config.yaml | ||
|
||
.. code-block:: none | ||
- plugin: | ||
name: ait.core.server.plugins.PacketPadder.PacketPadder | ||
inputs: | ||
- PacketAccumulator | ||
pad_octets: 987 | ||
The *pad_octets* option specifies the minimum size to pad the data to. The plugin will not modify the data if its size already meets or exceeds this value. A negative, 0, or missing value will bypass the plugin. | ||
|
||
Use *inputs* to specify which PUB/SUB topic the plugin should receive pipeline data from. |