When developing new micro python how do you debug it.
When a program crashes how do you find the line number and exception code?
How do i find out the line number of a bug
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: How do i find out the line number of a bug
There is no debugger.
If the program crashes (as in segfaults) then you remove code until it doesn't crash anymore, then add code one by one. And report a bug on github.com/micropython because it's not supposed to crash.
If the program terminates because of an unhandled exception, that gets printed e.g. on the command line including stack trace with files and line numbers.
If the program crashes (as in segfaults) then you remove code until it doesn't crash anymore, then add code one by one. And report a bug on github.com/micropython because it's not supposed to crash.
If the program terminates because of an unhandled exception, that gets printed e.g. on the command line including stack trace with files and line numbers.
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: How do i find out the line number of a bug
I'm getting nothing just a pyboard with no led on or flashing. Nothing is being passed back up the usb or at least linux handles it without printing the text in a terminal.
Re: How do i find out the line number of a bug
No experience with pyboard, did you look in the 'pyboard is dead' and other threads on the forum for hints?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How do i find out the line number of a bug
@rhubarbdog It would help if you could explain exactly what you are doing. You mention Linux: what program are you using to connect to the Pyboard and how are you invoking it? Are you seeing a REPL prompt? If so, does a one-line program work?
If you're not getting a REPL prompt have you checked your USB cable?
Code: Select all
>>> print('Hello')
Hello
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: How do i find out the line number of a bug
Doing some further searching accross the internet. I've found the following putting your main loop into a function called 'main' put you program into a file called 'something.py' (never main.py or boot.py).
From a repl prompt type the following [/code]import something
something.main() [/code]
From a repl prompt type the following [/code]import something
something.main() [/code]
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How do i find out the line number of a bug
That's correct. Once your program is debugged, if you want it to run automatically at power up, you make main.py read:
To go back to debugging the program you can simply replace main.py with a version with those lines deleted or commented out.
Code: Select all
import my_module
my_module.main()
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.