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

Deprecate implicit types and define explicit message types for JSON format #11

Open
peplin opened this issue Aug 2, 2014 · 0 comments
Assignees

Comments

@peplin
Copy link
Member

peplin commented Aug 2, 2014

For sending from a VI to a client, the implicit types are those were we have to infer whether it is a translated message, CAN message, diagnostic message, etc. For example, these are two different implicit messages:

{"name": "foo, "value": bar"}
{"id": 42, "bus": 1, "data": "0x1234"}

The first is a simple, translated message. The second is a CAN message. The only way for the client to tell the different is to check in a particular order if the message contains the fields required for each message type.

The pros of implicit messages is that they are very concise - no extra type field to send over Bluetooth/USB. Up until now, they have also been trivial to process - we just didn't have that much variation in message types.

The cons, which is why I've opened this ticket: as we expand to many more types of message (diagnostic requests and responses, commands, etc), this is getting very cumbersome. It's also tricky if one message is a superset of another. You have to make sure to check the message with more required fields first, otherwise you risk misidentification.

For the previous example messages, we would wrap the object with another key that tells the exact type, e.g.:

{"simple": {"name": "foo, "value": bar"}}
{"can": {"id": 42, "bus": 1, "data": "0x1234"}}

It's now much easier for the client to deserialize the messages. The types as of today would be:

  • simple
  • evented
  • can
  • diagnostic
  • command

The cons? Each message has a few extra bytes to include the explicit type. However, now that we have the binary message format (with protocol buffers), anyone that needs the utmost level of performance should be using that instead (which are already all explicitly typed).

To summarize: If you need performance, use the binary message format. If you need flexibility, readability or easier deserialization, use JSON. Once implemented, we can start to deprecate the implicit JSON format over a couple over firmware releases.

@peplin peplin self-assigned this Aug 5, 2014
peplin added a commit to openxc/openxc-android that referenced this issue Sep 8, 2014
@peplin peplin changed the title Deprecate implicit types and definite explicit message types for JSON format Deprecate implicit types and define explicit message types for JSON format Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant