不明白为什么raspberry上的join()函数会导致这种类型

2024-06-30 14:56:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建由树莓皮和电磁锁锁锁建设脚本。 我有一些单独运行的函数。我加入了他们,但有一个错误:

Process Process-4:
Traceback (most recent call last):   File
"/usr/lib/python3.5/multiprocessing/process.py", line 249, in
_bootstrap
    self.run()   File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)   File "/home/pi/Desktop/skuska.py", line 175, in motion
    edge_detect = GPIO.wait_for_edge(motion, GPIO.FALLING, timeout = 10000) 
      TypeError: an integer is required (got type function)
def morning():
    now = datetime.datetime.now()
    DayL = ['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun']
    date = DayL[datetime.date(now.year,now.month,now.day).weekday()] + 'day'
    if date != "Satur" or "Sun":
        if GPIO.input(alarm_check):
            GPIO controll
        else:
            print("")
        GPIO controll

    else:
        pass


def evening():
    if GPIO.input(alarm_check) == 0:
        GPIO controll

    GPIO controll


def automatic():
    while True:
        named_tuple = time.localtime()
        time_string = time.strftime("%H:%M", named_tuple)
        sleep(45)
        if time_string == "06:45":
            morning()
            sleep(60*60*10)

        elif time_string =="18:00":
            evening()
            sleep(60*60*10)


def rfid_button_open():
    while True:

        edge_detect = GPIO.wait_for_edge(rfid_input, GPIO.RISING, timeout = 10000)

        if edge_detect:
            GPIO controll


def button_closing():
    while True:
        edge_detect = GPIO.wait_for_edge(button_close, GPIO.RISING, timeout = 10000)

        if edge_detect:
            pulse_start = time.time()

        else: return 0

        edge_detect = GPIO.wait_for_edge(button_close, GPIO.FALLING, timeout = 10000)
        if edge_detect is not None:
            pulse_end = time.time()

        else: return 0

        pulse_duration = pulse_end - pulse_start
        if pulse_duration < 0.07:
            print("zakmit")
        elif pulse_duration > 3:
            GPIO controll
            sleep(cas_odchodu)
            evening()


        else:
            print ("Short Press")
            GPIO controll

        sleep(0.5)


def motion_continue():
    i = 1
    while True:

        if GPIO.input(motion) == 1:
            motion()

        else:
            sleep(3)
            cas = cas_cakania_motion*60/3
            if i == cas:
                GPIO.output(branka, GPIO.HIGH)
                motion()
        i += 1


def motion():
    while GPIO.input(branka) == 0:

        edge_detect = GPIO.wait_for_edge(motion, GPIO.FALLING, timeout = 10000)
        if edge_detect:
            motion_continue()

def net():
    a lot of code for connecton to web controlling



now = datetime.datetime.now()
DayL = ['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun']
date = DayL[datetime.date(now.year,now.month,now.day).weekday()] + 'day'
if date != "Satur" or "Sun":

    named_tuple = time.localtime() # get struct_time
    time_string = time.strftime("%H:%M", named_tuple)
    if time_string > "6:40" and time_string < "18:05":
        morning()
    else:
        evening()
else:
    print("je vikend")

try:
  p1 = Process(target=automatic)
  p1.start()
  p2 = Process(target=rfid_button_open)
  p2.start()
  p3 = Process(target=button_closing)
  p3.start()
  p4 = Process(target=motion)
  p4.start()
  p5 = Process(target=net)
  p5.start()

except:
   print ("Error: unable to start process")

p1.join()
p2.join()
p3.join()
p4.join()
p5.join()

Tags: targetforgpioiftimedefprocessstart