Debug python code…

18 thoughts on “Debug python code…

  1. Hi.

    Today , I start write python code for my application . I do it long time ago but now don’t remember how  do it right.

    I install to my WinXP PythonWin and telitSerialPortMux

    I have EVKit2 with GE863-GPS.

    if pwer on gsm module and connect my hardware serial port to upper connector on EVKit

    then I can send and receive at command in all speed (9600 or 115200). and then run  telit com port selection tools and set so MDM is my COM1 and other (SER,MDM2,SER2) set no com port. then if run python win and write easy code :

    import MOD
    import MDM

    print ‘Test s AT commandr’

    res = MDM.send(‘ATr’,0)
    res = MDM.receive(50)

    print res

     

    then all. work.

    but Inned use MDM2

    really need to use serial port mux or what I need to correct debug code. 
    I read documentation but can do this work.

     can any write here step by step what to do ???

    regards 

  2. Yes you need serial port multiplexer or SSC to see debug messages.

    Try to work outside of PythonWin when debugging,with the script running live on module, will save you some time working in the native environment, for example timeouts are completely different.

     

    The debug procedure are clearly described in Easy Script in Python, please read it.

     

     

    1. I thinks so need set some at command first, … I follow step by step documentation but still in mux show connected and then error.

        1. Cosmin I have still problem.

          I do all what is on documentation and test it more.

          via rsterm upload any test script :

           

          import SER

          print ‘SER_send_rcv.pyrn© 2009 Telit Communicationsr’

          SER.set_speed(‘115200′,’8N1’)

          while (1 == 1):
          SER.send(‘Write text:rn’)
          MOD.sleep(10)

           

          only every one second send text. before compile. then execute this script and restart GSM but on serial port don’t receive any data .

          I don’t know why but don’t work.

          I define startmodescr , sstrace=0,cmuxscr=1,10… and all. try more upload files but still don’t work.
          you have any suggestion??? 

          I use real hardware serial port, and if don’t use MUX and pythonwin set debug COM1 then can debug but only MDM , but I need MDM2 too.

          if start mux then open any COM10 (like in documentation) then show connect and then error and again and again… .

          on GSM module is second serial port trace , can I use this port or not???? 

          1. Hi.

            Cosmin.

            On previous post I write small example how to send data from python script to  standard serial port . I try it but don’t work .

            Can you here or tome email write small example how to do it???

            I use EVKit2 and GSM module is GE863-GPS.

            then I want try it on GE865-quad.

            is it possible?

             

            thanks 

          2. hello.py:

             

            import MOD
            import SER

            while 1:
                print "Hello worldrnt"
                a = SER.send("Hello worldrn")
                print a
                a = SER.sendbyte(0x38)
                print a
                MOD.sleep(10)

             

  3. Hi Cosmin.

    today I try SPCM function.

    On my PC I create program (in Delphi) what can send file from HDD to serial port.

    On GE863-GPS set speed 115200. record any voice from microphone and save to my PC.

    then from my program send to GSM this :

    ATD0903xxxxxx; and hand up called phone , after this send to GSM 

    AT#SPCM=1,1 and then send my recorded file from PC to GSM (raw voice data) and  on other phone hear voice. 

    AT#SPCM function work good.

    then I copy my wav file to GSM module to internal flash to file zaznam.wav

    and in python want create small program to read data from this file and send to engine but if test it on debugger then still show error so file do not exist.

    f =open(‘zaznam.wav’,’r’)

    but file not found .

    what is problem ?. Can I debug this function or not??? or must compile and then copy to GSM module this script and then execute???
    how can I debug this function???

     

    thanks 

    PS: in list all file in gsm then there is my saved file zaznam.wav 

     

    PSS: use all in real time and work., now don’t debug code , run in real time

    regards 

  4. Hi all.

    I have question about receive data from SPCM.

    if want receive data from MDM.receive(timeout) then still receive data max size 511 bytes.

    and doesn’t matter what timeout define .

    is it correct or is some special setting. in documentation are write so max buffer size is 4096.

     

    regards. 

    1. Receive with timeout is for the cases one wants to have a read with a time interval to wait if data is still not present in the buffer, without bothering himself with a time counter. For a continuous stream as PCM is using the read version (MDM.read) is enough, keeping it in a loop until all data is received, or, say, nothing is returned for a certain time.

       

      1. Sorry I’m forget for this function MDM.read()

        I try this code :

         

        count = 5
        size = 0
        while(count>0):
                   bin = MDM.read()
                   size = size + len(bin)
                   count = count -1
        print ‘Size: ‘+str(size)

         

        and size received data are 2555 and if divide with 5 then result is 511, still 511.
        what is correct received data from this stream???

        where I do wrong??? 

        thanks .

         

        1. And what’s the problem with this? Don’t use that counter as an exit condition, but use one which counts the actual number of bytes received, with an exit condition on this and a timeout, in case of interrupted stream.

           

           

  5. Hi Cosmin.

    I try record audio to internal flash but if record then audio is bud , distorted .

    I set this path AT#SPCM=2,1 , audio from downlink , is my setting correct or must set different way ???
    I’m don’t know if good understand documentation about SPCM.

     

     

    PS: if record any voice in PC and try my self program (Delphi program for play wav file ) I set : AT#SPCM=1,1 and then send data from wav file and on other side I hear clear voice . 

    but if record data using my python script and download to PC and try play in program then voice is bud,distorted .
    is there any setting for audio path or somethink else???

     

    regards 

    1. Maybe the code hasn’t enough speed and losses samples. Try to copy back in PC and do a comparison with the original file.

  6. ehm… what original file????
    I just call to my personal cell phone and say any voice, and recorded file play gain in PC.

    I can’t compare recorded file .

    and speed???

    if python script is too slow then I have problem.

     

    I try somethink else . write function data to file is may be slow. try record data only to variable and then store to file.

     

    pls ask specialist in to Telit is is possible to record data to internal flash in python script

     

    regards 

     

    PS:  I try it and store to file data bigger then 12K bytes. and still hear big noise. 

    I need to know if is it possible to record stream from downlink to internal flash in real time.

     

    thanks