Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pystack exhausted #3208

Closed
jerryneedell opened this issue Jul 26, 2020 · 1 comment · Fixed by #3213
Closed

pystack exhausted #3208

jerryneedell opened this issue Jul 26, 2020 · 1 comment · Fixed by #3213

Comments

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jul 26, 2020

I tried running the adafruit_io example adafruit_io_http/adafruit_io_simpletest.py under the current main for 6.0.0-alpha2 and it fails with this error
This runs normally with CP 5.3.1

Is this a CP issue or does something have to be changed in the adafruit_io libraries?

the esp32spi_simpletest works OK under CP 6.0.0-alpha2


Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 6.0.0-alpha.2-43-g7ab5c520e on 2020-07-26; Adafruit Metro M4 Airlift Lite with samd51j19
>>> import temp_hum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "temp_hum.py", line 63, in <module>
  File "temp_hum.py", line 60, in <module>
  File "adafruit_io/adafruit_io.py", line 635, in get_feed
  File "adafruit_io/adafruit_io.py", line 532, in _get
  File "adafruit_esp32spi/adafruit_esp32spi_wifimanager.py", line 202, in get
  File "adafruit_requests.py", line 291, in get
  File "adafruit_requests.py", line 251, in request
  File "adafruit_requests.py", line 192, in request
  File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 75, in connect
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 752, in socket_connect
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 651, in socket_open
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 324, in _send_command_get_response
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 232, in _send_command
RuntimeError: pystack exhausted
>>> 

for reference code is here

"""
Example of sending temperature
values to an Adafruit IO feed.

"""
import time
import board
import busio
from digitalio import DigitalInOut

# ESP32 SPI
from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager

# Import NeoPixel Library
import neopixel

# Import Adafruit IO HTTP Client
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError

# Import aht7410 Library
import adafruit_ahtx0

# Get wifi details and more from a secrets.py file
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

# ESP32 Setup
try:
    esp32_cs = DigitalInOut(board.ESP_CS)
    esp32_ready = DigitalInOut(board.ESP_BUSY)
    esp32_reset = DigitalInOut(board.ESP_RESET)
except AttributeError:
    esp32_cs = DigitalInOut(board.D9)
    esp32_ready = DigitalInOut(board.D10)
    esp32_reset = DigitalInOut(board.D5)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
status_light = neopixel.NeoPixel(
    board.NEOPIXEL, 1, brightness=0.2
)  # Uncomment for Most Boards
"""Uncomment below for ItsyBitsy M4"""
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)

# Set your Adafruit IO Username and Key in secrets.py
# (visit io.adafruit.com if you need to create an account,
# or if you need your Adafruit IO key.)
aio_username = secrets["aio_username"]
aio_key = secrets["aio_key"]

# Create an instance of the Adafruit IO HTTP client
io = IO_HTTP(aio_username, aio_key, wifi)

try:
    # Get the 'temperature' feed from Adafruit IO
    temperature_feed = io.get_feed("aht20-temperature")
except AdafruitIO_RequestError:
    # If no 'temperature' feed exists, create one
    temperature_feed = io.create_new_feed("aht20-temperature")

# Set up ahtx0 sensor
aht = adafruit_ahtx0.AHTx0(board.I2C())

while True:
    try:
        temperature = aht.temperature * 9.0/5.0 + 32.0
        # set temperature value to two precision points
        temperature = "%0.2f" % (temperature)

        print("Current Temperature: {0}*C".format(temperature))
        print("Sending to Adafruit IO...")
        io.send_data(temperature_feed["key"], temperature)
        print("Data sent!")
    except (ValueError, RuntimeError) as e:
        print("Failed to get data, retrying\n", e)
        wifi.reset()
        continue
    time.sleep(0.5)

@jerryneedell
Copy link
Collaborator Author

If I double the size of the pystack it works

diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index a1a7ec238..768e05af1 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -799,7 +799,7 @@ void supervisor_run_background_tasks_if_tick(void);
 #endif
 
 #ifndef CIRCUITPY_PYSTACK_SIZE
-#define CIRCUITPY_PYSTACK_SIZE 1024
+#define CIRCUITPY_PYSTACK_SIZE 2048
 #endif
 
 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant