rtapi_app_main(3rtapi)

✨ rtapi_app_main ✨

okay bestie, so this is rtapi_app_main(3rtapi) β€” it lives in the HAL corner of the LinuxCNC manual universe, and it's literally the function YOU write to get your component born into the world. πŸ‘‘


🌸 NAME 🌸

rtapi_app_main β€” the user-provided function that initializes a component πŸ’–


πŸŽ€ SYNTAX πŸŽ€

#include <rtapi_app.h>

int rtapi_app_main(void) {...}

🫢 ARGUMENTS 🫢

None. Nada. Zero. It takes no arguments, she's low-maintenance like that. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: rtapi_app_main is your function. Like, the component author writes the body of it. That's you, bestie. ✨

And what goes in that body? Generally it's a call to rtapi_init or hal_init, and then after that comes all the other component-specific initialization code you need. That's the whole vibe β€” you're basically rolling out the red carpet so your component can make its grand entrance. 🌈


πŸ’œ RETURN VALUE πŸ’œ

  • Return 0 for success. slay. βœ…
  • Return a negative errno value (e.g., -EINVAL) on error. 🚨

ngl, existing code also returns RTAPI or HAL error values, and that's fine β€” but here's the thing: using negative errno values gives you better diagnostics from insmod. so do that if you can. iykyk. 🫢


πŸ”₯ REALTIME CONSIDERATIONS πŸ”₯

This gets called automatically by the rtapi infrastructure, and it happens in an initialization context β€” which is to say, NOT realtime. so no panicking about your realtime budget here, she's off duty. 😌


⭐ SEE ALSO ⭐


and that's the whole page, bestie!! πŸŽ€ go forth and init your components. the LinuxCNC Documentation wrote this one back on 2008-05-26, and it's still out here being iconic in the rtapi_app_main(3rtapi) era. mwah. πŸ’–πŸ¦‹βœ¨