Skip to content

Accessing compilation errors #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
royemmerich opened this issue Feb 13, 2014 · 13 comments
Closed

Accessing compilation errors #284

royemmerich opened this issue Feb 13, 2014 · 13 comments

Comments

@royemmerich
Copy link

So I am thrashing away trying to get MODBUS communication working...and it is not...yet :( I have one BIG script with all of the modbus_tk python library in it to compensate for the inability to import other python modules.

I also added some LED blinking to see if things are actually working. Initially they didn't blink so I commented out all the MODBUS related code (numerous classes, function definitions, etc.), re-uploaded the script and they started to blink again. Eventually through trial and error I figured out it was this piece of code which was causing things to break (specifically line 3):

1 _hooks = {}
2 def install_hook(name, fct):
3     _hooks[name].append(fct)

This got me thinking:

How is one supposed to know when there is a compilation error after uploading a script and what the error is?

P.S. Until importing is working and the python standard libraries are better represented it is looking more feasible to implement the MODBUS stuff in C and call it from python. I'll give that a bash over the next few days.

@JonHylands
Copy link

So, if you are using an actual pyboard (or a discovery board, or like me rolled your own) you will usually get a compile error show up on the USB console.

If you use my brother's usb-ser-mon, it automagically re-connects as soon as the console is available (after flashing), so you won't miss anything.

  • Jon

----- Original Message -----

How is one supposed to know when there is a compilation error after
uploading a script and what the error is?

@pfalcon
Copy link
Contributor

pfalcon commented Feb 14, 2014

for the inability to import other python modules.

There's no such known inability (with #282 applied which cover last "obscure" bit). If you have issues with imports, please submit a ticket with a testcase which shows the issue.

How is one supposed to know when there is a compilation error after uploading a script and what the error is?

Everyone would have different opinion for this one, so here's mine: you should do all porting, debugging, testing, etc. using "unix" port. For "unix" port, such questions don't hold - you get complete (with tracebacks) error reporting in split seconds. For hardware access, you should have appropriate mock/semihosting modules. Once you have testsuite which does ~100% code coverage, you move to device, where it will just work.

@dpgeorge
Copy link
Member

If there is an error that throws an exception, then it should print out on the USB console. You don't have to be connected to the console when the error happens, it should buffer the output and you will see it when you connect (eg picocom /dev/ttyACM0).

@royemmerich
Copy link
Author

I have tried both picocom and minicom and have yet to see any compilation error printed to the console. I prefer minicom as it doesn't drop the connection during a script upload and automatically reconnects after I hit the reset button on my STM32F407 discovery board.

Based on my little import test script in #304, I modified the print line to something I know creates an issue in python 3:

This works 👍

print(counter)

And this doesn't work 👎

print counter

However I don't see any compilation error in the second case.

@JonHylands
Copy link

Using my brother's usb-ser-mon, I get the following:

USB Serial device with vendor 'STMicroelectronics' serial '00000000050C' connected @/dev/ttyACM0
Use Control-C to exit.
File "0:/src/test.py", line 2 column 7
SyntaxError: invalid syntax
Micro Python build on 25/1/2014; PYBv4 with STM32F405RG
Type "help()" for more information.

My test.py program has the following line (after a blank line):

print "Hello"

This is running on my custom STM32F405 based MicroPython board.

What are you running on?

You can't use normal terminal emulators - they don't connect fast enough when the board is powered or reset.

Clone this repo: https://github.com/dhylands/usb-ser-mon

Read and follow the readme, and then see what happens.

  • Jon

----- Original Message -----

I have tried both picocom and minicom and have yet to see any compilation
error printed to the console.

Based on my little import test script in #304, I modified the print line
to something I know creates an issue in python 3:

This works 👍

print(counter)

And this doesn't work 👎

print counter

However I don't see any compilation error in the second case.


Reply to this email directly or view it on GitHub:
#284 (comment)

@JonHylands
Copy link

Yes, I'm aware of that. I was trying to force a syntax error, to show that the compile errors show up on the USB console, which is what the point of this issue is...

----- Original Message -----

This is Python 3, and print is a function - try:
print("hello")
instead.


Reply to this email directly or view it on GitHub:
#284 (comment)

@jugglerchris
Copy link

@JonHylands Yeah, sorry - I replied having seen the bug e-mail, without spending the time to read the rest of the bug. My bad - I deleted the comment immediately afterwards, but presumably notifications still went through.

@dhylands
Copy link
Contributor

I think that exceptions which occur as part of boot.py or main.py might not
be getting reported

Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
On Feb 17, 2014 9:37 AM, "Jon Hylands" notifications@github.com wrote:

Yes, I'm aware of that. I was trying to force a syntax error, to show that
the compile errors show up on the USB console, which is what the point of
this issue is...

----- Original Message -----

This is Python 3, and print is a function - try:
print("hello")
instead.


Reply to this email directly or view it on GitHub:

#284 (comment)

Reply to this email directly or view it on GitHubhttps://github.com//issues/284#issuecomment-35305989
.

@JonHylands
Copy link

On my board, I've got the following in my boot.py:

print("Executing uCee's boot.py")
pyb.source_dir("src")
pyb.main("test.py")

So test.py is the equivalent of main.py in this case...

  • Jon

----- Original Message -----

I think that exceptions which occur as part of boot.py or main.py might not
be getting reported

@pfalcon
Copy link
Contributor

pfalcon commented Feb 22, 2014

@royemmerich: Did suggestions provided help? Can we close this ticket?

@royemmerich
Copy link
Author

Did suggestions provided help?

Making use of @dhylands usb-ser-mon python serial app I can now see the compilation errors after copying my file to the /SRC directory and hitting the reset button on my STM32F4 discovery board.

However after @dpgeorge's comment:

You don't have to be connected to the console when the error happens, it should buffer the output and you will see it when you connect (eg picocom /dev/ttyACM0)

which doesn't seem to work, then I would consider usb-ser-mon a (rather good) workaround and this still an unfixed bug.

@dhylands
Copy link
Contributor

The USB serial console doesn't seem to buffer characters.

Using usb-ser-mon connected to a UART (and main.c modified appropriately),
I always see all of the startup messages on the HW UART. But only sometimes
do I see all of the messages from a hard RESET on the USB serial console.

I haven't yet established if the fault is in usb-ser-mon or in the
firmware. I should be able to tell by doing a wireshark capture.

Dave Hylands

On Sun, Feb 23, 2014 at 1:57 PM, Roy Emmerich notifications@github.comwrote:

Did suggestions provided help?

Making use of @dhylands https://github.com/dhylands usb-ser-monhttps://github.com/dhylands/usb-ser-monpython serial app I can now see the compilation errors after copying my
file to the /SRC directory and hitting the reset button on my STM32F4
discovery board.

However after @dpgeorge https://github.com/dpgeorge's comment:

You don't have to be connected to the console when the error happens, it
should buffer the output and you will see it when you connect (eg picocom
/dev/ttyACM0)

which doesn't seem to work, then I would consider usb-ser-mon a (rather
good) workaround and this still an unfixed bug.

Reply to this email directly or view it on GitHubhttps://github.com//issues/284#issuecomment-35845085
.

@pfalcon
Copy link
Contributor

pfalcon commented Apr 26, 2014

I assume this was resolved/clarified, and there were further changes to console code to make other concerns obsolete. If issues still hold, please reopen/resubmit.

@pfalcon pfalcon closed this as completed Apr 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants