hal_param_new(3hal)

πŸ’… NAME πŸ’…

okay so bestie, gather round β€” this is hal_param_new from the 3hal manual, and it creates a HAL parameter. that's the whole vibe. a brand new param object, fresh out of the box, yours to keep ✨


🌸 SYNTAX 🌸

like, here's the full lineup, no cap β€” every single one of these makes a param:

int hal_param_bit_new(const char *name, hal_param_dir_t dir,
       hal_bit_t * data_addr, int comp_id)

int hal_param_float_new(const char *name, hal_param_dir_t dir,
       hal_float_t * data_addr, int comp_id)

int hal_param_u32_new(const char *name, hal_param_dir_t dir,
       hal_u32_t * data_addr, int comp_id)

int hal_param_s32_new(const char *name, hal_param_dir_t dir,
       hal_s32_t * data_addr, int comp_id)

int hal_param_bit_newf(hal_param_dir_t dir, hal_bit_t *
       data_addr, int comp_id, const char *fmt, ...)

int hal_param_float_newf(hal_param_dir_t dir, hal_float_t *
       data_addr, int comp_id, const char *fmt, ...)

int hal_param_u32_newf(hal_param_dir_t dir, hal_u32_t *
       data_addr, int comp_id, const char *fmt, ...)

int hal_param_s32_newf(hal_param_dir_t dir, hal_s32_t *
       data_addr, int comp_id, const char *fmt, ...)

int hal_param_new(const char *name, hal_type_t type,
       hal_param_dir_t dir, void *data_addr, int comp_id)

nine functions. nine. the _newf girlies take a format string, the plain ones just take a name, and hal_param_new is the generalist queen who takes a type instead πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • name β€” the name you're giving to the parameter you just created. name your baby. it's giving main character energy 🍼
  • dir β€” the direction of the parameter, and this is from the component's point of view, okay? it can be one of HAL_RO, or HAL_RW. here's the tea: a component may assign a value to any parameter, but other programs (like halcmd) may only assign a value to a parameter that is HAL_RW. so if you want the outside world to be able to write to it, you already know which one to pick πŸ’…
  • data_addr β€” the address of the data. and bestie, listen, it must lie within memory allocated by hal_malloc. not "should", must. don't get cute with it 🫢
  • comp_id β€” a HAL component identifier, returned by an earlier call to hal_init. you gotta have done that first, fr fr.
  • fmt, ... β€” a printf-style format string and arguments. yeah, it's that kind of party ✨
  • type β€” the type of the parameter, as specified in hal_type_t(3hal). go check that page for the deets πŸ“–

πŸ¦‹ DESCRIPTION πŸ¦‹

so the hal_param_new family of functions create a new param object. that's it, that's the job, and they ate πŸ’…

there are functions for each of the data types that the HAL supports β€” hence the whole bit/float/u32/s32 lineup up in the synopsis.

also, quick note that lives here in this section: pins may only be linked to signals of the same type. just a lil fact, no notes πŸ’€

⭐ RETURN VALUE ⭐

returns a HAL status code. that's the whole return value section, she's short and she's iconic 🌈


πŸ”₯ SEE ALSO πŸ”₯


and that's the page, bestie!! this one's from the LinuxCNC Documentation, dated 2006-10-12, and it lives in the 3hal manual β€” so next time you need her, just holler for hal_param_new(3hal) and she'll be there πŸ«ΆπŸ’–βœ¨