adafruit / Adafruit_CircuitPython_MagTag

Helper library for the Adafruit MagTag
MIT License
28 stars 24 forks source link

Peripherals.py line 46 TypeError #65

Closed PaulskPt closed 3 years ago

PaulskPt commented 3 years ago

Suddenly getting TypeError in Peripherals.py, line 46: 'function missing required positional argument #3' called from a standard example script. Code_py

2021-07-30_adafruit_magtag_peripherals py_error neopixel py_init

FoamyGuy commented 3 years ago

I tried to replicate this issue but was unable to. I tested the latest versions of all used libraries from the bundle, and I tried CircuitPython 6.1. 0, 6.2.0, 6.3.0, and 7.0.0 alpha5. All seemed to run the simpletest script successfully for me.

@PaulskPt can you post what version of CircuitPython is on your MagTag? You can find it by checking inside of the boot_out.txt file. You can paste the entire contents of that file in a comment here.

Aside from letting us know what version of CircuitPython have my other recomendation is to update all of your libraries, especially adafruit_magtag and neopixel (but doing all libraries can be helpful) you can delete the files from these from your lib folder and then paste in new ones from a fresh copy of the bundle downloaded from here: https://circuitpython.org/libraries

One other question as well, did you modify the neopixel library file? I noticed in your screenshot that the parameters inside of the __init__() function are commented out and there is an extra line next to the commented one that is missing the * parameter. Looking at the current version of the neopixel library code on Github it seems that the line commented out in your screenshot is the one that is present in the released version of the library. If you edited that, I would recommend putting it back to how it was (or deleting your copy and getting a fresh one from the bundle as noted above).

PaulskPt commented 3 years ago

@FoamyGuy. Thank you very much for your extensive investigation. To answer one of your questions: below a screenshot of the contents of boot_out.txt.

Earlier in the day I had a problem with a code.py that caused the MAGTAG to reset constantly, making it unable to connect with whatever device and/or app. I learned from @danh how to wipe out the entire flash memory using esptool from cli (I did this in a Ubuntu Linux session) (later on I discovered that I also could do this successfully using the Adafruit webbased Esptool. So I cleaned the flash. Then I flashed combined.bin (of Tinyuf2 (?)), then I flashed CP. Next I copied all the necessary libraries and files I wanted to be in the CIRCUITPY drive. All files from the latest edition of CP (see screenshot above in the issue opening text).

Regarding your last question. You did see very well (very attentive!) that - in an attempt to find a clue/solution to the reported error, I modified the '*' (3rd param) in the neopixel init() call) - this didn't work out so I 'repaired' my mod, and then I used the .mpy version (as I did from the start - if I can I use .mpy files only), so the modded file was not used. I put it with some other .py versions in a separated folder within the /lib folder. I copied those .py versions only for reason of the investigation.

Btw. the earlier problem of the MAGTAG resetting every second or so caused problems in my MS Windows 10 desktop, in fact the File Explorer became damaged and behaving strange. Fortunately I was able to tackle that side-problem.

About noon yesterday (Z+1) I soldered a 2-pin strip onto the TX and RX holes on the back of the MAGTAG aside of the ESP32-S2 chip. See the images. After this I successfully monitored the output of the ESP32-S2 with KiTTY. I did the soldering with a light solder iron and carefully, using a magnifying loupe to see my actions more clearly. See the three images at the end.

Yesterday evening, Initially I posted my question in Discord but then I saw that there was a recent commit of the Peripheral.py file, I deleted the (2) posts. Then I created this issue here in GitHub.

Thank you again for trying to help me to solve this. I will now (again) go to download a fresh copy of all the files in question.´

CP_fw_for_MAGTAG_v_7 0 0-alpha 5_

boot_out txt_

IMG_2258 IMG_2255 2021-07-29_12h10_MAGTAG_Debug_output_via_ESP32-S2_RxTx

PaulskPt commented 3 years ago

I think the problem is solved. After downloading, extracting and copying all the libraries and individual .mpy files, suddenly appeared a white screen with "Hello World" centered (see image). I copied one after one - I didn't see/check at each move the result - I copied the fonts lib as last. I think (but have no prove) that the problem was the folder with adafruit_bitmap_fonts. I also deleted some .py files I had there for a Google OAuth2 test.

2021-07-30_11h29_lib_contents_b4_renewing magtag_lib_after_cpy_to_magtag_cp_drive IMG_2260

To finish I have one more question: How can I 'catch' events of constant resets to not loosing control. Yes, the obvious answer would be: write an error-free script! I have a habit to build-in try - except blocks at crucial locations in the scripts. I have quite some years of experience with python. I built scripts for receiving/decoding/presenting gps messages broadcasted by an addon for various flightsimulators, most recent: MSFS2020, and displaying the results on a 4x20 LCD (I2C) . I program since I had my 1st Apple ][ in 1978. But I am relatively new to uPython and CircuitPython. B4 I received my 1st RPi Pico I experimented a year with an ESP32-S2 Saloa-1R and an ESP32-S2 Kaluga-1 building apps using ESP-IDF toolchain.

PaulskPt commented 3 years ago

Afterburner: I just discovered/remembered that, yesterday, I copied adafruit-circuitpython-bundle-7.x-mpy-20210729 's neopixel.mpy from the /lib/seesaw folder instead from the /lib folder. Maybe that caused the error. Time to close this issue which happened not to be an 'issue'.

FoamyGuy commented 3 years ago

Ah! yes I have just confirmed on my device that using the neopixel.mpy file from inside of the adaruit_seesaw library instead of the "standard" neopixel library file does cause the error that you saw.

With regards to the restarts and reconnecting to the host PC I am probably not the most well suited to answer that. I don't recall ever encountering an issue like that before and my host OS is Linux based so it may react or behave differently than windows would in a situation like that.

You can use try/except in your code though to catch errors instead of crashing your code i.e:

try:
    # some code
    # here that might cause
    # a crash
except:
    print("The code caused an Error")

If you know the specific exception types that might be raised you can also specify those in the except line and handle different types of errors in different ways by including multiple except lines, one for each type of error that can be raised.

makermelissa commented 3 years ago

Glad you were able to figure it out and thank you @FoamyGuy for helping.