In the Xenomai API documentation, you have also an example of regular (i.e. non-real-time) thread and a real-time task communicating through an XDDP socket:
https://xenomai.org/documentation/xenomai-3/html/xeno3prm/xddp-echo_8c-example.html.
Your ROS node should behave as the regular thread does.
Then we would like to read this source code of regular thread for the website.
* regular_thread---------------------------------------+ |
* => open /dev/rtp0 | ^
* => read traffic from RT domain via read() | |
* => echo traffic back to RT domain via write() +--+
*/
static void *regular_thread(void *arg)
{
char buf[128], *devname;
int fd, ret;
if (asprintf(&devname, "/dev/rtp%d", XDDP_PORT) < 0)
fail("asprintf");
fd = open(devname, O_RDWR);
free(devname);
if (fd < 0)
fail("open");
for (;;) {
/* Get the next message from realtime_thread. */