Rshell buffer size

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
philwilkinson40
Posts: 46
Joined: Tue Nov 14, 2017 3:11 am
Location: Perth, Australia

Rshell buffer size

Post by philwilkinson40 » Thu Jun 14, 2018 2:22 pm

I just taught a short practical micropython course this evening; we used Rshell to transfer files and enter the REPL. I love Rshell, it allows a really simple interface to boards running micropython.
At the course somebody asked why are we defining the buffer size on starting and I wasn't sure.

Code: Select all

rshell --buffer-size=30 -a -p /dev/ttyUSB0
Can someone explain, to a person of limited intelligence like me, why does the buffer size need to be defined? Why is 30 a reasonable number, and when/why would this parameter change?
thanks Phil

User avatar
dhylands
Posts: 2880
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Rshell buffer size

Post by dhylands » Thu Jun 14, 2018 4:49 pm

When I wrote rshell, it was focused on the pyboard, which has a native USB peripheral, and the default buffer size was set to 512 bytes.

Devices which use a serial interface typically have much smaller buffers. rshell can do ascii or binary. The ascii mode transfer send 2 bytes for each byte of data.

The default serial buffer size is 64 bytes. In ascii mode, this would drop to 32 bytes of data being transferred. Setting a wee bit smaller for good measure yields a buffer size of 30 bytes,

When transferring files, the host will send "buffer size" bytes of data and then wait for an ACK. The host can typically send data at full serial speeds and the receiving device often cab't keep up, especially when writing to flash. The serial driver on the device typically uses hardware ISRs to store the data into the serial buffer, and it can normally keep up to whatever the full serial rate is, but the python code often gets delayed waiting for data writes to flash to finish etc.

User avatar
pythoncoder
Posts: 3051
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Rshell buffer size

Post by pythoncoder » Fri Jun 15, 2018 5:23 am

Just to add to this, this means that you don't need to specify --buffer-size or -a when communicating with a Pyboard. The -a (ASCII-transfer) option was added because ESP platforms barfed on certain byte sequences when sending binary data such as .mpy files.

Both these options can impact transfer speed.
Peter Hinch

User avatar
philwilkinson40
Posts: 46
Joined: Tue Nov 14, 2017 3:11 am
Location: Perth, Australia

Re: Rshell buffer size

Post by philwilkinson40 » Fri Jun 15, 2018 9:14 am

Many thanks @pythoncoder @dylands, really clearly explained!
Sorry I forgot to mention the devboards were ESP8266.

cefn
Posts: 205
Joined: Tue Aug 09, 2016 10:58 am

Re: Rshell buffer size

Post by cefn » Mon Jun 18, 2018 12:04 am

Where can I find out more about your Micropython tuition? What boards did you use? Are any of the materials or projects you used documented so I can learn from them?

I am trying to gather some resources at http://vgkits.org to help educators in the UK get started with absolute budget micropython physical computing on ESP8266, so very curious to know the approaches you've decided on.

User avatar
philwilkinson40
Posts: 46
Joined: Tue Nov 14, 2017 3:11 am
Location: Perth, Australia

Re: Rshell buffer size

Post by philwilkinson40 » Wed Jun 20, 2018 12:27 pm

@cefn I answered your question with a new post

Post Reply