SwiftyGPIO icon indicating copy to clipboard operation
SwiftyGPIO copied to clipboard

Safer i2c

Open Uthedris opened this issue 4 years ago • 3 comments

What's in this pull request?

Update I2C functions that don't abort when communication errors occur.

Is there something you want to discuss?

I have been working on a project using the Qwiic cables to communicate with a slave device. The problem is that the current functions cause the master application to abort whenever the slave goes into debug.

I modified the various write functions to return a discardable Bool result, and added variants of the read functions that return optional results. I left the current read functions that return actual values intact, so as not to break anyones existing code.

Pull Request Checklist

  • [ x] I've added the default copyright header to every new file.
  • [ x] Every new file has been correctly indented, no tabs, 4 spaces (you can use swiftlint).
  • [ x] Verify that you only import what's necessary, this reduces compilation time.
  • [ x] Try to declare the type of every variable and constant, not using type inference greatly reduces compilation time.
  • [ x] Verify that your code compiles with the currently supported Swift version (currently 4.1.3)
  • [ x] You've read the contribution guidelines.

Uthedris avatar Nov 22 '21 05:11 Uthedris

I added the readRaw function to allow multi-byte reads without sending a register number

Uthedris avatar Dec 07 '21 17:12 Uthedris

I wish someone would get this fixed so it can be merged. It works fine on the official 64bit Raspberry OS.

ea7kir avatar Mar 01 '22 10:03 ea7kir

Please merge this necessary request. I've been using it for months without issue. The only problem I see is that here its called "Safer i2C" whereas curuva calls it "Safe-I2C". The failed details say "The log was not found. It may have been deleted based on retention settings". I think this means "don't worry about it".

ea7kir avatar Jun 02 '22 14:06 ea7kir