Skip to content

Feature/packetized data#1580

Merged
MaticTonin merged 12 commits intodevelopfrom
feature/packetizedData
Jan 29, 2026
Merged

Feature/packetized data#1580
MaticTonin merged 12 commits intodevelopfrom
feature/packetizedData

Conversation

@JakubFara
Copy link
Copy Markdown
Collaborator

Summary

This commit adds support for reading packetized data.
Currently, this functionality is available only for RVC2 devices.


New Structure

  • PacketizedData : Buffer — sent before the actual packetized data to provide context for subsequent packets.

New Functions

XLinkInHost

  • std::shared_ptr<ADatatype> readData(const XLinkStream& stream) const;
    Reads incoming data from the specified stream.

  • std::shared_ptr<ADatatype> parsePacketizedData(const std::shared_ptr<PacketizedData>& packetizedData, const XLinkStream& stream) const;
    Parses packetized data and reconstructs the original payload.

  • void parseMessageGroup(const std::shared_ptr<MessageGroup>& messageGroup, const XLinkStream& stream) const;
    Handles message groups and their contained data packets.


New Parameters

XLinkOutProperties

  • int packetSize — defines the packet size.
  • int packetFrequency — defines how frequently packets are sent.

Tests

  • Tests are added to tests/src/ondevice_tests/xlink_test.cpp.
  • The tests verify the expected sending duration base on number of packets and packet frequency.
  • Deeper testing is not currently possible, as the public API does not expose low-level packetization details.

@moratom moratom requested a review from aljazkonec1 December 10, 2025 11:51
Comment on lines +52 to +55
void setPacketSize(int packetSize);

void setPacketFrequency(int packetFrequency);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add comments here;

  • I assume packetSize is in bytes?
  • What does packetFrequency do? Is this the "max" frequency?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes bytes.

I have changed frequencyLimit to BytesPerSecondLimit

Copy link
Copy Markdown
Collaborator

@moratom moratom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

We should bump RVC4 and RVC2 FW so it compiles and at add a warning on RVC4 that these are not implement at least (or implement the functionality on RVC4)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this be internal (ideally at least)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here: e8c24dd Make PacketizedData struct private

Comment on lines +31 to +34
/**
* Maximal frequency beteen of packets (-1 = unlimited)
*/
int packetFrequency = -1; //
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth considering a max bandiwidth setting instead may be better (easier to grasp and can also be applied in case the messages are not packatized).

Copy link
Copy Markdown
Collaborator Author

@JakubFara JakubFara Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed here: c359769 Change frequencyLimit to BytesPerSecondLimit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@aljazkonec1 aljazkonec1 requested a review from Copilot December 12, 2025 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for packetized data transfer, currently available only for RVC2 devices. The implementation allows data to be split into smaller packets and sent incrementally over XLink connections, with configurable packet size and frequency.

Key Changes

  • Introduced PacketizedData datatype to provide context for subsequent packet transfers
  • Added packet size and frequency configuration parameters to XLinkOut
  • Implemented parsing logic to reconstruct original payloads from packetized data streams

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
include/depthai/pipeline/datatype/PacketizedData.hpp New datatype for representing packetized frame metadata
include/depthai/pipeline/datatype/DatatypeEnum.hpp Added PacketizedData enum value
src/pipeline/datatype/DatatypeEnum.cpp Registered PacketizedData in datatype hierarchy
src/pipeline/datatype/StreamMessageParser.cpp Added parsing logic for PacketizedData messages
include/depthai/properties/internal/XLinkOutProperties.hpp Added packetSize and packetFrequency properties
include/depthai/pipeline/node/internal/XLinkOut.hpp Added getter/setter declarations for packet configuration
src/pipeline/node/internal/XLinkOut.cpp Implemented packet configuration getters/setters
include/depthai/pipeline/node/internal/XLinkInHost.hpp Added private helper methods for reading and parsing packetized data
src/pipeline/node/internal/XLinkInHost.cpp Refactored data reading to support packetized transfers
include/depthai/xlink/XLinkStream.hpp Made stream read/write methods const
src/xlink/XLinkStream.cpp Updated implementations to match const signatures
bindings/python/src/pipeline/node/NodeBindings.cpp Exposed packet configuration methods to Python API
tests/src/ondevice_tests/xlink_test.cpp Added tests verifying packet timing and data integrity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/depthai/properties/internal/XLinkOutProperties.hpp Outdated
Comment thread include/depthai/properties/internal/XLinkOutProperties.hpp Outdated
Comment thread include/depthai/properties/internal/XLinkOutProperties.hpp Outdated
Comment thread src/pipeline/node/internal/XLinkInHost.cpp Outdated
Comment thread src/pipeline/datatype/PacketizedData.hpp
Copy link
Copy Markdown
Contributor

@aljazkonec1 aljazkonec1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some comments but looks good otherwise.

There is also a compiler warning that needs to be handled:

/home/aljaz/work-luxonis/depthai-core/src/utility/ProtoSerialize.cpp:138:11: warning: enumeration value ‘PacketizedData’ not handled in switch [-Wswitch]
  138 |     switch(datatype) {
      |           ^
/home/aljaz/work-luxonis/depthai-core/src/pipeline/node/host/Replay.cpp: In function ‘std::shared_ptr<dai::Buffer> dai::node::getMessage(std::shared_ptr<google::protobuf::Message>, dai::DatatypeEnum)’:
/home/aljaz/work-luxonis/depthai-core/src/pipeline/node/host/Replay.cpp:45:11: warning: enumeration value ‘PacketizedData’ not handled in switch [-Wswitch]
   45 |     switch(datatype) {
      |           ^
/home/aljaz/work-luxonis/depthai-core/src/pipeline/node/host/Replay.cpp: In function ‘std::shared_ptr<google::protobuf::Message> dai::node::getProtoMessage(dai::utility::BytePlayer&, dai::DatatypeEnum)’:
/home/aljaz/work-luxonis/depthai-core/src/pipeline/node/host/Replay.cpp:107:11: warning: enumeration value ‘PacketizedData’ not handled in switch [-Wswitch]
  107 |     switch(datatype) {

Comment thread src/pipeline/node/internal/XLinkInHost.cpp
Comment thread src/pipeline/node/internal/XLinkInHost.cpp
Comment thread src/xlink/XLinkStream.cpp
Comment thread src/pipeline/datatype/StreamMessageParser.cpp
Comment thread tests/src/ondevice_tests/xlink_test.cpp
@JakubFara JakubFara force-pushed the feature/packetizedData branch 2 times, most recently from c59ebad to bdd0bbe Compare December 16, 2025 13:13
@JakubFara
Copy link
Copy Markdown
Collaborator Author

#1580 (review)
Warnings fixed here: e9a8afe Fix warnings

@JakubFara JakubFara force-pushed the feature/packetizedData branch 2 times, most recently from 7222d40 to 1af49e9 Compare December 16, 2025 16:18
@JakubFara JakubFara force-pushed the feature/packetizedData branch from 1af49e9 to 53fb5c0 Compare January 8, 2026 15:43
Copy link
Copy Markdown
Collaborator

@moratom moratom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let's add the RVC4 implementation as well before merging (should be faster now than later) and we have to do it anyhow.

Comment thread tests/CMakeLists.txt
dai_add_test(calibration_handler_test src/onhost_tests/calibration_handler_test.cpp)
dai_set_test_labels(calibration_handler_test onhost ci)

# XLInkInHost test
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XLinkInHost

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/xlink/XLinkStream.cpp
@JakubFara JakubFara force-pushed the feature/packetizedData branch from 53fb5c0 to e8e09bc Compare January 12, 2026 09:50
@JakubFara JakubFara force-pushed the feature/packetizedData branch 2 times, most recently from a95d001 to fa446a8 Compare January 23, 2026 09:29
@moratom moratom added the testable PR is ready to be tested label Jan 27, 2026
@JakubFara JakubFara force-pushed the feature/packetizedData branch 2 times, most recently from 003c917 to 3385417 Compare January 27, 2026 16:04
@MaticTonin MaticTonin added testable PR is ready to be tested and removed testable PR is ready to be tested labels Jan 27, 2026
@JakubFara JakubFara force-pushed the feature/packetizedData branch 3 times, most recently from 5a4c53a to 60208a3 Compare January 29, 2026 10:35
@JakubFara JakubFara force-pushed the feature/packetizedData branch 2 times, most recently from a40f868 to 0c4f317 Compare January 29, 2026 15:19
@JakubFara JakubFara force-pushed the feature/packetizedData branch from 0c4f317 to 722e32d Compare January 29, 2026 15:20
@MaticTonin MaticTonin merged commit 794ebdf into develop Jan 29, 2026
@MaticTonin MaticTonin deleted the feature/packetizedData branch January 29, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testable PR is ready to be tested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants