labstreaminglayer / pylsl

Python bindings (pylsl) for liblsl
MIT License
142 stars 58 forks source link

No support for variable-length binary data #7

Closed papr closed 5 years ago

papr commented 5 years ago

The XDF format specification explicitly states support for

non-numeric (i.e., string or binary) values, [with] a variable-length encoding

To my knowledge, the only supported variable-length type in pylsl is pylsl.cf_string.

The issue is that the pylsl.StreamOutlet.push_sample() implementation only accepts unicode strings. It does not support objects of type bytes, etc.

Is there a reason why byte-like objects are not supported?

Suggested solution: Wrap the .encode("utf-8") in a try-except block that catches the attribute error in case the user passed bytes-like objects, see https://stackoverflow.com/a/34870210.

I would like to start working on a PR as soon as one of the developers (maybe @cboulay) confirms the issue and signs off on the suggested solution.

Motivation: Support for variable-length binary data is crucial for the upcoming Pupil Labs LSL Relay plugin changes.

mgrivich commented 5 years ago

Please read and move the discussion to this issue: Add support for variable length typed data