Harp 32-bit protocol thoughts (and a tangent about Harp protocol extensibility) #136
Unanswered
PathogenDavid
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
(#134 unintentionally nerd sniped me into writing out my thoughts on possible improvements to Harp. This was originally going to be a comment there but I realized that'd cause it to disappear into oblivion when that issue gets closed so I'm rambling here instead.)
If/when we do ratify the 32bit protocol we should take the opportunity to address some areas that could stand to be improved.
I don't expect any of this to be addressed or considered anytime soon, maybe not even ever. Just wanted to get some of these things out of my head.
I have a longer list somewhere, but here's some possible improvements that come to mind (with some added commentary on the 32-bit spec since I was looking at it while writing):
Thoughts on the 32-bit protocol specifically
Flag32
flag inMessageType
(making the protocol compatible), but I feel like generally devices will either speak Harp8 or Harp32, but this implementation requires both (and requires resolving weirdness like when a Harp32 devices receives a Harp8 message that would require a Harp32 message to reply to.)device.yml
to know which protocol to speak, but we could also negotiate the protocol (see below.)Protocol negotiation
If using
device.yml
is undesirable (IE: if an existing Harp devices is upgraded from Harp8 to Harp32), Harp clients negotiate could be mandated to negotiate with the device upon initial connection. Rough implementation would look like this:Read
R_PROTOCOL_CAPABILITIES
u8[], no timestamp
R_POROTOCOL_CAPABILITIES
as described below.R_POROTOCOL_CAPABILITIES
R_POROTOCOL_CAPABILITIES
replies with a list of lists of capability IDs (variable-length register proposal intensifies](https://github.com/KhronosGroup/glTF/tree/5de957b8b0a13c147c90d4ff569250440931872f/specification/2.0#specifying-extensions)).A list is terminated either by the end of the payload or a 0x00.
The first list contains any required capabilities (IE: clients should cease communication if they don't recognize anything here.)
The second list contains any optional capabilities (IE: clients can ignore anything they don't understand and may opt in to using ones that they do.)
The separation is important to allow clients to know if they're actually capable of talking to the device. Utilizing optional capabilities is implementation-defined for each capability. The separation also allows a capability to be either (such as a device which was retrofitted to use Harp32 but still supports Harp8 in order to support old clients.)
(This is inspired by the glTF extension mechanism.)
So if you imagine we have the following capabilities defined:
A Harp32 device would respond with
[0x01]
to indicate it requires Harp32 and provides no optional capabilities.A Harp8 device might respond with
[0x02, 0x00, 0x03]
to indicate that it requires Harp8 framing and optionally supports the Harp8 CRC-8 extension. (So a client must use Harp8 framing, but only has to opt-in to using CRC-8 instead of sum complement if knows how.)A different Harp8 device might respond with
[0x02, 0x03, 0x04]
to indicate that it requires Harp8 framing, the CRC-8 extension, and uses nanosecond timestamps.A legacy Harp8 device would respond with an error, which shall be interpreted as an empty payload for the purposes of the protocol negotiation.
One thing important to highlight is that the definition of a sublist always terminates on 0x00. This means that
[0x02, 0x00, 0x03, 0x00, 0x42]
contains three lists, and the purpose of the third list is undefined (and must be ignored.)Beta Was this translation helpful? Give feedback.
All reactions