# Connect to RPyC server and get main object
        connection = rpyc.connect_by_service("TAMAGOTCHIP")
        r = connection.root
    except DiscoveryError, e:
        return FAIL, "Serial interface daemon unreachable."
    except Exception, e:
        # Ugly hack to catch the SerialException, but only that one
        # Exceptions through RPyC are a little hard to track.
        if isinstance(e, collections.Iterable) and \
            "SerialException" in e.args[0]:
            return FAIL, "Microcontroller unavailable."
        else:
            raise e
    else:
        # Reset communication to microcontroller and set new states
        msg = r.set_states(states)

        # Close nicely, and relay feedback to caller
        connection.close()
        return SUCCESS, msg

@usercommand
def flow_red():
    """ Flow in red ink. (by opening the corresponding valves) """
    set_states([1, 1, 1, 1, 1, 0, 1, 1, 0] + [0] * 3)
    r.set("state_msg", "Flowing red dye.")

@usercommand
def flow_blue():
    """ Flow in blue ink. (by opening the corresponding valves) """
    set_states([0, 1, 1, 1, 1, 0, 1, 1, 1] + [0] * 3)