component failstop "if any of the inputs ever become true, stop threads and print a message";

pin_ptr in bit in#[pincount] = 0;
pin_ptr out bit stopped = 0;
instanceparam int pincount = 2      "number of input pins, in0..inN";
//instanceparam string message; //  = "input became TRUE";
option MAXCOUNT 16;

function _;

author          "Michael Haberler";
license         "GPLv2 or later";
;;

FUNCTION(_)
{
    int i;
    for (i = 0; i < local_pincount; i++)
	if (get_bit_pin(in(i))) {
	    hal_stop_threads();
	    set_bit_pin(stopped, 1);
	    rtapi_print_msg(RTAPI_MSG_ERR,
			    "failstop %s on %s: pin 'in%d' became true",
			    fa_funct_name(fa),fa_thread_name(fa), i);
	}
    return 0;
}
