You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pi...@googlegroups.com
I wondered from the very beginning why Pi4J requires root privileges for i2c when they are not actually required in common use cases. I found out that it is possible to work around and it is easy to do.
final MCP23017GpioProvider gpioProvider = new MCP23017GpioProvider( I2CBus.BUS_1, 0x21 ); GpioFactory.setDefaultProvider( gpioProvider );
So you just need to create the provider and call GpioFactory.setDefaultProvider before GpioFactory.getInstance.
But you still need to call the following commands before starting you Java application: sudo modprobe i2c-dev sudo chmod o+rw /dev/i2c* You can put them into /etc/rc.local so they will be executed on Raspberry Pi’s startup.
Explanation:
Basically you just should not call com.pi4j.wiringpi.Gpio.wiringPiSetup*. Method com.pi4j.wiringpi.Gpio.wiringPiSetup() is called from constructor of RaspiGpioProvider. This is the default provider and this constructor is called if it was not set explicitly by GpioFactory.setDefaultProvider.
Alex
Pi4J
unread,
Aug 24, 2013, 9:35:26 AM8/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pi...@googlegroups.com
Thank's for sharing that. If someone has asked that question, I'm not sure I would have readily identified such an easy workaround.