Python debugging

13 thoughts on “Python debugging

  1. Hello


    Reading "Easy script in Python"  manual, rev 13, page 84/117, there is a reference to "Telit Python Package". What does it contain and where can I get it?


    Also, there is a reference to stdout and stderr but the whole manual does not contain any further explanation of these functions. Please, can you point me to some place to get information about how to use and benefit from these functions?


    BR, Tom 

  2. Telit Python Package contains Windows Python 1.5.2 + v4.1 and Telit specific extensions, see page 17 of the same doc.


    Python print statements are written to stdout and errors to stderr, which are both piped to the debug channel of the module, be it ASC1 or the virtual port provided by CMUX / TelitSerialPortMux. There is a trick to move stdout/stderr to ASC0 if needed and available, for a direct debug log on GPS enabled modules and/or without CMUX.

    1. Hi Cosmin


      OK, so I think I probably have the package  Python 1.5.2 + v4.1. But I cannot find anywhere a link to get it, or to check if I really have the latest version. My PythonWin says only (in Help->About): "win32all build 143". Can you confirm it is the latest version?


      Right, what is the trick, please? I do want to get  print statements on ASC0, but the before said manual talks only about debugging over SSC for GPS models, and CMUX based debugging.



      1. That is the version of PythonWin GUI, for Python’s one see in the lower console window or run python in command prompt:


        PythonWin 1.5.2+ (#0, Oct  1 2004, 15:39:52) [MSC 32 bit (Intel)] on win32.


        The trick is:


        import sys
        import SER

        class SERstdout:
            def __init__(self):
            def write(self,s):

        if(sys.platform != "win32"):       #
            sys.stdout = SERstdout()    # Redirect print statements to SERIAL ASC0
            sys.stderr = SERstdout()     # Redirect errors to SERIAL ASC0


        1. Hi Cosmin


          Two more questions concerning debugging, on the module itself (GE865, fw 10.00.003).


          Say, I use ASC1 normally for debugging. Default speed is 115.200 bit/s.That´s all OK.


          At startup, and right after the script has run, I get some odd printouts that I cannot find described anywhere. Or is there some documentation about these, some place?


          Anyway, If I am lucky, the script might run without runtime errors. If not, I get errors which are quite cryptic, again some descriptions would be welcome to have. Cannot find any.


          Also, if I embed print statements into my code, these will be printed out during script runtime. Fine, helps tracing the execution of the script.


          So question 1: any descriptions available about debugger printouts and runtime errors?


          Question 2: is there any use of the incoming data line (ASC1 receive data in my case), during the debug? Does the Python interpreter on the module use it in any way? Or can my script make use of it?


          Thanks for your help.



          1. Hi Tom,


            I think you are talking about messages sent out by the Python system, in this case you should search through general Python documentation; if you have problems interpreting something write here maybe we can help.


            For no 2, maybe some suggestions here will work. If not, moving input to ASC0 is the only way.

          2. Hi Cosmin


            Thanks for your warning, I did not even try any of those suggestions yet.


            But back to your "trick" of 30.03.2011 14:18, I just tried it by inserting the class def and the short three line piece of code at the beginning of my script, it did not work either.


            Can you please give me some more exact advice of using your "trick" so that I can redirect all execution-time printouts to ASC0?


            BR, Tom

          3. It must work straight out of the box, all prints and system messages are sent to ASC0. Check if you don’t have the port occupied with something else, CMUX for example.


          4. Cosmin,


            I tried with a very simple LED blinking script. Sending you separately my original four line script, and the other script with added lines as you suggested.


            Both work as such, i.e. do the LED blinking. But both print debug output on ASC1, not ASC0 as expected from the modified one. 


            It appears that the modified one does not say ‘import sys’ as I would expect.


            But please, can you try youreslf?


            Thanks for your help, 


          5. Tom, simply put some prints like below, your file with prints them on ASC0:


                s=GPIO.setIOdir(3,1,0) #LED off
                print "OFFrn"
                s=GPIO.setIOdir(3,1,1) #LED on
                print "ONrn"

            Initial system startup messages are still on ASC1, until redirection is put in place at script execution.


  3. Oh, yes Cosmin, you are right, as always Embarassed  It is obvious what you say, and now it also works for me, printing on ASC0 during script execution.


    But it then appears that I cannot completely get rid of hooking myself to ASC1 in addition to the usual AT interface at ASC0, during debug. The usual initialisation rubbish I am not interested in, but in case there is a real error in my script, can I somehow get the error indications redirected to ASC0 also? Some errors appear before script execution, and those will then inevitably output on ASC1, right?


    Thanks, Tom