hal_export_funct(3hal)

πŸ’– hal_export_funct πŸ’–

okay bestie, welcome to the hal_export_funct(3hal) page β€” yes that's the manual name, it lives in section 3hal, and it's literally the glow-up your realtime function needs to get noticed by the whole system ✨


✨ NAME ✨

hal_export_funct β€” create a realtime function callable from a thread πŸ§΅πŸ’…


πŸŽ€ SYNTAX πŸŽ€

typedef void(*hal_funct_t)(void * arg, long period)

int hal_export_funct(const char *name, hal_funct_t funct, void *arg, int
       uses_fp, int reentrant, int comp_id)

that's the whole vibe, no cap πŸ¦‹


🌸 ARGUMENTS 🌸

  • name β€” the name of the function. like, its name-name. what you're gonna call it πŸ‘‘
  • funct β€” the pointer to the function 🫢
  • arg β€” the argument that gets passed as the first parameter of funct
  • uses_fp β€” nonzero if the function does floating-point operations, and yes that includes assigning floating point values with "=" 😭 don't skip that part, it counts
  • reentrant β€” if reentrant is non-zero, the function may be preempted and called again before the first call even finishes πŸ’€ otherwise? it may only be added to one thread. one. single. thread. 🚫
  • comp_id β€” a HAL component identifier, and you get that from an earlier call to hal_init 🌈

πŸ’œ DESCRIPTION πŸ’œ

hal_export_funct makes a realtime function that a component provides available to the system. that's it, that's the whole serve πŸ’… then a later call to hal_add_funct_to_thread can be used to schedule when the function actually runs, as the system needs it.

so when this function gets placed on a HAL thread, and HAL threads are started, funct gets called over and over again with two arguments: void *arg is the exact same value you gave to hal_export_funct, and long period is the interval between calls, measured in nanoseconds ⏱️

and listen β€” each call to the function should do a small amount of work and return. small. tiny. a lil snack, not a whole feast πŸ™ˆ

⭐ RETURN VALUE ⭐

Returns a HAL status code ✨


πŸ”₯ SEE ALSO πŸ”₯


and that's the page bestie πŸŽ€ big shoutout to the LinuxCNC Documentation crew β€” this one's dated 2006-10-12, so it's been iconic for a minute πŸ‘‘ mwah, go schedule something πŸ’–