Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds log_messages field to device data so that SlimeVR GUI can display log messages from the device #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions protocol/cpp/include/solarxr_protocol/generated/all_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -3777,7 +3777,8 @@ struct DeviceData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_CUSTOM_NAME = 6,
VT_HARDWARE_INFO = 8,
VT_HARDWARE_STATUS = 10,
VT_TRACKERS = 12
VT_TRACKERS = 12,
VT_LOG_MESSAGES = 14
};
const solarxr_protocol::datatypes::DeviceId *id() const {
return GetStruct<const solarxr_protocol::datatypes::DeviceId *>(VT_ID);
Expand All @@ -3799,6 +3800,9 @@ struct DeviceData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const flatbuffers::Vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>> *trackers() const {
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>> *>(VT_TRACKERS);
}
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *log_messages() const {
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_LOG_MESSAGES);
}
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<solarxr_protocol::datatypes::DeviceId>(verifier, VT_ID, 1) &&
Expand All @@ -3811,6 +3815,9 @@ struct DeviceData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyOffset(verifier, VT_TRACKERS) &&
verifier.VerifyVector(trackers()) &&
verifier.VerifyVectorOfTables(trackers()) &&
VerifyOffset(verifier, VT_LOG_MESSAGES) &&
verifier.VerifyVector(log_messages()) &&
verifier.VerifyVectorOfStrings(log_messages()) &&
verifier.EndTable();
}
};
Expand All @@ -3834,6 +3841,9 @@ struct DeviceDataBuilder {
void add_trackers(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>>> trackers) {
fbb_.AddOffset(DeviceData::VT_TRACKERS, trackers);
}
void add_log_messages(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> log_messages) {
fbb_.AddOffset(DeviceData::VT_LOG_MESSAGES, log_messages);
}
explicit DeviceDataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
Expand All @@ -3851,8 +3861,10 @@ inline flatbuffers::Offset<DeviceData> CreateDeviceData(
flatbuffers::Offset<flatbuffers::String> custom_name = 0,
flatbuffers::Offset<solarxr_protocol::datatypes::hardware_info::HardwareInfo> hardware_info = 0,
flatbuffers::Offset<solarxr_protocol::datatypes::hardware_info::HardwareStatus> hardware_status = 0,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>>> trackers = 0) {
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>>> trackers = 0,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> log_messages = 0) {
DeviceDataBuilder builder_(_fbb);
builder_.add_log_messages(log_messages);
builder_.add_trackers(trackers);
builder_.add_hardware_status(hardware_status);
builder_.add_hardware_info(hardware_info);
Expand All @@ -3867,16 +3879,19 @@ inline flatbuffers::Offset<DeviceData> CreateDeviceDataDirect(
const char *custom_name = nullptr,
flatbuffers::Offset<solarxr_protocol::datatypes::hardware_info::HardwareInfo> hardware_info = 0,
flatbuffers::Offset<solarxr_protocol::datatypes::hardware_info::HardwareStatus> hardware_status = 0,
const std::vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>> *trackers = nullptr) {
const std::vector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>> *trackers = nullptr,
const std::vector<flatbuffers::Offset<flatbuffers::String>> *log_messages = nullptr) {
auto custom_name__ = custom_name ? _fbb.CreateString(custom_name) : 0;
auto trackers__ = trackers ? _fbb.CreateVector<flatbuffers::Offset<solarxr_protocol::data_feed::tracker::TrackerData>>(*trackers) : 0;
auto log_messages__ = log_messages ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*log_messages) : 0;
return solarxr_protocol::data_feed::device_data::CreateDeviceData(
_fbb,
id,
custom_name__,
hardware_info,
hardware_status,
trackers__);
trackers__,
log_messages__);
}

} // namespace device_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,22 @@ public final class DeviceData extends Table {
public int trackersLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
public solarxr_protocol.data_feed.tracker.TrackerData.Vector trackersVector() { return trackersVector(new solarxr_protocol.data_feed.tracker.TrackerData.Vector()); }
public solarxr_protocol.data_feed.tracker.TrackerData.Vector trackersVector(solarxr_protocol.data_feed.tracker.TrackerData.Vector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public String logMessages(int j) { int o = __offset(14); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int logMessagesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
public StringVector logMessagesVector() { return logMessagesVector(new StringVector()); }
public StringVector logMessagesVector(StringVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }

public static void startDeviceData(FlatBufferBuilder builder) { builder.startTable(5); }
public static void startDeviceData(FlatBufferBuilder builder) { builder.startTable(6); }
public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addStruct(0, idOffset, 0); }
public static void addCustomName(FlatBufferBuilder builder, int customNameOffset) { builder.addOffset(1, customNameOffset, 0); }
public static void addHardwareInfo(FlatBufferBuilder builder, int hardwareInfoOffset) { builder.addOffset(2, hardwareInfoOffset, 0); }
public static void addHardwareStatus(FlatBufferBuilder builder, int hardwareStatusOffset) { builder.addOffset(3, hardwareStatusOffset, 0); }
public static void addTrackers(FlatBufferBuilder builder, int trackersOffset) { builder.addOffset(4, trackersOffset, 0); }
public static int createTrackersVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
public static void startTrackersVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
public static void addLogMessages(FlatBufferBuilder builder, int logMessagesOffset) { builder.addOffset(5, logMessagesOffset, 0); }
public static int createLogMessagesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
public static void startLogMessagesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
public static int endDeviceData(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
Expand Down Expand Up @@ -84,6 +91,9 @@ public void unpackTo(DeviceDataT _o) {
solarxr_protocol.data_feed.tracker.TrackerDataT[] _oTrackers = new solarxr_protocol.data_feed.tracker.TrackerDataT[trackersLength()];
for (int _j = 0; _j < trackersLength(); ++_j) {_oTrackers[_j] = (trackers(_j) != null ? trackers(_j).unpack() : null);}
_o.setTrackers(_oTrackers);
String[] _oLogMessages = new String[logMessagesLength()];
for (int _j = 0; _j < logMessagesLength(); ++_j) {_oLogMessages[_j] = logMessages(_j);}
_o.setLogMessages(_oLogMessages);
}
public static int pack(FlatBufferBuilder builder, DeviceDataT _o) {
if (_o == null) return 0;
Expand All @@ -97,12 +107,20 @@ public static int pack(FlatBufferBuilder builder, DeviceDataT _o) {
for (solarxr_protocol.data_feed.tracker.TrackerDataT _e : _o.getTrackers()) { __trackers[_j] = solarxr_protocol.data_feed.tracker.TrackerData.pack(builder, _e); _j++;}
_trackers = createTrackersVector(builder, __trackers);
}
int _logMessages = 0;
if (_o.getLogMessages() != null) {
int[] __logMessages = new int[_o.getLogMessages().length];
int _j = 0;
for (String _e : _o.getLogMessages()) { __logMessages[_j] = builder.createString(_e); _j++;}
_logMessages = createLogMessagesVector(builder, __logMessages);
}
startDeviceData(builder);
addId(builder, solarxr_protocol.datatypes.DeviceId.pack(builder, _o.getId()));
addCustomName(builder, _customName);
addHardwareInfo(builder, _hardwareInfo);
addHardwareStatus(builder, _hardwareStatus);
addTrackers(builder, _trackers);
addLogMessages(builder, _logMessages);
return endDeviceData(builder);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DeviceDataT {
private solarxr_protocol.datatypes.hardware_info.HardwareInfoT hardwareInfo;
private solarxr_protocol.datatypes.hardware_info.HardwareStatusT hardwareStatus;
private solarxr_protocol.data_feed.tracker.TrackerDataT[] trackers;
private String[] logMessages;

public solarxr_protocol.datatypes.DeviceIdT getId() { return id; }

Expand All @@ -34,13 +35,18 @@ public class DeviceDataT {

public void setTrackers(solarxr_protocol.data_feed.tracker.TrackerDataT[] trackers) { this.trackers = trackers; }

public String[] getLogMessages() { return logMessages; }

public void setLogMessages(String[] logMessages) { this.logMessages = logMessages; }


public DeviceDataT() {
this.id = new solarxr_protocol.datatypes.DeviceIdT();
this.customName = null;
this.hardwareInfo = null;
this.hardwareStatus = null;
this.trackers = null;
this.logMessages = null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ class DeviceData : Table() {
get() {
val o = __offset(12); return if (o != 0) __vector_len(o) else 0
}
fun logMessages(j: Int) : String? {
val o = __offset(14)
return if (o != 0) {
__string(__vector(o) + j * 4)
} else {
null
}
}
val logMessagesLength : Int
get() {
val o = __offset(14); return if (o != 0) __vector_len(o) else 0
}
companion object {
@JvmStatic
fun validateVersion() = Constants.FLATBUFFERS_22_10_26()
Expand All @@ -92,7 +104,7 @@ class DeviceData : Table() {
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
@JvmStatic
fun startDeviceData(builder: FlatBufferBuilder) = builder.startTable(5)
fun startDeviceData(builder: FlatBufferBuilder) = builder.startTable(6)
@JvmStatic
fun addId(builder: FlatBufferBuilder, id: Int) = builder.addStruct(0, id, 0)
@JvmStatic
Expand All @@ -114,6 +126,18 @@ class DeviceData : Table() {
@JvmStatic
fun startTrackersVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
@JvmStatic
fun addLogMessages(builder: FlatBufferBuilder, logMessages: Int) = builder.addOffset(5, logMessages, 0)
@JvmStatic
fun createLogMessagesVector(builder: FlatBufferBuilder, data: IntArray) : Int {
builder.startVector(4, data.size, 4)
for (i in data.size - 1 downTo 0) {
builder.addOffset(data[i])
}
return builder.endVector()
}
@JvmStatic
fun startLogMessagesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
@JvmStatic
fun endDeviceData(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl<'a> DeviceData<'a> {
pub const VT_HARDWARE_INFO: flatbuffers::VOffsetT = 8;
pub const VT_HARDWARE_STATUS: flatbuffers::VOffsetT = 10;
pub const VT_TRACKERS: flatbuffers::VOffsetT = 12;
pub const VT_LOG_MESSAGES: flatbuffers::VOffsetT = 14;

#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Expand All @@ -44,6 +45,7 @@ impl<'a> DeviceData<'a> {
args: &'args DeviceDataArgs<'args>
) -> flatbuffers::WIPOffset<DeviceData<'bldr>> {
let mut builder = DeviceDataBuilder::new(_fbb);
if let Some(x) = args.log_messages { builder.add_log_messages(x); }
if let Some(x) = args.trackers { builder.add_trackers(x); }
if let Some(x) = args.hardware_status { builder.add_hardware_status(x); }
if let Some(x) = args.hardware_info { builder.add_hardware_info(x); }
Expand Down Expand Up @@ -93,6 +95,13 @@ impl<'a> DeviceData<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<super::tracker::TrackerData>>>>(DeviceData::VT_TRACKERS, None)}
}
#[inline]
pub fn log_messages(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>> {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>(DeviceData::VT_LOG_MESSAGES, None)}
}
}

impl flatbuffers::Verifiable for DeviceData<'_> {
Expand All @@ -107,6 +116,7 @@ impl flatbuffers::Verifiable for DeviceData<'_> {
.visit_field::<flatbuffers::ForwardsUOffset<super::super::datatypes::hardware_info::HardwareInfo>>("hardware_info", Self::VT_HARDWARE_INFO, false)?
.visit_field::<flatbuffers::ForwardsUOffset<super::super::datatypes::hardware_info::HardwareStatus>>("hardware_status", Self::VT_HARDWARE_STATUS, false)?
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<super::tracker::TrackerData>>>>("trackers", Self::VT_TRACKERS, false)?
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<&'_ str>>>>("log_messages", Self::VT_LOG_MESSAGES, false)?
.finish();
Ok(())
}
Expand All @@ -117,6 +127,7 @@ pub struct DeviceDataArgs<'a> {
pub hardware_info: Option<flatbuffers::WIPOffset<super::super::datatypes::hardware_info::HardwareInfo<'a>>>,
pub hardware_status: Option<flatbuffers::WIPOffset<super::super::datatypes::hardware_info::HardwareStatus<'a>>>,
pub trackers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<super::tracker::TrackerData<'a>>>>>,
pub log_messages: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>,
}
impl<'a> Default for DeviceDataArgs<'a> {
#[inline]
Expand All @@ -127,6 +138,7 @@ impl<'a> Default for DeviceDataArgs<'a> {
hardware_info: None,
hardware_status: None,
trackers: None,
log_messages: None,
}
}
}
Expand Down Expand Up @@ -157,6 +169,10 @@ impl<'a: 'b, 'b> DeviceDataBuilder<'a, 'b> {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(DeviceData::VT_TRACKERS, trackers);
}
#[inline]
pub fn add_log_messages(&mut self, log_messages: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<&'b str>>>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(DeviceData::VT_LOG_MESSAGES, log_messages);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> DeviceDataBuilder<'a, 'b> {
let start = _fbb.start_table();
DeviceDataBuilder {
Expand All @@ -179,6 +195,7 @@ impl core::fmt::Debug for DeviceData<'_> {
ds.field("hardware_info", &self.hardware_info());
ds.field("hardware_status", &self.hardware_status());
ds.field("trackers", &self.trackers());
ds.field("log_messages", &self.log_messages());
ds.finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,20 @@ trackersLength():number {
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

logMessages(index: number):string
logMessages(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
logMessages(index: number,optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
}

logMessagesLength():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

static startDeviceData(builder:flatbuffers.Builder) {
builder.startObject(5);
builder.startObject(6);
}

static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
Expand Down Expand Up @@ -112,6 +124,22 @@ static startTrackersVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static addLogMessages(builder:flatbuffers.Builder, logMessagesOffset:flatbuffers.Offset) {
builder.addFieldOffset(5, logMessagesOffset, 0);
}

static createLogMessagesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}

static startLogMessagesVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static endDeviceData(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
Expand All @@ -124,7 +152,8 @@ unpack(): DeviceDataT {
this.customName(),
(this.hardwareInfo() !== null ? this.hardwareInfo()!.unpack() : null),
(this.hardwareStatus() !== null ? this.hardwareStatus()!.unpack() : null),
this.bb!.createObjList<TrackerData, TrackerDataT>(this.trackers.bind(this), this.trackersLength())
this.bb!.createObjList<TrackerData, TrackerDataT>(this.trackers.bind(this), this.trackersLength()),
this.bb!.createScalarList<string>(this.logMessages.bind(this), this.logMessagesLength())
);
}

Expand All @@ -135,6 +164,7 @@ unpackTo(_o: DeviceDataT): void {
_o.hardwareInfo = (this.hardwareInfo() !== null ? this.hardwareInfo()!.unpack() : null);
_o.hardwareStatus = (this.hardwareStatus() !== null ? this.hardwareStatus()!.unpack() : null);
_o.trackers = this.bb!.createObjList<TrackerData, TrackerDataT>(this.trackers.bind(this), this.trackersLength());
_o.logMessages = this.bb!.createScalarList<string>(this.logMessages.bind(this), this.logMessagesLength());
}
}

Expand All @@ -144,7 +174,8 @@ constructor(
public customName: string|Uint8Array|null = null,
public hardwareInfo: HardwareInfoT|null = null,
public hardwareStatus: HardwareStatusT|null = null,
public trackers: (TrackerDataT)[] = []
public trackers: (TrackerDataT)[] = [],
public logMessages: (string)[] = []
){}


Expand All @@ -153,13 +184,15 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const hardwareInfo = (this.hardwareInfo !== null ? this.hardwareInfo!.pack(builder) : 0);
const hardwareStatus = (this.hardwareStatus !== null ? this.hardwareStatus!.pack(builder) : 0);
const trackers = DeviceData.createTrackersVector(builder, builder.createObjectOffsetList(this.trackers));
const logMessages = DeviceData.createLogMessagesVector(builder, builder.createObjectOffsetList(this.logMessages));

DeviceData.startDeviceData(builder);
DeviceData.addId(builder, (this.id !== null ? this.id!.pack(builder) : 0));
DeviceData.addCustomName(builder, customName);
DeviceData.addHardwareInfo(builder, hardwareInfo);
DeviceData.addHardwareStatus(builder, hardwareStatus);
DeviceData.addTrackers(builder, trackers);
DeviceData.addLogMessages(builder, logMessages);

return DeviceData.endDeviceData(builder);
}
Expand Down
3 changes: 3 additions & 0 deletions schema/data_feed/device_data.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ table DeviceData {

/// Info about all trackers attached to this device
trackers: [solarxr_protocol.data_feed.tracker.TrackerData];

/// Log messages sent from the device
log_messages: [string];
}