Hi everyone,
I found that two blocks of share memory of emcmot_struct_t has been
created, but how does they get associated?
usrmotintf.cc
int usrmotInit(const char *modname)
{
int retval;
module_id = rtapi_init(modname);
if (module_id < 0) {
fprintf(stderr,
"usrmotintf: ERROR: rtapi init failed\n");
return -1;
}
/* get shared memory block from RTAPI */
shmem_id = rtapi_shmem_new(SHMEM_KEY, module_id, sizeof(emcmot_struct_t));
if (shmem_id < 0) {
fprintf(stderr,
"usrmotintf: ERROR: could not open shared memory\n");
rtapi_exit(module_id);
return -1;
}
/* get address of shared memory area */
retval = rtapi_shmem_getptr(shmem_id, (void **) &emcmotStruct);
if (retval < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,
"usrmotintf: ERROR: could not access shared memory\n");
rtapi_exit(module_id);
return -1;
}
motion.c
static int init_comm_buffers(void)
{
int joint_num, axis_num, n;
emcmot_joint_t *joint;
int retval;
rtapi_print_msg(RTAPI_MSG_INFO, "MOTION: init_comm_buffers() starting...\n"
);
emcmotStruct = 0;
emcmotDebug = 0;
emcmotStatus = 0;
emcmotCommand = 0;
emcmotConfig = 0;
/* allocate and initialize the shared memory structure */
emc_shmem_id = rtapi_shmem_new(key, mot_comp_id, sizeof(emcmot_struct_t));
if (emc_shmem_id < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,
"MOTION: rtapi_shmem_new failed, returned %d\n", emc_shmem_id);
return -1;
}
retval = rtapi_shmem_getptr(emc_shmem_id, (void **) &emcmotStruct);
if (retval < 0) {
rtapi_print_msg(RTAPI_MSG_ERR,
"MOTION: rtapi_shmem_getptr failed, returned %d\n", retval);
return -1;
}
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github:
https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.