Page 1 of 1

Rshell buffer size

Posted: Thu Jun 14, 2018 2:22 pm
by philwilkinson40
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

Re: Rshell buffer size

Posted: Thu Jun 14, 2018 4:49 pm
by dhylands
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.

Re: Rshell buffer size

Posted: Fri Jun 15, 2018 5:23 am
by pythoncoder
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.

Re: Rshell buffer size

Posted: Fri Jun 15, 2018 9:14 am
by philwilkinson40
Many thanks @pythoncoder @dylands, really clearly explained!
Sorry I forgot to mention the devboards were ESP8266.

Re: Rshell buffer size

Posted: Mon Jun 18, 2018 12:04 am
by cefn
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.

Re: Rshell buffer size

Posted: Wed Jun 20, 2018 12:27 pm
by philwilkinson40
@cefn I answered your question with a new post