Python Script no working with get

7 thoughts on “Python Script no working with get

  1. Hi, I have a GM862-GPS Module and I’m trying to do GET Requests. Well, when I run a code from the hyperterminal, my code reachs the GET correctly and gives me the correct feedback (HTTP 200)







    GET HTTP /1.1




    But When I run the same code from the Python Script, It actually does not work



    import MDM
    import SER

    res = MDM.send(‘AT+CGDCONT=1,"IP",""r’,0)

    a = SER.send("register user")
    res = MDM.send(‘AT#USERID="tim"r’,0)
    res = MDM.receive(200)
    a = SER.send(res)

    a = SER.send("register passw")
    res = MDM.send(‘AT#PASSW="tim"r’,0)
    res = MDM.receive(200)
    a = SER.send(res)

    a = SER.send("register skt")
    res = MDM.send(‘AT#SKTSET=0,80,""r’,0)
    res = MDM.receive(200)
    a = SER.send(res)

    a = SER.send("opening skt")
    res = MDM.send(‘AT#SKTOPr’,0)
    res = MDM.receive(100)

    while (res.find(‘CONNECT’) == -1):
        res = MDM.receive(100)
        a = SER.send("finding connect")
    a = SER.send("found connect")
    res = MDM.send(‘GET HTTP /1.1rn’,0)
    res = MDM.send(‘rnrnrnrnrnrn’,0)



     All my feedback works correctly in the python script, but after sending a GET request, I don’t have an answer. 


    Andre Mariano


    1. Why so many rn? Two pairs are enough, and the GET should look like below:


      MDM.send(‘GET /posicoes.php?posicao=61&batidas=61 HTTP /1.1rnrn’,0)


      In initial setup set flow control to none: MDM.send("AT&K0r").

      Please post your communications log, including how and what you read after GET.


    The many rn is because the socket actually connects,


    "a = SER.send("opening skt")
    res = MDM.send(‘AT#SKTOPr’,0)
    res = MDM.receive(200)
    a = SER.send(res)"


    what shows in the hyperterminal…


    "opening skt



    but I don’t know why, apparently the GET request is not being sent – because I don’t receive any feedback as an 404 or 200 or anything and then the connection closes after a while -, even with the GET request that you showed.

    I’m thinking the problem is in the line feed ( "n").


    is there anyway to change the line feed caracter?


    If you have an working example code, can you provide me?


    1. Please follow the suggestions I wrote, AT&K0, a more complete HTTP request and only 2 pairs of final rn.

      The example is in  "Easy GPRS User Guide" document.

      1. You will never believe what was the problem in fact

        I forgot the " res = MDM.receive(100)"

        in the end of the code, looks like it actually really sends when I call the MDM.receive method


        I followed your suggestions too for an optimized code, but both codes worked 😀


        Thanks a lot, I was getting worried 😀

        1. This was indeed missed in the code you quoted here, but I thought it was only a copy-paste issue … at least you’ll have a serene weekend and Happy Easter Wink