question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unmapping/remapping pins

See original GitHub issue

If I create an IO config for a pin with

config = DigitalInput.newConfigBuilder(rpi4j).provider("pigpio-digital-input").id("pin-"+pinNumber).address(pinNumber)....
pin = rpi4j.create(config);

the name “pinX” is registered in the Registry and the pin works accordingly.

If I then want to disconnect the pin I call pin.shutdown(rpi4j); which seems to forward the disconnect to pigpio but doesn’t unregister the IO in the Registry.

Any attempt to then create a new config with the same id creates an exception:

com.pi4j.io.exception.IOAlreadyExistsException: IO instance [pin14] already exists in the Pi4J runtime context; unable to create a new instance using this reserved id.
	at com.pi4j.provider.impl.ProviderProxyHandler.invoke(ProviderProxyHandler.java:99)
	at com.sun.proxy.$Proxy2.create(Unknown Source)
	at com.pi4j.context.Context.create(Context.java:309)
	at com.pi4j.internal.IOCreator.create(IOCreator.java:60)
	at com.pi4j.internal.IOCreator.create(IOCreator.java:101)
	at com.pi4j.internal.IOCreator.create(IOCreator.java:189)
        ...

The registry on the autoContext doesn’t seem to have a way to remove things from it (it is a DefaultRegistry not RuntimeRegistry)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
eitchcommented, Nov 17, 2022

I merged a PR, and i think it should be fine now since v2.2.0

0reactions
FDelportecommented, Nov 17, 2022

I see @eitch did a commit https://github.com/Pi4J/pi4j-v2/pull/198/files related to this topic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Betaflight Resource Remapping - Oscar Liang
Resource Remapping is an awesome feature in Betaflight, that allows you to swap some pins around on a flight controller.
Read more >
Remapping pins to add motors? - IntoFPV Forum
Hello, I have a Kakute F7 mini that has 6 motor inputs that i'm trying to add two more motors to for an...
Read more >
6.a. Remapping the Arduino Connections - Pololu
It is easy to cut the connections at these points and establish new connections to replace the broken ones if desired. The following...
Read more >
Correct procedure to remap I/O pins
When remapping peripherals to IO pins on the PIC (PIC24FJ256GA106), does one also need to assign the I/O direction of the pins?
Read more >
Remap Motors In Betaflight (damaged pins fix) - YouTube
Here I shot you how to determine which it is, and if it is a bad motor output pin then how to remap...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found