[Xenomai] struct rtdm_fd usage in application

Heinick, J Michael Michael.Heinick at Honeywell.com
Wed Dec 2 19:38:39 CET 2015

What file(s) do we have to include in an application that interacts
with a RTDM driver with a node in the /dev/rtdm directory and needs the
declaration of the rtdm_fd structure?  Any additional information on,
and examples of, the usage of the rtdm_fd structure would be appreciated.

Currently, we have a RTDM driver that installs with insmod, creates the
node in /dev/rtdm, uninstalls with rmmod, and removes the node from
/dev/rtdm.  At this early stage this RTDM driver is only a skeleton that
will log a message with rtdm_printk whenever the read, write, and ioctl
handlers are called.  From the Xenomai 3.0.1 API documentation it appears
that an application interacting with this driver through open, close,
read, write, and ioctl will need to have the declaration of the rtdm_fd
structure.  The driver code containing the rtdm_fd structure had no
problems being built, but when the application code containing the
"struct rtdm_fd fd;" statement is built an error is generated.

A declaration for the rtdm_fd structure could not be found in the
/usr/xenomai/include directories on our installation.

Thanks for any help that you can provide.
Mike H.

Additional details on our situation are included below:

The code: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Note: The open statement is probably wrong.
  At this point just trying to get past the rtdm_fd stucture.
// ------------- tcgrtdmtest.c -----------
//#include <fcntl.h>
//#include <unistd.h>

//#include <uapi/kernel/types.h>
//#include <rtdm/uapi/rtdm.h>
#include <rtdm/rtdm.h>

int main()
  struct rtdm_fd fd;
  //int fd;
  fd = open("/dev/rtdm/tcgrtdm",O_RDWR);
  return 0;

The makefile: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
XENO_CONFIG := /usr/xenomai/bin/xeno-config
CFLAGS := $(shell $(XENO_CONFIG) --posix --cflags)
LDLAGS := $(shell $(XENO_CONFIG) --posix --ldflags)
CC := $(shell $(XENO_CONFIG) --cc)

        $(CC) -o tcgrtdmtest tcgrtdmtest.C $(CFLAGS) $(LDFLAGS)

The result: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ make
gcc -o tcgrtdmtest tcgrtdmtest.C -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__COBALT__ -D__COBALT_WRAP__
tcgrtdmtest.C: In function ‘int main()’:
tcgrtdmtest.C:11:18: error: aggregate ‘main()::rtdm_fd fd’ has incomplete type and cannot be defined
   struct rtdm_fd fd;
make: *** [default] Error 1

Note: Using <rtdm/uapi/rtdm.h> instead of <rtdm/rtdm.h> generates several
errors from uapi/rtdm.h that uint64_t, socklen_t, __64, and size_t do not
name types in addition to the one involving rtdm_fd.

/usr/xenomai Directories: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
boilerplate  pthread.h    signal.h  sys       time.h      uapi
fcntl.h      sched.h      stdio.h   syslog.h  trace.h     unistd.h
mqueue.h     semaphore.h  stdlib.h  ticks.h   tunables.h  wrappers.h

cond.h     event.h  monitor.h  sched.h  signal.h   sysconf.h  time.h
corectl.h  kernel   mutex.h    sem.h    syscall.h  thread.h

alchemy      cobalt       psos  smokey  version.h  xeno_config.h
boilerplate  copperplate  rtdm  trank   vxworks    xenomai

analogy.h  autotune.h  can.h  ipc.h  rtdm.h  serial.h  testing.h  uapi  udd.h

analogy.h  autotune.h  can.h  ipc.h  rtdm.h  serial.h  testing.h  udd.h

Return from /usr/xenomai/bin/xeno-config --info vvvvvvvvvvvvvvvvvvvvvvvvvv
$ /usr/xenomai/bin/xeno-config --info
Xenomai version: Xenomai/cobalt v3.0.1
Linux htsi-linux 3.14.44-xeno02 #1 SMP PREEMPT Fri Nov 13 09:35:37 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
Kernel parameters: BOOT_IMAGE=/vmlinuz-3.14.44-xeno02 root=UUID=ef5daf08-36a0-46b3-9ed4-4917b36301cf ro nomodeset quiet splash
I-pipe release #10 detected
Cobalt core 3.0.1 detected
Compiler: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
Build args: --with-core=cobalt --enable-smp --enable-pshared --host=i686-linux host_alias=i686-linux

More information about the Xenomai mailing list