             var packets = i2c_rdwr_ioctl_data(msgs: &messages, nmsgs: UInt32(messages.count))
             let status = ioctl(i2c, UInt(I2C_RDWR), &packets)
             guard status >= 0 else {
-                throw I2CError.readOrWriteError(status)
+                throw I2CError.readOrWriteError(status, errno)
             }
             
             if let buf = readBuf {

        public init(portNumber: UInt8) throws {
            let fd = open("/dev/i2c-\(portNumber)", O_RDWR)
            guard fd != -1 else {
                throw I2CError.deviceOpenError(portNumber, fd)
            }
            self.i2c = fd
        }

    public final class I2CBusDevice: I2CDevice {
        
        public enum I2CError: Error {
            case deviceOpenError(portNumber: UInt8, returns: Int32, errno: Int32)
            case slaveAddressSetError(Int32, Int32)
            case readOrWriteError(Int32, Int32)
            case noAckError(Int32, Int32)
        }
        
        private var currentAddress: UInt8 = 0
