Closed Pax-nl closed 7 months ago
The Apple protocol is quite different from the supported ones and I'm not surprised that the test scripts fail. I don't plan to try to fix this as it's usage outside of the intended scope of these scripts.
Hi,
thank you for the reply, but the device rebooting/crashing with unchanged files and trying to test other remotes is not related to my endeavour for getting the Apple Remote working.
The same code on an Wemos S2 mini is working, it seems it's only on the C3. If I'm the only one with this issue on an C3 then ignore my issue but if other C3 owners have the same, closing this issue is incorrect?
Ah, sorry I misunderstood: I assumed it was the Apple sequence which was crashing it.
Unfortunately I don't have a C3 to test. This may be a firmware issue given that the C3 is rather new with a different CPU to other Espressif products. I suggest we see how others get on with these chips.
Did some more testing on 2 different C3 boards:
Working:
LOLIN_C3_MINI-20220618-v1.19.1.bin
LOLIN_C3_MINI-20230426-v1.20.0.bin
Not working:
LOLIN_C3_MINI-20231005-v1.21.0.bin
LOLIN_C3_MINI-20231227-v1.22.0.bin
So it seems it starts with 1.21 and is still happening in 1.22
on 1.19.1 and 1.20.0 the library is not working, but tests are not rebooting the device(s)
Traceback (most recent call last):
File "ir_rx/__init__.py", line 54, in _cb_pin
OSError: (-258, 'ESP_ERR_INVALID_ARG')
This is the error I get when trying any of the tests. This is an error with test(1) and play on the remote.
This is almost certainly a firmware issue. A pin interrupt handler is initialising a timer and that call is failing. If I had an ESP32-C3 I would attempt to write a minimal repro and (assuming the error was reproducible) raise an issue.
I'm not sure how to proceed. I could suggest a script to try, if you want to pursue this.
I'm happy to help with debugging. I have 2 LOLIN ESP32-C3 boards a v1.0.0 and a v2.1.0
MicroPython v1.22.0 on 2023-12-27;
Tried this code and it reboot's the device:
from machine import Timer
def mycallback(t):
pass
tim = Timer(-1)
tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback)
the minus one comes from __init__.py
line 48
self.tim = Timer(-1) # Sofware timer
When I set this to a positive value the device does not reboot.
OK. I'll write a script that tests the relevant bit of code, test it on an ESP32, and post it for you to adapt and try. I'll use PWM to toggle a pin so we can run a pin ISR which triggers a timer.
Updated __init__.py
line 48 to:
self.tim = Timer(0) # Sofware timer
Which looks like it does not break the library code and fix the issue on the C3.
Nice work. I used software timers in the module as I thought these were more portable. Your adaptation uses a hardware timer, which is fine. What troubles me is that the firmware allowed a software timer to be instantiated, with the thing failing on use.
Please could you try this script, which should enable us to raise an issue:
from machine import Timer
import time
tim = Timer(-1)
for _ in range(10):
print("Trigger")
tim.init(period=500, mode=Timer.ONE_SHOT, callback=lambda _: print("Timer"))
time.sleep(1)
I ran your code:
>>> from machine import Timer
>>> import time
>>> tim = Timer(-1)
>>> for _ in range(10):
... print("Trigger")
... tim.init(period=500, mode=Timer.ONE_SHOT, callback=lambda _: print("Timer"))
... time.sleep(1)
...
Trigger
Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.
I found a previous issue (Oct 2022) and added a comment. We'll see if there's a response.
The above script works on ESP32 and ESP32-S3. If soft timers are not supported, the firmware should throw an exception on line 3 (which could be trapped). Crashing is not good.
I've pushed an update which allows the timer ID to be overridden via a class variable. This should provide ESP32C3 users with a workround. See the docs for an explanation of why a software timer is the default.
Thank you for your work in diagnosing this. I have credited you in the code and docs.
Hi,
I'm trying to get an old Apple Remote A1156 to work with my ESP32-C3.
I'm working with a Lolin Wemos ESP32-C3: https://www.wemos.cc/en/latest/c3/index.html Micropython: MicroPython v1.22.0 on 2023-12-27; LOLIN_C3_MINI with ESP32-C3FH4
I tried:
from ir_rx.test import test
And test() or test(1) result in crash and reboot.I finally tried:
from ir_rx.acquire import test
which gave me this output:
I see in the test.py code the gc.collect() is used, I also tried to gc.collect before the acquire.py code and disabled debug mode with osdebug(None) but did not help..
I can read the raw data and used the same esp for other projects. not sure what to do.
(found an wemos s2 mini and this device does not reset) info on the Apple Remote NEC protocol: https://en.wikipedia.org/wiki/Apple_Remote