aboutsummaryrefslogtreecommitdiffstats
path: root/src/emc/motion/homemod.c
blob: 66b1bd9305da1ee1a32517a79e365e1e01bc22f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
**Notes:
**  1) The rtapi_app_main() creates a minimal component (homemod)
**     allowing use with:
**     'halcmd loadrt homemod' (loads module: homemod.so)
**  2) homing.c provides all functions required by subsequent load
**     of motmod
*/
#include "rtapi.h"
#include "rtapi_app.h"
#include "hal.h"
MODULE_LICENSE("GPL");

#define HOMEMOD_DEBUG
#undef  HOMEMOD_DEBUG

// provision for testing use of module parameters:
static char *home_parms;
RTAPI_MP_STRING(home_parms,"Example home parms");

static int homemod_id;
int rtapi_app_main(void)
{
#ifdef HOMEMOD_DEBUG
    if (home_parms) {
        rtapi_print("%s:%s: home_parms=%s\n",__FILE__,__FUNCTION__,home_parms);
    }
#endif

    char* emsg;
    homemod_id = hal_init("homemod"); // dlopen(".../homemod.so")
    if (homemod_id < 0) {emsg="hal_init()"; goto error;}

    hal_ready(homemod_id);
    return 0;

error:
    rtapi_print_msg(RTAPI_MSG_ERR,"\nhomemod FAIL:<%s>\n",emsg);
    hal_exit(homemod_id);
    return -1;
}

void rtapi_app_exit(void)
{
    hal_exit(homemod_id);
    return;
}
bues.ch cgit interface