forked from LinuxCNC/linuxcnc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tpmod.c
47 lines (40 loc) · 1 KB
/
tpmod.c
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) This rtapi_app_main() creates a minimal component (tpmod)
** allowing use with:
** 'halcmd loadrt tpmod' (loads module: tpmod.so)
** 2) tp.c, tc.c,...,etc provide all functions required by
** subsequent load of motmod
*/
#include "rtapi.h"
#include "rtapi_app.h"
#include "hal.h"
MODULE_LICENSE("GPL");
#define TPMOD_DEBUG
#undef TPMOD_DEBUG
// provision for testing use of module parameters:
static char *tp_parms;
RTAPI_MP_STRING(tp_parms,"Example tp parms");
static int tpmod_id;
int rtapi_app_main(void)
{
#ifdef TPMOD_DEBUG
if (tp_parms) {
rtapi_print("%s:%s: tp_parms=%s\n",__FILE__,__FUNCTION__,tp_parms);
}
#endif
char* emsg;
tpmod_id = hal_init("tpmod"); // dlopen(".../tpmod.so")
if (tpmod_id < 0) {emsg="hal_init()"; goto error;}
hal_ready(tpmod_id);
return 0;
error:
rtapi_print_msg(RTAPI_MSG_ERR,"\ntpmod FAIL:<%s>\n",emsg);
hal_exit(tpmod_id);
return -1;
}
void rtapi_app_exit(void)
{
hal_exit(tpmod_id);
return;
}