Spike Prime remote command using screen
With the prime hub you need to exit the hub default process before you can send commands using ctrl-c.
Ctrl-c is the character 0x03.
This is my python script that I use to send micropython scripts over to my hub:
https://github.com/gpdaniels/spike-prime/blob/master/simulator/run.py
It has lots of nastyness in it like this:
port.write(b'\x03')
time.sleep(0.1)
port.write(b'\x03')
time.sleep(1.0)

To try and get the hub to stop the running script and behave.
Also there's functions to read the serial input from the hub until it sees the &gt;&gt;&gt; characters which indicate the REPL is ready to receive python commands.