Menu

#85 Segmentation fault caused by events

New
None
Medium
Defect
2016-08-26
2014-11-21
BieHDC
No

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

Discussion

  • Ben Croston

    Ben Croston - 2014-12-12
    • assigned_to: Ben Croston
    • Priority: High --> Medium
     
  • Carmine Noviello

    Same problem here. Is there any solution?

     
  • Janek Thomaschewski

    Same problem for me. Has anyone found a workaround (or even fix)?

     

    Last edit: Janek Thomaschewski 2015-11-12
  • Momo

    Momo - 2016-08-26

    as posted here: Other Ticket
    I found a workaround for the problem.

     

Log in to post a comment.

MongoDB Logo MongoDB