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

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
nickovs
Posts: 11
Joined: Sun Sep 11, 2016 8:11 pm

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

Post by nickovs » Mon Oct 10, 2016 5:08 am

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?

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

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

Post by Damien » Mon Oct 10, 2016 9:13 am

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

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

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

Post by jms » Mon Oct 10, 2016 9:40 am

I think you're looking for what is typically provided by the operating system.

If you want carriage returns produce them yourself.

nickovs
Posts: 11
Joined: Sun Sep 11, 2016 8:11 pm

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

Post by nickovs » Mon Oct 10, 2016 7:13 pm

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.

nickovs
Posts: 11
Joined: Sun Sep 11, 2016 8:11 pm

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

Post by nickovs » Tue Oct 11, 2016 3:38 am

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.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

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

Post by platforma » Tue Oct 11, 2016 3:44 pm


nickovs
Posts: 11
Joined: Sun Sep 11, 2016 8:11 pm

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

Post by nickovs » Tue Oct 11, 2016 5:27 pm

platforma wrote:Just FYI, this was added in https://github.com/micropython/micropython/pull/2502
Excellent. Thanks!

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

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

Post by Damien » Wed Oct 12, 2016 12:09 am

This feature was just merged into master.

Post Reply