lathoub / Arduino-AppleMIDI-Library

Send and receive MIDI messages over Ethernet (rtpMIDI or AppleMIDI)
Other
306 stars 66 forks source link

triggers watchdog #127

Closed folkertvanheusden closed 3 years ago

folkertvanheusden commented 3 years ago

Hi,

I believe it may need a few calls to yield() here and there. I took the basic ESP8266_NoteOnOffEverySec.ino, added mDNS and as soon as something connects to it, the watchdog gets triggered:

0x40203398: appleMidi::AppleMIDISession ::available() at /home/folkert/Projects/sketches/libraries/AppleMIDI/src/AppleMIDI.hpp line 30
0x402033f6: loop() at /home/folkert/Projects/sketches/libraries/MIDI_Library/src/MIDI.hpp line 712
0x401003ac: ets_post(uint8, ETSSignal, ETSParam) at /home/folkert/.arduino15/packages/esp8266/hardware/esp8266/3.0.1/cores/esp8266/core_esp8266_main.cpp line 181
0x40209ee4: loop_wrapper() at /home/folkert/.arduino15/packages/esp8266/hardware/esp8266/3.0.1/cores/esp8266/core_esp8266_main.cpp line 201

esp8266_test.zip

folkertvanheusden commented 3 years ago

Dug a bit into it and:

In src/AppleMIDI.hpp there's (line 27):

template <class UdpClass, class Settings, class Platform>
void AppleMIDISession<UdpClass, Settings, Platform>::parseControlPackets()
{
    while (controlBuffer.size() > 0)
    {
        auto retVal = _appleMIDIParser.parse(controlBuffer, amPortType::Control);
        if (retVal == parserReturn::UnexpectedData)

But 'parse' can also return parserReturn::NotSureGiveMeMoreData (and others) causing the loop to loop forever which then triggers the wdt. So I suggest parserReturn::Processed to be checked against there.

It doesn't explain why it fails to communicate with https://github.com/davidmoreno/rtpmidid though.

lathoub commented 3 years ago

additional test to avoid infinite loop (added in master branch, tested on ESP32)

https://github.com/lathoub/Arduino-AppleMIDI-Library/blob/17a1b7bc3223ad9edb2ea4c0f2edd2a3f2b7fe62/src/AppleMIDI.hpp#L32-L38

@folkertvanheusden does this resolve this issue?

lathoub commented 3 years ago

@folkertvanheusden thank you reporting and proactive digging into the issue

folkertvanheusden commented 3 years ago

The one from the branch I responded last on worked fine. Haven't tested the merged version yet.

On Sat, Aug 21, 2021 at 9:03 PM lathoub @.***> wrote:

additional test to avoid infinite loop (added in master branch, tested on ESP32)

https://github.com/lathoub/Arduino-AppleMIDI-Library/blob/17a1b7bc3223ad9edb2ea4c0f2edd2a3f2b7fe62/src/AppleMIDI.hpp#L32-L38

@folkertvanheusden https://github.com/folkertvanheusden does this resolve this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lathoub/Arduino-AppleMIDI-Library/issues/127#issuecomment-903161960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUN5IW6BIFCFXDJWFFV2BATT57Z6DANCNFSM5BOGLDCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

lathoub commented 3 years ago

The one from the branch I responded last on worked fine. Haven't tested the merged version yet.

That did not have the fix yet :-)

folkertvanheusden commented 3 years ago

The master? Or the branch? The branch works fine with long- and short names.

On Sat, Aug 21, 2021 at 9:09 PM lathoub @.***> wrote:

The one from the branch I responded last on worked fine. Haven't tested the merged version yet.

That did not have the fix yet :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

lathoub commented 3 years ago

Only 1 branch now: master Master now contains a fix for the above issue (session names already solved and folded in master earlier today)

lathoub commented 3 years ago

I did another fix: the session name of the data invitation was incorrect: it send back the remote session name, rather than the local name.

Maybe that addresses the below issue:

It doesn't explain why it fails to communicate with https://github.com/davidmoreno/rtpmidid though.