Comments (6)
I have run the board with ESP.debug set to True and have some debug logging showing how the ESP hangs. It has not been very insightful to me, but thought it may be helpful. This example ran for 2hr 30 minutes before freezing.
Here is the ESP writing and sending my POST request.
Writing: b'POST'
Writing: b' /'
Writing: b'Arrivals.aspx/getStopTimes'
Writing: b' HTTP/1.1\r\n'
Writing: b'Accept-Encoding'
Writing: b': '
Writing: b'gzip, deflate'
Writing: b'\r\n'
Writing: b'Content-Type'
Writing: b': '
Writing: b'application/json'
Writing: b'\r\n'
Writing: b'Host'
Writing: b': '
Writing: b'nextconnect.riderta.com'
Writing: b'\r\n'
Writing: b'User-Agent'
Writing: b': '
Writing: b'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
Writing: b'\r\n'
Writing: b'Referer'
Writing: b': '
Writing: b'http://nextconnect.riderta.com/LiveDepartureTimes'
Writing: b'\r\n'
Writing: b'Accept'
Writing: b': '
Writing: b'application/json'
Writing: b'\r\n'
Writing: b'Content-Type: application/json\r\n'
Writing: b'Content-Length: 89\r\n'
Writing: b'\r\n'
Writing: b'{"directionID": 5, "stopID": 12925, "tpID": 0, "useArrivalTimes": "false", "routeID": 60}'
Connection status: 3
Here is a successful read sequence after my POST request is written and sent as above.
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 1022 bytes available
Reading 1 bytes from ESP socket with status 4
ESPSocket: 1021 bytes available
Reading 32 bytes from ESP socket with status 4
ESPSocket: 989 bytes available
Reading 31 bytes from ESP socket with status 4
ESPSocket: 958 bytes available
Reading 20 bytes from ESP socket with status 4
ESPSocket: 938 bytes available
Reading 14 bytes from ESP socket with status 4
ESPSocket: 924 bytes available
Reading 32 bytes from ESP socket with status 4
ESPSocket: 892 bytes available
Reading 60 bytes from ESP socket with status 4
ESPSocket: 832 bytes available
Reading 12 bytes from ESP socket with status 4
ESPSocket: 820 bytes available
Reading 62 bytes from ESP socket with status 4
ESPSocket: 758 bytes available
Reading 52 bytes from ESP socket with status 4
ESPSocket: 706 bytes available
Reading 54 bytes from ESP socket with status 4
ESPSocket: 652 bytes available
Reading 50 bytes from ESP socket with status 4
ESPSocket: 602 bytes available
Reading 60 bytes from ESP socket with status 4
ESPSocket: 542 bytes available
Reading 45 bytes from ESP socket with status 4
ESPSocket: 497 bytes available
Reading 51 bytes from ESP socket with status 4
ESPSocket: 446 bytes available
Reading 52 bytes from ESP socket with status 4
ESPSocket: 394 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 330 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 266 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 202 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 138 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 74 bytes available
Reading 64 bytes from ESP socket with status 4
ESPSocket: 10 bytes available
Reading 10 bytes from ESP socket with status 4
Connection status: 3
Here is a failing read sequence, the last console messages before the whole board hangs and USB connection fails.
...
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 0 bytes available
ESPSocket: 1022 bytes available
Reading 1 bytes from ESP socket with status 4
ESPSocket: 1021 bytes available
Reading 32 bytes from ESP socket with status 4
ESPSocket: 989 bytes available
Reading 31 bytes from ESP socket with status 4
ESPSocket: 958 bytes available
Reading 20 bytes from ESP socket with status 4
As you see, the ESP stops responding (?) for some reason in the middle of unpacking the response from the POST request.
Hoping I can find a workaround or help find the bug. Thank you!
from adafruit_circuitpython_esp32spi.
Is there something that I might be doing wrong code-wise that is causing memory issues?
If so, is there a good way to debug to check it out?
from adafruit_circuitpython_esp32spi.
I am looking at related issues also, see for instance: adafruit/circuitpython#6205.
I ran a simple get via the requests library every second for several hours without problem.
If you have not already done so, try updating the ESP32 firmware to 1.7.4. What version are you currently running? It's reported in the "Internet Test" example given in the guide.
from adafruit_circuitpython_esp32spi.
If you have not already done so, try updating the ESP32 firmware to 1.7.4. What version are you currently running? It's reported in the "Internet Test" example given in the guide.
I updated several weeks ago to 1.74 firmware for ESP32. I will try running your simpler web fetcher and see what messages I get or if it hangs.
Thanks for taking a look. This definitely seems like the same issue so far.
from adafruit_circuitpython_esp32spi.
I adapted your code @dhalbert with tweaks of
- turning the GET into a POST request
- calls .json method and accesses a time dict key (which is printed on new line each iteration).
- changed it to 20 second interval to make sure I am not running into rate limit issues.
# code.py file
import board
import busio
from digitalio import DigitalInOut
import adafruit_requests as requests
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi
import time
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
requests.set_socket(socket, esp)
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])
print("Connecting to AP...")
while not esp.is_connected:
try:
esp.connect_AP(secrets["ssid"], secrets["password"])
except RuntimeError as e:
print("could not connect to AP, retrying: ", e)
continue
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
print("My IP address is", esp.pretty_ip(esp.ip_address))
URL = "http://nextconnect.riderta.com/Arrivals.aspx/getStopTimes"
hdrs = {'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate',
'Host': 'nextconnect.riderta.com',
'Referer': 'http://nextconnect.riderta.com/LiveDepartureTimes',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
}
params = {'routeID': 139, 'directionID': 3, 'stopID': 13363, 'tpID': 0, 'useArrivalTimes': 'false'}
secs = 0
while True:
print(secs, "Fetch start ", end = "")
r = requests.post(URL,json=params,headers=hdrs)
print("Fetch end")
print(r.json()['d']['updateTime'])
time.sleep(20)
secs += 1
It connects and starts off fine. After about 6 hours on the 1168th attempt it hung and USB unmounted. Last I saw on my serial console below.
....
1167 Fetch start Fetch end
6:28
1168 Fetch start
from adafruit_circuitpython_esp32spi.
I'm fairly certain now that ESP32SPI isn't the issue and the problem lies with the matrix module and object in adafruit_matrixportal.
Closing here and continuing troubleshooting in more related open issue adafruit/circuitpython#6205
from adafruit_circuitpython_esp32spi.
Related Issues (20)
- Errors and very slow when using a simple node.js server HOT 3
- TimeoutError: Timed out waiting for SPI char (Teensy 4.0 + Adafruit AirLift FeatherWing - ESP32 WiFi Co-Processor) HOT 10
- SPI lock not aquired
- Missing optional requirements
- 800 bps when serving webpage with WSGIServer HOT 2
- adafruit_esp32 TimeoutError HOT 1
- Feather M4 + AirLift feather wing connect to WIFI error HOT 3
- Unable to connect to WiFi with duplicate SSIDs HOT 1
- Fix double subtraction of bytes_read from num_to_read in recv_into HOT 1
- Fix WSGI headers parse and readline implementation
- socket.settimeout() Argument 0 value meaning differs from cpython
- wrong connection error messages from connect_AP method HOT 2
- Readme dependencies out of date HOT 2
- Debugging mode socket_status() call breaks UDP packet reading
- No context manager for socket HOT 1
- Is the `timeout` and `TimeoutError` intended to be different? HOT 2
- Remove allowing `dict` arg to `connect()` and other backward compatible
- Make sockets compatible with native `ssl` / CPython
- Socket and Timeout issues with requests - how to handle it? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_circuitpython_esp32spi.