raspberry-sharp/raspberry-sharp-io

I2C ReadReg methods missing

donker opened this issue · 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

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; } }