[][src]Function linuxcnc_hal_sys::hal_pin_bit_new

pub unsafe extern "C" fn hal_pin_bit_new(
    name: *const c_char,
    dir: hal_pin_dir_t,
    data_ptr_addr: *mut *mut hal_bit_t,
    comp_id: c_int
) -> c_int

The 'hal_pin_xxx_new()' functions create a new 'pin' object. Once a pin has been created, it can be linked to a signal object using hal_link(). A pin contains a pointer, and the component that owns the pin can dereference the pointer to access whatever signal is linked to the pin. (If no signal is linked, it points to a dummy signal.) There are eight functions, one for each of the data types that the HAL supports. Pins may only be linked to signals of the same type. 'name' is the name of the new pin. It must be no longer than HAL_NAME_LEN. If there is already a pin with the same name the call will fail. 'dir' is the pin direction. It indicates whether the pin is an input or output from the component. 'data_ptr_addr' is the address of the pointer that the component will use for the pin. When the pin is linked to a signal, the pointer at 'data_ptr_addr' will be changed to point to the signal data location. 'data_ptr_addr' must point to memory allocated by hal_malloc(). Typically the component allocates space for a data structure with hal_malloc(), and 'data_ptr_addr' is the address of a member of that structure. 'comp_id' is the ID of the component that will 'own' the variable. Normally it should be the ID of the caller, but in some cases, a user mode component may be doing setup for a realtime component, so the ID should be that of the realtime component that will actually be using the pin. If successful, the hal_pin_xxx_new() functions return 0. On failure they return a negative error code.