I have these lines of code running in Python on my Pi 3:
os.system('mpg123 -q /usr/local/marbik/public/evilcave.mp3 &') GPIO.add_event_detect(17, GPIO.FALLING, callback=GPIO17Callback, bouncetime=50)
Everything is working: audio is played and callback is called as soon as the GPIO trigger the falling of the signal applied to the pin.
BUT if I invert the order of the lines above, audio is played and the callback doesn't work anymore.
GPIO.add_event_detect(17, GPIO.FALLING, callback=GPIO17Callback, bouncetime=50) os.system('mpg123 -q /usr/local/marbik/public/evilcave.mp3 &')
For your information,
uname -a gives:
Linux kk1 4.4.21-v7+ #911 SMP Thu Sep 15 14:22:38 BST 2016 armv7l GNU/Linux
/opt/vc/bin/vcgencmd version gives:
Copyright (c) 2012 Broadcom version 2eaf52cc53435b5ce67253af1487f9a4f9f96e2d (clean) (release)
I think this issue has something to do very deeply with interrupts e.t.c in the Broadcom CPU, (I read some interesting threads about callbacks missed).
Well I can leave the callback->play order in the code, but I dislike when something is weird in my projects. Maybe someone has already experienced this issue?