Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Detect if I2C is enable and possibly enable it if user agrees #40

Open
DanielSSilva opened this issue May 9, 2018 · 4 comments
Open

Comments

@DanielSSilva
Copy link
Contributor

For what I've seen, enable the I2C "manually" seems quite easy, only requiring to edit:

  • the /etc/modules file to add i2c-dev
  • the /boot/config.txt file and uncomment the dtparam=i2c_arm=on entry.

If this is all that it takes, when the user imports this module, we can check if the i2c is already enabled and display a warning if it's not. Even better would be to prompt the user if he wants to enable it (avoiding the process of running sudo raspi-config and search for that).

Does this seems feasible/ make sense?

@anmenaga
Copy link
Contributor

anmenaga commented May 9, 2018

It would certainly be beneficial to have a PowerShell way of enabling I2C (and, as extension, other interfaces).
Though doing this during module import may not be the best place because user may be wanting to use interface other than I2C.
Currently with disabled I2C Get-I2CDevice will give Unable to open I2C device: No such file or directory error. At a minimum we need to improve this error message to something like "Unable to open I2C device; please enable I2C interface using ..."
Ideally, I think, we should implement 2 cmdlets like:
Enable/Disable-ArmInterface -I2C/-SPI/<others>
and maybe add a call to them when Get-I2CDevice gets above-mentioned error.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented May 9, 2018

We should also make sure these aren't pi specific (Or write them in an easy way to support other devices) since we do eventually want to support other devices.

@DanielSSilva
Copy link
Contributor Author

@anmenaga I understand your point, although the idea was not to "prevent" the user from using the module, but to warn/alert him that I2C (or other interface) was not enabled. Although this could become annoying if the user frequently import this module but don't care about this interface (maybe this is what you mean). Don't know if this could be solved with a flag on the Import-Module (don't know if it's even possible, but doesn't really makes sense). The call as you referred would make sense in that way.

@tylerl0706 I'm not familiar with the other devices, but isn't this something specific for each device? Seems like it's a configuration that can vary from device do device (worst case, from OS to OS)

@TylerLeonhardt
Copy link
Member

We can start with Pi specific commands :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants