-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support for pushing arbitrary byte sequences in cf_string channels #54
Comments
Just thinking out loud... We could add another pylsl-only How does that sound? I prefer doing something like this instead of adding a kwarg that is only relevant in << 1% of cases and might be confusing if not documented exactly correctly. |
@cboulay I think this is a very good alternative. 👍🏻 @ClaraKuper and I will work on an implementation proposal. |
I heard from @ClaraKuper in Slack that you are now encountering a problem with your char-arrays being interpreted as null-terminated strings, effectively cutting your data whenever a There's another Since we are providing the length of the char array, it uses the 'from sequence' std::string constructor (5 here), and it shouldn't do a null termination. So, as above, if you use a new |
Even with the above change, I suspect you'll still encounter some difficulties on the receiving end. For example, xdf importers may attempt to coerce the blob into a string and will do the null termination... I haven't looked too closely at that. |
We would like to transmit arbitrary byte sequences using pylsl and cf_string channels. Unfortunately, the current pylsl implementation does not support that. Technically, it should work just fine though.
liblsl states the following about the
cft_string
channel format:For the user's convenience, pylsl cf_string outlets accept Python
str
objects and encode them on the fly. Similarly, the cf_string inlets decode incoming byte strings tostr
objects.While this is helpful 99% of the time, it makes sending/receiving arbitrary byte strings impossible, e.g. when one wants to transmit encoded video frame data. Decoding our bytestring to utf-8 first and then have pylsl encode it again is unfortunately not a viable workaround as not all byte sequences can be decoded to utf-8.
Proposed solution
We suggest adding a boolean flag to the corresponding
pull_*
andpush_*
function that indicates wether the data should be encoded/decoded, defaulting toTrue
. This should fit conceptionally, given that it is the users responsibility to interpret the data.Dear pylsl maintainers, what do you think about this proposal?
/cc @ClaraKuper
The text was updated successfully, but these errors were encountered: