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 monitor unable to use control characters #3832

Closed
chippey opened this issue Feb 3, 2021 · 4 comments
Closed

Remote monitor unable to use control characters #3832

chippey opened this issue Feb 3, 2021 · 4 comments
Assignees
Milestone

Comments

@chippey
Copy link

chippey commented Feb 3, 2021

When trying to use the remote monitor / miniterm, I'm unable to do things like hit Ctl + T to bring up the menu, or toggle various lines with Ctl + R or Ctl + D

Configuration

Operating system: Linux (Pop!_OS 20.04 LTS

PlatformIO Version (platformio --version): PlatformIO Core, version 5.1.0

Description of problem

Steps to Reproduce

  1. Install pio via Python on remote host and local
  2. Initiate pio monitor with : pio remote device monitor
  3. Hit Ctl + T, or any other Ctl combo other than Ctl + C

Actual Results

chippey@acornduex:~$ pio remote device monitor
Starting Serial Monitor on nvidia-nano:/dev/ttyACM0
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on socket://localhost:40225  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Unhandled Error
Traceback (most recent call last):
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/home/chippey/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/chippey/.local/lib/python3.7/site-packages/platformio/commands/remote/client/device_monitor.py", line 33, in dataReceived
    self.factory.send_to_server(data)
  File "/home/chippey/.local/lib/python3.7/site-packages/platformio/commands/remote/client/device_monitor.py", line 68, in send_to_server
    self.cdm.acwrite_data(data)
  File "/home/chippey/.local/lib/python3.7/site-packages/platformio/commands/remote/client/device_monitor.py", line 218, in acwrite_data
    self._acwrite_buffer += data
builtins.TypeError: can only concatenate str (not "bytes") to str


--- exit ---
Exception in thread rx:
Traceback (most recent call last):
  File "/home/chippey/.local/lib/python3.7/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.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/chippey/.local/lib/python3.7/site-packages/serial/tools/miniterm.py", line 499, in reader
    data = self.serial.read(self.serial.in_waiting or 1)
  File "/home/chippey/.local/lib/python3.7/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

Get the remote monitor menu, or other functions that are invoked with Ctl

@mulles
Copy link

mulles commented May 4, 2021

You might use the baud rate (speed) 115200 as suggest in https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-321/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fsoftware_features_jetson_nano.html%23wwpID0E0DB0HA

pio remote device monitor --baud 115200

Moreover I have a similar problem with the combo Raspberrypi3B+ and STM Nucleo-64 (USB to Serial):

~$ pio remote device monitor  --baud 115200 --echo
Starting Serial Monitor on raspberrypi:/dev/ttyACM0
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on socket://localhost:34709  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
# {"Uptime_s":203,"Bat_V":14.34,"Bat_A":0.29,"SOC_pct":100,"ChgState":0,"DCDCState":1,"Solar_V":20.03,"Solar_A":-0.95,"Load_A":1.04,"LoadInfo":1,"UsbInfo":1,"ErrorFlags":0,"DeepDisCount":3,"BatUsable_Ah":0.0,"SolarInDay_Wh":0.99,"LoadOutDay_Wh":0.83,"BatChgDay_Wh":0.20,"BatDisDay_Wh":0.04,"Dis_Ah":-0}

--- pySerial (3.5) - miniterm - help
---
--- Ctrl+C   Exit program (alias Ctrl+T Q)
--- Ctrl+T   Menu escape key, followed by:
--- Menu keys:
---    Ctrl+T  Send the menu character itself to remote
---    Ctrl+C  Send the exit character itself to remote
---    Ctrl+I  Show info
---    Ctrl+U  Upload file (prompt will be shown)
---    Ctrl+A  encoding
---    Ctrl+F  edit filters
--- Toggles:
---    Ctrl+R  RTS   Ctrl+D  DTR   Ctrl+B  BREAK
---    Ctrl+E  echo  Ctrl+L  EOL
---
--- Port settings (Ctrl+T followed by the following):
---    p          change port
---    7 8        set data bits
---    N E O S M  change parity (None, Even, Odd, Space, Mark)
---    1 2 3      set stop bits (1, 2, 1.5)
---    b          change baud rate
---    x X        disable/enable software flow control
---    r R        disable/enable hardware flow control

--- Settings: socket://localhost:40245  115200,8,N,1
--- RTS: active    DTR: active    BREAK: inactive
--- CTS: active    DSR: active    RI: inactive  CD: active  
--- software flow control: inactive
--- hardware flow control: inactive
--- serial input encoding: UTF-8
--- serial output encoding: UTF-8
--- EOL: CRLF
--- filters: default
Unhandled Error
Traceback (most recent call last):
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/home/mulles/.platformio/packages/contrib-pysite/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/mulles/.platformio/penv/lib/python3.8/site-packages/platformio/commands/remote/client/device_monitor.py", line 33, in dataReceived
    self.factory.send_to_server(data)
  File "/home/mulles/.platformio/penv/lib/python3.8/site-packages/platformio/commands/remote/client/device_monitor.py", line 68, in send_to_server
    self.cdm.acwrite_data(data)
  File "/home/mulles/.platformio/penv/lib/python3.8/site-packages/platformio/commands/remote/client/device_monitor.py", line 218, 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):

--- exit ---
  File "/home/mulles/.platformio/penv/lib/python3.8/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.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/mulles/.platformio/penv/lib/python3.8/site-packages/serial/tools/miniterm.py", line 499, in reader
    data = self.serial.read(self.serial.in_waiting or 1)
  File "/home/mulles/.platformio/penv/lib/python3.8/site-packages/serial/urlhandler/protocol_socket.py", line 178, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: socket disconnected

In my case: Ctrl + T followed by Ctrl + H works to get help. Ctrl + T followed by Ctl + I to get information. Ctrl + T followed by b to change the baud rate on the fly. Input of commands or other option result in the error shown above, which seems to be the same as @chippey gets.

When Nucleo64-board is connected directly to my laptop (PopOS 20.10) with pio device monitor --baud 115200 --echo everything works as expected. Echo is used so I see the commands I typing on the serial console:

:~$ pio device monitor  --baud 115200 --echo
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

--- Settings: /dev/ttyACM0  115200,8,N,1
--- RTS: active    DTR: active    BREAK: inactive
--- CTS: active    DSR: inactive  RI: inactive  CD: inactive
--- software flow control: inactive
--- hardware flow control: inactive
--- serial input encoding: UTF-8
--- serial output encoding: UTF-8
--- EOL: CRLF
--- filters: default

# {"Uptime_s":176,"Bat_V":14.45,"Bat_A":0.63,"SOC_pct":100,"ChgStat# {"Uptime_s":678,"Bat_V":14.36,"Bat_A":-0.12,"SOC_pct":100,"ChgState":0,"DCDCState":1,"Solar_V":20.04,"Solar_A":-0.66,"Load_A":1.04,"LoadInfo":1,"UsbInfo":1,"ErrorFlags":0,"DeepDisCount":3,"BatUsable_Ah":0.0,"SolarInDay_Wh":3.34,"LoadOutDay_Wh":2.81,"BatChgDay_Wh":0.68,"BatDisDay_Wh":0.14,"Dis_Ah":-0}

@mulles
Copy link

mulles commented May 5, 2021

@chippey A workarround would be to run ssh -t username@host pio device monitor -b 115200 in case you got ssh access to nvidia-nano, where -t stand for Terminal.
If you configure a SSH Reverse tunnel you would even be able to access the nvidia-nano outside of a router without NAT:
In that case the command would be: ssh -t -p <port> <pi@lsserver.uber.space> pio device monitor -b 115200, where port the reverse ssh port.

@ivankravets ivankravets added this to the 5.2.3 milestone Oct 25, 2021
@ivankravets ivankravets self-assigned this Oct 25, 2021
@ivankravets
Copy link
Member

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

@coratron
Copy link

I was following #4068 (duplicate)

pio upgrade --dev works for me

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

No branches or pull requests

4 participants