> Looks like the code formatting got messed up by the elog... here it is in the attachment instead.
unfortunately, your code does nothing because you do not call "i2c_set_bit(10, 1);".
if you add it in the destructor:
~i2c_temp_bit() {
std::cout << "Bit " << bit << " set to " << oldval << "\n";
i2c_set_bit(10, 0);
}
you will burn the kitchen down if "std::cout" and "<<" throw an exception (as we know they do). (I
always use printf(), instead of c++ exceptions, it can throw the SIGPIPE signal, so main() must
always have signal(SIGPIPE, SIG_IGN);).
also if usleep() throws an exception, the water does not get boiled to 100 degC, important for food
safety.
also there is a logic error, if you are at a high enough elevation (Mount Everest), water starts
boiling well below 100 degC, so the loop never ends, probably until all water is gone and the empty
kettle is heated to 100 degC, at this point, both kettle and heater are probably damaged. the
infinite loop should have some kind of safety limit.
K.O. |