Search code examples
python-3.xautomated-testspyserialreadline

Python3.10.4 serial readline() not displaying prompts


Right now, I am connecting to a device using Tera Term and manually running over 50 tests. My goal is to automate these tests. Currently I am trying to do this through python using the pyserial library. The issue I am running into is readline() will display everything until the login prompt appears. It stops on the line before.

What it should look like

Booting: 2022.08
CPU:     cpu_id
In:      serial
OUT:     serial
Normal Boot
Hit any key to stop autoboot: 0

Starting Kernel ...

Enter your credentials
cpu_id login:

what readline() is displaying:

Booting: 2022.08
CPU:     cpu_id
In:      serial
OUT:     serial
Normal Boot
Hit any key to stop autoboot: 0

Starting Kernel ...

Enter your credentials

Here is the code I am currently playing with:

enter image description here

Any insight would help. Or, if you know of another way to run tests through a serial port, I'm all ears.Thanks!


Solution

  • Thanks to the comments of @ShadowRanger I was able find a work around. I ended the readline() loop the line before the login prompt. I then logged in and ran a test blind then started reading again afterwards. Here is the code I used:

    enter image description here

    This is not the cleanest code but it explains the process well enough.