Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
packet.h
Go to the documentation of this file.
1
10#pragma once
11#include <stdint.h>
12#include <iostream>
13#include <iomanip>
14
15#define SR_packet_sizeOffset 0
16#define SR_packet_destinationOffset (sizeof(SR_packet::size))
17#define SR_packet_payloadOffset (sizeof(SR_packet::size) + sizeof(SR_packet::destination))
18#define SR_packet_headerSize SR_packet_payloadOffset
19
25typedef struct {
26 uint64_t size;
27 uint64_t destination;
28 uint64_t payload;
29} SR_packet;
30
36static void SR_packet_print(SR_packet& packet) {
37 uint64_t frameSize = packet.size - SR_packet_payloadOffset;
38 std::cout << "SR_packet {\n"
39 << "\tsize: " << packet.size << "\n"
40 << "\tdestination: " << packet.destination << "\n"
41 << "\tpayload: "
42 << std::setfill('0') << std::hex;
43 for (uint64_t i = frameSize; i > 0; --i) {
44 std::cout << std::setw(2) << (int)(((uint8_t*)&packet.payload)[i - 1]) << " ";
45 }
46 std::cout << std::dec << std::endl;
47}
#define SR_packet_payloadOffset
Definition: packet.h:17
static void SR_packet_print(SR_packet &packet)
Print raw contents of SR network packet.
Definition: packet.h:36
C-compatible struct for communication between SR applications.
Definition: packet.h:25
uint64_t destination
Definition: packet.h:27
uint64_t payload
Start of binary payload data.
Definition: packet.h:28
uint64_t size
Definition: packet.h:26