read() method without parameters, in the sense of Python's
io module is expected to read all bytes until an
EOF is found, which happens indirectly by calling
readall() (which indirectly also calls
read(), but with another number. pyserial's
read() defaults to reading one byte. And even actively calling
read(-1) doesn't result in the expected behavior. This is somewhat frustrating, if you want to write code that is exchangeable for all Python io-like interfaces.
In the stdlib can be found, that
read() is already implemented and either calls
readall() if n < 0 or calls a
readinto() method, which should be implemented by subclasses of
RawIOBase. Therefore from my point of view, serial should implement it's reading capabilities in a
readuntil() function and leave the other functions to the standard behaviour of
RawIOBase. Otherwise it doesn't make much sense to use
RawIOBase at all. Does that sound about right?
I mostly wrote this ticket, to get to a common ground of understanding with the developers of pyserial. I know that my solution will break current projects based on pyserial. So maybe the end result might be, to change something on a lower level, to allow users of the
io interface to write a Plugin for their API instead of changing the API for everybody. We'll see.
And I don't think I will find the time to produce a suitable implementation myself in the next weeks, sorry. Writing my Master's thesis currently. But maybe someone else will, if we can agree on a meaningful solution plan or I might get to it later on. In any case it looks to me like a general problem of pyserial which must be addressed at some point.
(btw. is there a mailing list? couldn't find one in the docs)