ntoll / microrepl

A REPL client for MicroPython running on the BBC micro:bit.
Other
32 stars 17 forks source link

Error configuring miniterm on windows #16

Closed carlosperate closed 6 years ago

carlosperate commented 6 years ago

Testes on Windows 10 x64, Python 2.7 (32-bits), with Pyserial 3.4:

>python microrepl.py
port COM3
Traceback (most recent call last):
  File "microrepl.py", line 119, in <module>
    main()
  File "microrepl.py", line 98, in main
    miniterm = connect_miniterm(port)
  File "microrepl.py", line 60, in connect_miniterm
    echo=False,
  File "C:\Users\carlo\Envs\py2ubitflash\lib\site-packages\serial\tools\miniterm.py", line 341, in __init__
    self.console = Console()
  File "C:\Users\carlo\Envs\py2ubitflash\lib\site-packages\serial\tools\miniterm.py", line 109, in __init__
    self.output = codecs.getwriter('UTF-8')(Out(sys.stdout.fileno()), 'replace')
  File "C:\Users\carlo\Envs\py2ubitflash\lib\codecs.py", line 401, in __getattr__
    return getattr(self.stream, name)
AttributeError: 'Out' object has no attribute 'fileno'

Testes on Windows 10 x64, Python 3.5 (32-bits), with Pyserial 3.1.1:

>python microrepl.py
port COM3
Traceback (most recent call last):
  File "microrepl.py", line 119, in <module>
    main()
  File "microrepl.py", line 98, in main
    miniterm = connect_miniterm(port)
  File "microrepl.py", line 60, in connect_miniterm
    echo=False,
  File "C:\Users\carlo\Envs\py3mu\lib\site-packages\serial\tools\miniterm.py", line 348, in __init__
    self.console = Console()
  File "C:\Users\carlo\Envs\py3mu\lib\site-packages\serial\tools\miniterm.py", line 104, in __init__
    super(Console, self).__init__()
  File "C:\Users\carlo\Envs\py3mu\lib\site-packages\serial\tools\miniterm.py", line 46, in __init__
    self.byte_output = sys.stdout.buffer
  File "C:\Users\carlo\Envs\py3mu\lib\codecs.py", line 408, in __getattr__
    return getattr(self.stream, name)
AttributeError: 'Out' object has no attribute 'buffer'
Exception ignored in: <bound method Console.__del__ of <serial.tools.miniterm.Console object at 0x034462B0>>
Traceback (most recent call last):
  File "C:\Users\carlo\Envs\py3mu\lib\site-packages\serial\tools\miniterm.py", line 116, in __del__
    ctypes.windll.kernel32.SetConsoleOutputCP(self._saved_ocp)
AttributeError: 'Console' object has no attribute '_saved_ocp'

The line that causes this in the microrepl scrip is: https://github.com/ntoll/microrepl/blob/4065e2154be2afb5a4153e0e8ebacf459fc7d1d2/microrepl.py#L58-L63 So we must be misconfiguring something in Miniterm that only causes an issue on Windows.

carlosperate commented 6 years ago

Closed via #17.