Segmentation fault caused by events
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
Get Segmentation fault if GPIO.remove_event_detect and GPIO.add_event_detect directly after.
pinf = [7,28,30]
for x in pinf:
GPIO.setup(x, GPIO.IN, pull_up_down = GPIO.PUD_UP)
isSettingFreq = False
tmpFreq = float(ctrl.freq)
def setFreq(x):
global isSettingFreq
print "Setting"
if not isSettingFreq:
print "isf"
isSettingFreq = True #led blink?
GPIO.remove_event_detect(30)
GPIO.add_event_detect(28, GPIO.RISING, callback=lambda x: changeFreq("+", 0.1), bouncetime=200)
GPIO.add_event_detect(7, GPIO.RISING, callback=lambda x: changeFreq("-", 0.1), bouncetime=200)
GPIO.add_event_detect(30, GPIO.RISING, callback=finFreqSet, bouncetime=500)
print "waiting"
def changeFreq(addsub, val):
global tmpFreq
print addsub
if addsub == "+":
tmpFreq += val
elif addsub == "-":
tmpFreq -= val
def finFreqSet(x):
global isSettingFreq
if isSettingFreq:
isSettingFreq = False
ctrl.freq = tmpFreq
GPIO.remove_event_detect(30)
GPIO.remove_event_detect(28)
GPIO.remove_event_detect(7)
GPIO.add_event_detect(30, GPIO.RISING, callback=setFreq, bouncetime=500)
GPIO.add_event_detect(30, GPIO.RISING, callback=setFreq, bouncetime=500) #setFreq
the proof of concept WORKS, but if i remove event and add it again (pin 30) then i get this fault. i added a 5 sec sleep after removing and before adding, but this didnt work!
Version: 0.5.8-1
Same problem here. Is there any solution?
Same problem for me. Has anyone found a workaround (or even fix)?
Last edit: Janek Thomaschewski 2015-11-12
as posted here: Other Ticket
I found a workaround for the problem.