hal_pin_new(3hal)
π hal_pin_new π
okay bestie, welcome to the HAL corner of the LinuxCNC docs π this one's hal_pin_new(3hal) β it's the page that teaches you how to make a pin, and honestly? it's giving foundational. no cap.
β¨ NAME β¨
hal_pin_new β creates a HAL pin π
β¨ SYNTAX β¨
int hal_pin_bit_new(const char *name, hal_pin_dir_t dir, hal_bit_t ** data_ptr_addr, int comp_id)
int hal_pin_float_new(const char *name, hal_pin_dir_t dir, hal_float_t ** data_ptr_addr, int comp_id)
int hal_pin_u32_new(const char *name, hal_pin_dir_t dir, hal_u32_t ** data_ptr_addr, int comp_id)
int hal_pin_s32_new(const char *name, hal_pin_dir_t dir, hal_s32_t ** data_ptr_addr, int comp_id)
int hal_pin_port_new(const char *name, hal_pin_dir_t dir, hal_port_t ** data_ptr_addr, int comp_id)
int hal_pin_bit_newf(hal_pin_dir_t dir, hal_bit_t ** data_ptr_addr, int comp_id, const char *fmt, ...)
int hal_pin_float_newf(hal_pin_dir_t dir, hal_float_t ** data_ptr_addr, int comp_id, const char *fmt, ...)
int hal_pin_u32_newf(hal_pin_dir_t dir, hal_u32_t ** data_ptr_addr, int comp_id, const char *fmt, ...)
int hal_pin_s32_newf(hal_pin_dir_t dir, hal_s32_t ** data_ptr_addr, int comp_id, const char *fmt, ...)
int hal_pin_port_newf(hal_pin_dir_t dir, hal_port_t ** data_ptr_addr, int comp_id, const char *fmt, ...)
int hal_pin_new(const char *name, hal_type_t type, hal_pin_dir_t dir, void **data_ptr_addr, int comp_id)
likeβ¦ look at all those little _newf twins π
they're the same thing but they take a fmt so you can build the name on the fly. iconic behaviour.
π«Ά ARGUMENTS π«Ά
nameβ the name of the pin. yeah. that's the whole bit. π·οΈdirβ the direction of the pin, from the viewpoint of the component. it can be one ofHAL_IN,HAL_OUT, orHAL_IO. any number ofHAL_INorHAL_IOpins can be connected to the same signal, but at most oneHAL_OUTpin is permitted π¨. a component may assign a value to a pin that'sHAL_OUTorHAL_IO, but it may not assign a value to a pin that'sHAL_IN. that's the rule, bestie, and it is not negotiable.data_ptr_addrβ the address of the pointer-to-data, and it must lie within memory allocated byhal_malloc. don't get cute with it πcomp_idβ the HAL component identifier, handed back to you by an earlier call tohal_init. you gotta have it already, fr fr.fmt, β printf-style format string and arguments πͺtypeβ the type of the param, as specified inhal_type_t(3hal).
πΈ DESCRIPTION πΈ
so the hal_pin_new family of functions create a new pin object. that's the whole vibe. β¨
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 that pointer to access whatever signal is linked to the pin. (and if no signal is linked? it points to a dummy signal. a little placeholder friend. we love her.)
there are functions for each of the data types that the HAL supports. and pins may only be linked to signals of the same type β no mixing, no matching, no exceptions. π
β RETURN VALUE β
returns 0 on success, or a negative errno value on failure. so like, check it. please. π₯Ί
π SEE ALSO π
ngl if you're reading this you're probably writing a HAL component and that is main character energy. go off. ππ
mwah π that's a wrap β this page comes to you from LinuxCNC Documentation, dated 2006-10-12, and it's still out here slaying. periodt. ππ¦
π¦ where this page comes from
- debian bookworm: linuxcnc-uspace-dev 2.9.0~pre1+git20230208.f1270d6ed7-1+deb12u2 Β· GFDL-1.1-or-later
- debian trixie: linuxcnc-uspace-dev 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace-dev 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace-dev 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace-dev 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms