def METHOD_NAME(msg, expected_mode, expected_p, expected_q):
    res = 0
    # Read status and print control mode and tolerances
    s.poll()
    control_mode = None
    for i in s.gcodes:
        if i in (610, 611, 640):
            control_mode = i
    if len(s.settings) == 3:
        # Pre-state-tags fix
        print("%s:  Control mode = %d" % (msg, control_mode))
        p, q = (expected_p, expected_q)  # Fake valid results
    else:
        # After state-tags fix
        print("%s:  Control mode = %d; tolerances = P%.3f Q%.3f" % (
            msg, control_mode, s.settings[3], s.settings[4]))
        p, q = (s.settings[3], s.settings[4])
    if control_mode != expected_mode:
        print("*** ERROR control mode %d != expected %d" % (
            control_mode, expected_mode))
        res += 1
    if expected_p is not None and abs(p - expected_p) > 0.001:
        print("*** ERROR blend tolerance P%.3f != expected P%.3f" % (
            p, expected_p))
        res += 1
    if expected_q is not None and abs(q - expected_q) > 0.001:
        print("*** ERROR naive CAM tolerance Q%.3f != expected Q%.3f" % (
            q, expected_q))
        res += 1
    return res