You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Poofjunior Thanks for the great input and raising this requirement, I agree having more flexibility in passing around packed custom structures with possibly heterogeneous types is important.
Following the meeting, I was playing around with the YAML schema and actually there is a small kink that doesn't allow it to represent heterogeneous types out-of-the-box (yet). It is definitely fixable though and this is a use case we should indeed support so I will flag an issue to fix it. Nevertheless, for aligned types, you could do:
%YAML 1.1
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/harp-tech/reflex-generator/main/schema/device.jsondevice: harpywhoAmI: 0000firmwareVersion: "0.1"hardwareTargets: "0.0"registers:
Accelerometer:
address: 32type: S16length: 3access: EventpayloadSpec:
X:
offset: 0description: Represents the x-coordinate of the payload.Y:
offset: 1description: Represents the y-coordinate of the payload.Z:
offset: 2description: Represents the z-coordinate of the payload.
This will generate in the high-level interface the type AccelerometerPayload with the following signature (edited for conciseness):
It is actually possible using the message manipulation API to marshal arbitrary payload structs directly (with the equivalent of memcpy), and having an easy way to specify something like this in the spec is definitely interesting. I think I have a solution but need to go through a few edge cases more carefully to make sure it will be workable. Thanks for the push! I'll post here once I have something more complete.
@Poofjunior Thanks for the great input and raising this requirement, I agree having more flexibility in passing around packed custom structures with possibly heterogeneous types is important.
Following the meeting, I was playing around with the YAML schema and actually there is a small kink that doesn't allow it to represent heterogeneous types out-of-the-box (yet). It is definitely fixable though and this is a use case we should indeed support so I will flag an issue to fix it. Nevertheless, for aligned types, you could do:
This will generate in the high-level interface the type
AccelerometerPayload
with the following signature (edited for conciseness):And the auto-generated converters:
It is actually possible using the message manipulation API to marshal arbitrary payload structs directly (with the equivalent of
memcpy
), and having an easy way to specify something like this in the spec is definitely interesting. I think I have a solution but need to go through a few edge cases more carefully to make sure it will be workable. Thanks for the push! I'll post here once I have something more complete.Originally posted by @glopesdev in #27 (comment)
The text was updated successfully, but these errors were encountered: