Wiznet / RP2040-HAT-MicroPython

54 stars 22 forks source link

BadStatusLine Error #19

Open GM-Script-Writer-62850 opened 1 year ago

GM-Script-Writer-62850 commented 1 year ago

Board: W5500-EVB-PICO FW: v2.0.0 firmware.uf2

Several times during testing while using the urequests library i get a BadStatusLine Error in Thonny, the line below this error message is [] after checking my server log files a 200 status code was sent

try:
    if not data:
        r=urequest.get(page)
    else:
        r=urequest.post(page,data=json_encode(data),headers={"Content-type":"application/json"})
except BadStatusLine:
    #No idea why this happens, line is returned as []
    #My server log files disagree
    print("ERROR: BadStatusLine; Ignore")
except Exception as e:
    print("ERROR:",e)

in my use case i have a input polling loop running on core 0 and uasyicio running on core 1 via _thread, urequests is called from core 1

GM-Script-Writer-62850 commented 1 year ago

managed to log a error

urequest ERROR: HTTP error: BadStatusLine:
[]
Wiz CREG:
  0000: 00 0a 00 00 01 ff ff ff 00 02 a4 8f 74 61 9a 0a
  0010: 00 00 af 00 00 00 00 02 00 07 d0 08 28 00 00 00
  0020: 00 00 00 00 00 00 ff ff 00 00 00 00 00 00 bf 00
  0030: 00 00 00 00 00 00 00 78 25 04 00 00 00 00 00 00
  0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Wiz SREG[0]:
  0000: 01 00 00 00 c0 01 00 d8 61 55 c0 93 0a 00 00 45
  0010: 1f 90 05 b4 00 00 80 00 00 00 00 00 00 00 02 02
  0020: 08 00 fd e9 fd e9 01 b7 00 00 01 b7 ff 40 00 00
Wiz SREG[1]:
  0000: 02 00 04 22 00 44 ff ff ff ff ff ff 0a 00 00 af
  0010: 13 88 05 c0 00 00 80 00 00 00 00 00 00 00 02 02
  0020: 08 00 04 59 04 59 00 00 02 68 02 68 ff 40 00 00
Wiz SREG[2]:
  0000: 00 00 00 00 00 00 ff ff ff ff ff ff 00 00 00 00
  0010: 00 00 00 00 00 00 80 00 00 00 00 00 00 00 02 02
  0020: 08 00 00 00 00 00 00 00 00 00 00 00 ff 40 00 00
Wiz SREG[3]:
  0000: 00 00 00 00 00 00 ff ff ff ff ff ff 00 00 00 00
  0010: 00 00 00 00 00 00 80 00 00 00 00 00 00 00 02 02
  0020: 08 00 00 00 00 00 00 00 00 00 00 00 ff 40 00 00
None
def http(page,data=False,err=False):
    if not err:
        page="http://10.0.0.69:8080/"+page
    if not GPIO.nic.isconnected():
        print("----------NO NETWORK----------")
        return False
    try:
        if not data:
            r=urequest.get(page)
        else:
            r=urequest.post(page,data=json_encode(data),headers={"Content-type":"application/json"})
    except Exception as e:
        print("urequest ERROR:",e)
        print(GPIO.nic.regs())
        return False
    if r.status_code == 200 and r.content == b"OK":
        r.close()
        r=True
    else:
        r.close()
        r=False
    return r

If it matters http was called from core 1