opened
whaleygeek
username_0
**Is your feature request related to a problem? Please describe.**
I want to write a scanner to identify which I2C addresses are available on the I2C bus, to confirm if my device is good.

**Describe the solution you'd like**
I want the last I2C error/ok result code stored in a last_i2c_result variable, so that each call to any I2C routine can then check if the transfer worked or failed

**Describe alternatives you've considered**
I hacked a version of the existing i2c_write routine to achieve this, code as below

```
function write(address: number, value: number, format: NumberFormat, repeated?: boolean): void {
    let buf = control.createBuffer(pins.sizeOf(format))
    buf.setNumber(format, 0, value)
    let res = pins.i2cWriteBuffer(address, buf, repeated)
    basic.showNumber(res)

}
basic.forever(function () {
    write(64, 0, NumberFormat.UInt8BE)
    basic.pause(250)
})
```

**Additional context**
The result code from i2c.read and i2c.write cpp routines is not returned in the .ts wrappers
I2C result code
issue