Plasma icon indicating copy to clipboard operation
Plasma copied to clipboard

Add remote python console based on named pipes

Open roblabla opened this issue 2 years ago • 0 comments

This allows easily debugging python by connecting with PuTTY to a named pipe.

How to use:

  • Start Uru, wait for intro movie to finish
  • Start PuTTY, and try to connect to the following Serial port: \\.\pipe\URU-PYTHON-<PID> (For instance, if URU is running with pid 5151, connect to \\.\pipe\URU-PYTHON-5151). image
  • Upon connecting, you will be prompted with a python prompt. You can type python in there!

How it works:

The pfRemoteConsole class is responsible for setting everything up. It essentially creates a thread that handles the named pipe (connecting it, reading from it to get a script to run, and writing the output of the script back). When it gets a python script to run, it sends a message back to the main thread by dispatching a pfRemoteConsoleMsg. The pfRemoteConsole::MsgReceive will then take care of executing this message, and signaling the thread back when the output is acquired. This ensures that the python logic executes on the main thread, which should avoid data races.

Note that I'm not 100% sure this design is sound. Mainly, is it OK to call plMessage::Send from a new thread?

TODO:

  • [ ] Properly handle backspace and left/right arrow keys to edit lines
  • [ ] Handle line history with the up/down arrows
  • [ ] Clean up unhandled control characters so they don't end up in the python script.

roblabla avatar Nov 01 '21 01:11 roblabla