Embedded python: How to debug code in an isolated way

Grant Edwards grant.b.edwards at gmail.com
Sun Aug 23 21:41:55 EDT 2020


On 2020-08-23, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Aug 24, 2020 at 6:00 AM Grant Edwards <grant.b.edwards at gmail.com> wrote:
>>
>> 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...
>
> Haha, yep. That's also why the first "hello world" on any embedded
> system is also an important tool in itself - if you can make an LED
> flicker on and off in response to your code, then you have the most
> rudimentary of print functionality that you can use to debug
> everything else...

Yep, you can send morse code, or a simple "one flash when I get here",
"two flashes when I get here", etc.  Turn it on here off there, and
now you can profile performance.

--
Grant





More information about the Python-list mailing list