erpc icon indicating copy to clipboard operation
erpc copied to clipboard

Binary data size is lost on Python if connection breaks

Open daniellandau opened this issue 7 years ago • 0 comments

With basic_codec.py the length parameter is lost if for some reason the connection breaks and the full response isn't in the buffer. The code in question is:

    def read_binary(self):
        length = self.read_uint32()
        data = self._buffer[self._cursor:self._cursor+length]
        self._cursor += length
        return data

If self._buffer doesn't have length bytes after self._cursor, data will be happily shorter. The corresponding code in basic_codec.cpp returns an error, so an analogous thing might be to raise an exception in Python.

In my case though, I want to keep whatever I can from the response as I'm down linking data from a satellite and it's a waste to throw away bytes that did come through fine. What I would want is to get back the intended length and a data array whose length I could check and then request byte ranges manually from there with another procedure call. Maybe these fields could be even carried in an exception.

I'd be happy to write the code if I get indication on what would be an acceptable solution.

daniellandau avatar Sep 03 '18 07:09 daniellandau