     }
 
     private func setSlaveAddress(_ to: Int) {
+
+        if fd == -1 {
+            openI2C()
+        }
 
         guard currentSlave != to else {return}
 

    }

    private func smbus_ioctl(rw: UInt8, command: UInt8, size: Int32, data: UnsafeMutablePointer<UInt8>) -> Int32 {
        var args = i2c_smbus_ioctl_data(read_write: rw,
                                        command: command,
                                        size: size, 


    public init(i2cId: Int) {
        self.i2cId=i2cId
    }

    deinit {
        if fd != -1 {
            closeI2C()
        }
    }

    public func readByte(_ address: Int) -> UInt8 {
