Weird chars on paste in screen

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Weird chars on paste in screen

Post by mcauser » Fri Jan 05, 2018 8:56 am

I've noticed a few times when I paste a long string in gnu screen on OSX, the characters are garbled, but still execute correctly.
Sometimes it fails repeatably with small strings.

Code: Select all

$ screen /dev/tty.usbmodem1422 115200

Code: Select all

MicroPython v1.7-9-gbe020eb on 2016-04-18; micro:bit with nRF51822
Type "help()" for more information.
Copy and paste "from microbit import *" and enter.

Code: Select all

>>> mcimmicrobit import *
Copy and paste "display.show('1')" and enter (and repeat 3x).

Code: Select all

>>> p.w'lay.show('1')
>>> p.w'lay.show('1')
>>> p.w'lay.show('1')
Manually type it and enter.

Code: Select all

>>> display.show('1')
Paste, same garbled text.

Code: Select all

>>> h'play.show('1')
Anyone come across this?

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

Re: Weird chars on paste in screen

Post by dhylands » Fri Jan 05, 2018 3:08 pm

Since it seems to be working, I'm going to guess that this is a problem with GNU screen, but it could also be an issue with the MCU too.

It's interesting to consider the path of a single character when its typed.
  1. You type a character.
  2. This is seen by your terminal emulator which then sends it out the TX line
  3. The MCU sees the character and adds it to its queue
  4. The MCU then echos back the character to its TX line
  5. The terminal emulator sees the character on its RX line and displays it back to the user.
If characters are being generated really quickly (as they are when pasting) then sometimes a character might get lost. In your example, it looks like the character is getting lost at steps 4 or 5. Many terminal emulators have an option to introduce a small delay between each pasted character, which can help alleviate this problem.

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: Weird chars on paste in screen

Post by mcauser » Fri Jan 05, 2018 4:24 pm

After flashing MicroPython v1.9.2-34-gd64154c73 from the version1 branch, the problem went away!

I was using MicroPython v1.7-9-gbe020eb from the master branch.

Post Reply