Jan sebastian
Jan sebastian

Reputation: 320

AttributeError: 'NoneType' object has no attribute 'send' pigpiod

So I create an another program that can run stepper motor clockwise and counter clockwise with a ramp up and ramp down in there and adding limiter switch on GPIO 16 and 26 to stop the pi.wave_send_using_mode(wid2, pigpio.WAVE_MODE_ONE_SHOT_SYNC) giving a chain wave, this is my code:

import time
import pigpio

START_DELAY=600
FINAL_DELAY=500
STEP=1

GPIO=20

pi = pigpio.pi()

pi.set_mode(GPIO, pigpio.OUTPUT)
pi.set_mode(21, pigpio.OUTPUT)
pi.set_mode(26,pigpio.INPUT)
pi.set_mode(16,pigpio.INPUT)
#pi.write(21,1)
pi.wave_clear()

statee = 0
try:
    while True:

        pi.write(21,statee)
        pi.wave_clear()

        wf=[]
        offset = pi.wave_get_micros()
        for delay in range(START_DELAY, FINAL_DELAY, -STEP):
           wf.append(pigpio.pulse(1<<GPIO, 0,       delay))
           wf.append(pigpio.pulse(0,       1<<GPIO, delay))

        for i in range(500):
            wf.append(pigpio.pulse(1<<GPIO, 0,       FINAL_DELAY))
            wf.append(pigpio.pulse(0,       1<<GPIO, FINAL_DELAY))
        wf.append(pigpio.pulse(0, 0, offset))

        for delay in range(FINAL_DELAY, START_DELAY, STEP):
           wf.append(pigpio.pulse(1<<GPIO, 0,       delay))
           wf.append(pigpio.pulse(0,       1<<GPIO, delay))

        pi.wave_add_generic(wf)

        wid2 = pi.wave_create()

        #pi.wave_send_once(wid2)
        pi.wave_send_using_mode(wid2, pigpio.WAVE_MODE_ONE_SHOT_SYNC)

        if pi.read(26) == 0:
            pi. wave_tx_stop()
            pi.stop()
        if pi.read(16) == 0:
            pi.wave_tx_stop()
            pi.stop()

        time.sleep(0.75)
        if statee == 0:
            statee = 1
        elif statee == 1:
            statee = 0
except KeyboardInterrupt:
    print ("\nCtrl-C pressed.  Stopping PIGPIO and exiting...")
    pi.wave_tx_stop()
    pi.stop()

the problem happen when the mottor run arround 5 - 10 minutes, I give an error message like this:

Traceback (most recent call last):


File "/home/pi/Desktop/ramp.py", line 49, in <module>
    if pi.read(16) == 0:
  File "/usr/local/lib/python3.4/dist-packages/pigpio.py", line 1401, in read
    return _u2i(_pigpio_command(self.sl, _PI_CMD_READ, gpio, 0))
  File "/usr/local/lib/python3.4/dist-packages/pigpio.py", line 989, in _pigpio_command
    sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
AttributeError: 'NoneType' object has no attribute 'send'

So, what the cause of error in my code? Is that cause by pi.read(26) and pi.read(16)? Is there any other ways to stop or terminate pi.wave_send_using_mode(wid2, pigpio.WAVE_MODE_ONE_SHOT_SYNC) at the middle of it process? thank you small note: I set pigpiod daemon start on boot by folow (https://raspberrypi.stackexchange.com/questions/70568/how-to-run-pigpiod-on-boot KimSJ answer), is the method of runimg pigpiod cause this error? thank you

update: after I clear pi.stop() on pi.read(26) and pi.read(26) and update pigpiod version to v68 everything run correcly without error

Upvotes: 0

Views: 1434

Answers (1)

Jan sebastian
Jan sebastian

Reputation: 320

after I clear pi.stop() on pi.read(26) and pi.read(26) and update pigpiod version to v68 everything run correcly without error

Upvotes: 1

Related Questions