pub fn fault_status(&mut self) -> Result<(), DI::Error>{
        let mut buffer = [0u8; 2]; // One byte value from Fault status register
        buffer[0] = Registers::SR.read_address;
        self.iface.read(&mut buffer)?;
        let error_id = buffer[1];
        let mut has_error = false;
        let mut errors =  DeviceErrors::default();

        //If overvoltage or undervoltage, all other errors might not be set
        if(error_id & FaultBits::OVUV) !=0 {
            errors.overvoltage_undervoltage = true;
            return Err(Error::Device(errors))
        }
        if(error_id & FaultBits::CJ_HIGH) !=0 {
            errors.cold_junction_high = true;
            has_error = true;
        }
        if(error_id & FaultBits::CJ_LOW) !=0 {
            errors.cold_junction_low = true;
            has_error = true;
        }
        if(error_id & FaultBits::CJ_RANGE) !=0 {
            errors.cold_junction_out_of_range = true;
            has_error = true;
        }
        if(error_id & FaultBits::OPEN) !=0 {
            errors.open_circuit = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_HIGH) !=0 {
            errors.thermocouple_high = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_LOW) !=0 {
            errors.thermocouple_low = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_RANGE) !=0 {
            errors.thermocouple_out_of_range = true;
            has_error = true;
        }
        if has_error {            
            Err(Error::Device(errors))
        } else {
            Ok(())
        }
    }
/// Check if any of the faults are triggered
Check if any of the faults are triggered
Check if any of the faults are triggered
pub fn fault_status(&mut self) -> Result<(), DI::Error>{
        let mut buffer = [0u8; 2]; // One byte value from Fault status register
        buffer[0] = Registers::SR.read_address;
        self.iface.read(&mut buffer)?;
        let error_id = buffer[1];
        let mut has_error = false;
        let mut errors =  DeviceErrors::default();
        //If overvoltage or undervoltage, all other errors might not be set
        if(error_id & FaultBits::OVUV) !=0 {
            errors.overvoltage_undervoltage = true;
            return Err(Error::Device(errors))
        }
        if(error_id & FaultBits::CJ_HIGH) !=0 {
            errors.cold_junction_high = true;
            has_error = true;
        }
        if(error_id & FaultBits::CJ_LOW) !=0 {
            errors.cold_junction_low = true;
            has_error = true;
        }
        if(error_id & FaultBits::CJ_RANGE) !=0 {
            errors.cold_junction_out_of_range = true;
            has_error = true;
        }
        if(error_id & FaultBits::OPEN) !=0 {
            errors.open_circuit = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_HIGH) !=0 {
            errors.thermocouple_high = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_LOW) !=0 {
            errors.thermocouple_low = true;
            has_error = true;
        }
        if(error_id & FaultBits::TC_RANGE) !=0 {
            errors.thermocouple_out_of_range = true;
            has_error = true;
        }
        if has_error {            
            Err(Error::Device(errors))
        } else {
            Ok(())
        }
    }
pub fn fault_status ( & mut self ) -> Result < ( ) , DI :: Error > { let mut buffer = [ 0u8 ; 2 ] ; // One byte value from Fault status register buffer [ 0 ] = Registers :: SR . read_address ; self . iface . read ( & mut buffer ) ? ; let error_id = buffer [ 1 ] ; let mut has_error = false ; let mut errors = DeviceErrors :: default ( ) ; //If overvoltage or undervoltage, all other errors might not be set if ( error_id & FaultBits :: OVUV ) != 0 { errors . overvoltage_undervoltage = true ; return Err ( Error :: Device ( errors ) ) } if ( error_id & FaultBits :: CJ_HIGH ) != 0 { errors . cold_junction_high = true ; has_error = true ; } if ( error_id & FaultBits :: CJ_LOW ) != 0 { errors . cold_junction_low = true ; has_error = true ; } if ( error_id & FaultBits :: CJ_RANGE ) != 0 { errors . cold_junction_out_of_range = true ; has_error = true ; } if ( error_id & FaultBits :: OPEN ) != 0 { errors . open_circuit = true ; has_error = true ; } if ( error_id & FaultBits :: TC_HIGH ) != 0 { errors . thermocouple_high = true ; has_error = true ; } if ( error_id & FaultBits :: TC_LOW ) != 0 { errors . thermocouple_low = true ; has_error = true ; } if ( error_id & FaultBits :: TC_RANGE ) != 0 { errors . thermocouple_out_of_range = true ; has_error = true ; } if has_error { Err ( Error :: Device ( errors ) ) } else { Ok ( ( ) ) } }
Check if any of the faults are triggered
Check if any of the faults are triggered
&mut self