Embedded python: How to debug code in an isolated way

Schachner, Joseph Joseph.Schachner at Teledyne.com
Mon Aug 24 16:27:28 EDT 2020


Another suggestion:  If your Python code only references  few things outside of itself, make a simulated environment in Python on your PC, so that you can run your embedded code after importing your simulated environment, which should supply the functions it expects to call and variables it expects to access.

Then you can use any PC based debugger (PyScripter, Jetbrains' PyCharm, Visual Studio with Python support, etc) to debug in the simulated environment.

--- Joseph S.

-----Original Message-----
From: Grant Edwards <grant.b.edwards at gmail.com> 
Sent: Sunday, August 23, 2020 12:59 PM
To: python-list at python.org
Subject: Re: Embedded python: How to debug code in an isolated way

On 2020-08-22, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Aug 23, 2020 at 5:51 AM Eko palypse <ekopalypse at gmail.com> wrote:
>> So the question is, what do I need to read/learn/understand in order to solve this issue?
>> Or in other words, how can I debug my script in an isolated environment.
>
> I'd go for the old standby - IIDPIO: If In Doubt, Print It Out!
> Instead of trying to use a debug harness, just run your code normally, 
> and print out whatever you think might be of interest. If you don't 
> have a console, well, that would be the first thing to do - you
> *always* need a console.

Yep.  Even if you have to bit-bang a tx-only UART on a GPIO pin.

I've had to do that many times, and the last time was only a couple years ago.  Though I must admit I never had to do that _in_ Python or on a platform capable of running Python...

--
Grant






More information about the Python-list mailing list