Page 1 of 1

ESP board doesn't support std{in,out,err}.buffer

Posted: Mon Oct 10, 2016 5:08 am
by nickovs
Is there some reason why the builds of MicroPython for the ESP board don't support the stdio 'buffer' support for raw access to the terminal? The standard stdio streams do a bunch of translation between '\n', '\r' and '\r\n' on input and output, which is desirable for certain console operations but makes it a complete pain if you want to transfer binary files across the serial interface.

The main PyBoard code has support for access to the raw version of the terminal, through sys.stdio.buffer and sys.stdout.buffer. This support doesn't seem to be switched on for the ESP8266 version. It seems to just need:

Code: Select all

#define MICROPY_PY_SYS_STDIO_BUFFER (1)
being added to the mpconfigport.h, but I can't get the ESP build environment to work so I can't try it.

If there is some reason why this can't work on the ESP cards then it would be helpful to know. If there is no good reason, could someone who has the ability to test this please switch it on and submit the one line patch?

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Mon Oct 10, 2016 9:13 am
by Damien
It would be useful to have the buffer object. In the meantime you can use the machine.UART(0) object to access the serial in a binary way.

Sent from my GT-I9105P using Tapatalk

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Mon Oct 10, 2016 9:40 am
by jms
I think you're looking for what is typically provided by the operating system.

If you want carriage returns produce them yourself.

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Mon Oct 10, 2016 7:13 pm
by nickovs
Damien wrote:It would be useful to have the buffer object. In the meantime you can use the machine.UART(0) object to access the serial in a binary way.
Yes, I realise that I can reach the raw UART directly by name but that makes the code non-portable. I'm trying to communicate with a variety of boards from another machine and the other machine doesn't know a priori what port a given board is going to be using. This appears to have been the same motivation for putting the buffer support there in the first place. It would just be nice to get the buffer support enabled on the ESP8266 build.

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Tue Oct 11, 2016 3:38 am
by nickovs
I managed to get the tool chain working and build my own version of the ESP8266 port. Simply adding the one #define to the mpconfigport.h file seems to be sufficient to make this work and it seems to be working fine on my card. Hopefully this can get switched on by default in the main line builds of this port.

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Tue Oct 11, 2016 3:44 pm
by platforma

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Tue Oct 11, 2016 5:27 pm
by nickovs
platforma wrote:Just FYI, this was added in https://github.com/micropython/micropython/pull/2502
Excellent. Thanks!

Re: ESP board doesn't support std{in,out,err}.buffer

Posted: Wed Oct 12, 2016 12:09 am
by Damien
This feature was just merged into master.