Page 1 of 1

Revpi compact unreg method

Posted: 13 Jun 2024, 14:44
by franck_cern
Hello,
I've got a Revpi compact.
On my system, I've got to count some events on a digital input.
for that, I've used reg_event() method. After a count of 10, I want to unregister this event.

Here is the "reg_event" code:

def fan_event_start(self):
global fan_time
fan_time = time.time()
self.rpi.io.DInBit_1.reg_event(self.fan_event, edge=revpimodio2.RISING)
self.rpi.mainloop()
And the "unreg_event":

def fan_event_stop(self):
self.rpi.io.DInbit_1.unreg_event(self.fan_event)

But it raise me :
raise AttributeError("can not find io '{0}'".format(key))
AttributeError: can not find io 'DInbit_1'

I don't understand my error, could someone explain me ?
Thanks
Franck

Re: Revpi compact unreg method

Posted: 17 Jun 2024, 10:31
by dirk
Hi Frank and welcome to the Revolution Pi community,
probably the variable you want to access, "DInbit_1" is simply not declared.
Can you find it in PiCtory?
Did you save the PiCtory configuration as "Default" and reset the driver?

Have a look at that tutorial:
Revolution Pi Python Introduction
I find the ipython3 shell particularly helpful.

You can interactively see which objects are available in the namespace - a real game changer during development.