RPi::Pin objects -- looks like they can't be properly destroyed?
In this (perl) Test::More test fragment, I create a pin, use it (I watch the light blink), then destroy the pin object and try to create another. That fails as shown below.
subtest 'pin level reuse' => sub {
my $pinNumber = 4;
my $pin = $wpi->pin ($pinNumber);
$pin->mode (OUTPUT);
# Blink to show it's working
diag "Light will blink";
$pin->write(1); sleep (.2); $pin->write(0); sleep (.2);
$pin->write(1); sleep (.2); $pin->write(0);
pass ('link');
# Now, can I destroy the pin object?
$pin = 0;
pass ('delete pin');
# Now, new pin object?
$pin = $wpi->pin ($pinNumber);
$pin->mode (OUTPUT);
pass ('create new pin');
# Blink to show it's working
diag "Light will blink";
$pin->write(1); sleep (.2); $pin->write(0); sleep (.2);
$pin->write(1); sleep (.2); $pin->write(0);
pass ('link');
}; # subtest 'pin level reuse'
This fails:
# Subtest: pin level reuse
# Light will blink
ok 1 - link
ok 2 - delete pin
1..2
ok 6 - pin level reuse
not ok 7 # TODO & SKIP Reusing pins not working yet
# Looks like you planned 6 tests but ran 7.
sc@ordovik:~/repo $ t/Button-002-PI.t
2020/02/29 23:06:11 onPi 1
1..6
ok 1 - 'buttonInterruptQ' isa 'MCE::Shared::Object'
ok 2 - use RPi::WiringPi;
ok 3 - use RPi::Pin;
ok 4 - use Slideshow::Light;
ok 5 - use Slideshow::Button;
# Subtest: pin level reuse
# Light will blink
ok 1 - link
ok 2 - delete pin
cleaned up, exiting...
original error:
pin 4 is already in use... can't create second object
Is this just a limitation? Or there other API calls that I have to make that will eventually free up the pin? (They should be in the destructor for the RPi::Pin object surely, if so?)