See
Short introduction — pySerial 3.4 documentation[
^] and
pySerial API — pySerial 3.4 documentation[
^].
Serial.read(size=1)
reads the specified number of bytes which is one by default. That is why you get only one character.
readline()
reads until a new line character is received. This function can't be used when the other side is not responding with new line terminated answers. It requires also to specify a timeout when openening the port.
readlines()
calls
readline()
until an
EOF
occurs. But such never happens with serial ports so that the function terminates when the timeout has elapsed.
It is a general problem of serial communication to detect the end of a "package" when those does not have a fixed size.
The common method when using strings is using the new line character or a character not occuring in strings like a null byte as end of package indicator.
Binary data can be prefixed with a header of fixed size containing the length of the data. So the receiver knows how many data bytes he has to expect. A receiver reads than the header bytes first and the remaining payload bytes afterwards.
Conclusion:
You have to know the used data format (called
protocol) or define it when implementing both communication sides.