raspberry-sharp-io icon indicating copy to clipboard operation
raspberry-sharp-io copied to clipboard

I2C ReadReg methods missing

Open donker opened this issue 9 years ago • 1 comments

I'm trying to use this library for reading Temp and Pressure from a MPL115A2. But this relies on reading the values from specific addresses on the device. I have not found the methods in the I2C part for doing this. Only for writing and reading streaming bytes. Am I missing something or are these not implemented?

Thanks, Peter

donker avatar May 16 '16 13:05 donker

It's exactly how I2C work. You first need to write in to the address you need to read and then waiting for the response. Something like this: internal byte readRegisterByte(TKey register) { try { if (_deviceConnection != null) { _deviceConnection.Write(getConstantAsByte(register)); var value = _deviceConnection.ReadByte(); return value; } else return 0; } catch (Exception e) { CommonHelper.Logger.Error(e, "Error reading register {0}", getConstantAsByte(register)); return 0; } }

JTrotta avatar Aug 21 '16 13:08 JTrotta