0

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

And /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?

  • I expect it's more likely to be a "feature" of RPi.GPIO. Check at sourceforge.net/p/raspberry-gpio-python/tickets Have you tried any other GPIO modules to see if they have the same problem? – joan Jun 4 '17 at 10:55
  • I've been looking on these tickets but it seems that there's nothing about my issue. Anyway, thank you. And thank you Darth Vader for corrections, my english is not so good as I wish. – RikiRiocma Jun 5 '17 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.