Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote device monitor crashes on first keypress #4068

Closed
neilenns opened this issue Sep 26, 2021 · 4 comments
Closed

Remote device monitor crashes on first keypress #4068

neilenns opened this issue Sep 26, 2021 · 4 comments
Assignees
Milestone

Comments

@neilenns
Copy link

neilenns commented Sep 26, 2021

Configuration

Operating system:

Ubuntu (remote monitor), Windows 10 (remote agent)

PlatformIO Version (platformio --version):

PlatformIO Core, version 5.2.0

Description of problem

The remote device monitor crashes as soon as I press any key to try and send a character to the attached remote device.

Steps to Reproduce

  1. Fire up pio remote agent start on your remote machine
  2. Locally start up pio remote device monitor
  3. Press any key in the serial monitor window

Actual Results

Unhandled Error
Traceback (most recent call last):
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/home/vscode/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/client/device_monitor.py", line 33, in dataReceived
    self.factory.send_to_server(data)
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/client/device_monitor.py", line 68, in send_to_server
    self.cdm.acwrite_data(data)
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/platformio/commands/remote/client/device_monitor.py", line 222, in acwrite_data
    self._acwrite_buffer += data
builtins.TypeError: can only concatenate str (not "bytes") to str

Exception in thread rx:
Traceback (most recent call last):
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/serial/urlhandler/protocol_socket.py", line 171, in read
    raise SerialException('socket disconnected')
serial.serialutil.SerialException: socket disconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner

--- exit ---
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/serial/tools/miniterm.py", line 499, in reader
    data = self.serial.read(self.serial.in_waiting or 1)
  File "/home/vscode/.platformio/penv/lib/python3.9/site-packages/serial/urlhandler/protocol_socket.py", line 178, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: socket disconnected

Expected Results

No crash, keypress sent to remote device.

Additional info

I've confirmed that remote upload does work, I am able to flash my remotely connected STM32 device using the same setup. This appears to be specific to the remote device monitor feature.

@coratron
Copy link

coratron commented Oct 22, 2021

I can confirm this issue - running "pio monitor" over an SSH on the agent machine (Ubuntu in my case) does take keystrokes.
Keystrokes cause the mentioned crash when using "pio remote monitor".

@coratron
Copy link

@ivankravets this I think happened because of 2.7 python to 3.x and how str and bytes are used + some confusion around the processing of the "data" argument.
I am no python expert but I got it working I think. I will submit a PR for your testing - the fix was quite straight forward but it needs to be tested by more people.

@ivankravets
Copy link
Member

Duplicate of #3832

@ivankravets ivankravets marked this as a duplicate of #3832 Oct 25, 2021
@ivankravets
Copy link
Member

Thanks for the report! Please re-test with pio upgrade --dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants