bbcmicrobit / micropython

Port of MicroPython for the BBC micro:bit
https://microbit-micropython.readthedocs.io
Other
603 stars 284 forks source link

uart.read does not document return results #594

Closed DavidWhaleMEF closed 5 years ago

DavidWhaleMEF commented 5 years ago

The current readthedocs does not say what data type and value uart.read() returns

https://microbit-micropython.readthedocs.io/en/latest/uart.html

screen shot 2018-10-30 at 13 38 29

It says:

Read characters. If nbytes is specified then read at most that many bytes.

So, does it read characters or does it read bytes? What does it return? characters does not equal bytes where character encodings are used. Also, what is the return type? If it returns characters, is this a string? If it returns bytes, is it a bytes() or a bytearray()?

The implication is that if you don't provide a parameter it reads characters, and if you do provide a parameter, it reads bytes, is that correct?

DavidWhaleMEF commented 5 years ago

By experimentation alone, the return type appears to be a bytes() object.

It didn't seem clear to me from the documentation that this was the case, because it talks about characters (which implies a string) and bytes (which could be a bytes() or a bytearray() )

microbit-carlos commented 5 years ago

PR https://github.com/bbcmicrobit/micropython/pull/588 already covered the return type, was that enough or does it need something more explicit?

DavidWhaleMEF commented 5 years ago

Thanks, commented in the PR. I will close this issue.