Skip to content

How to transmit binary data? #65

@BenediktBurger

Description

@BenediktBurger

Sometime you have to transmit binary data, like an image.
JSON (our main encoding scheme) does not support binary data.
What do we recommend?

Several options, which are all compatible with current LECO definitions:

  1. You can send the binary data in the first (and more) payload frame, while setting the message_type to some specific (TBD) value
  2. You can send a JSON message in the first payload frame and add the binary objects in additional payload frames.
    This requires, however, that the code looks at the whole message and makes the additional frames available to the json-rpc interpreter somehow.
    Here it might be good to define its own message type as well.
    (I implemented this for PyMoDAQ)
  3. You can encode the binary data with some binary-to-text encoding to plain ASCII text, which can be sent via JSON.
    The most common encoding seems to be base64.

All three approaches have their advantages and disadvantages.
I guess the choice depends on the circumstances.
Here I want to present them, maybe we can recommend one or the other, or even all three as

Metadata

Metadata

Assignees

No one assigned

    Labels

    messagesConcerns the message formatquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions