* Simple Xenomai 4 API use examples and a question
@ 2025-08-22 7:13 Emmanuel Pacaud
2025-08-22 7:34 ` Philippe Gerum
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Emmanuel Pacaud @ 2025-08-22 7:13 UTC (permalink / raw)
To: xenomai
Hi,
I have started to work on a repository which is intended as a collection of very simple (dumb) examples of Xenomai 4 API use. Each example is an application, sometimes coupled with a kernel module, with the strict minimum around the actual API use. Applications and kernel modules are built using meson. The meson files are also kept the their simplest form. That was easy for the application building, not so for the kernel modules.
The repository is here: <https://gitlab.com/emmanuelpacaud/xenomai-c-examples>
It is similar to what I did for my own project: <https://github.com/AravisProject/aravis-c-examples>. I do think this sort a simple example collection are useful to understand how to use an API.
It is a work on progress, the code should be more commented.
But to be useful, all the examples should work, and I'm blocking on the oob_ioctl example :(
* <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/oob-ioctl.c>
* <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.c>
* <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.h>
The ioctl call fails with a `Bad file descriptor` error. What I'm doing wrong ?
Emmanuel.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:13 Simple Xenomai 4 API use examples and a question Emmanuel Pacaud
@ 2025-08-22 7:34 ` Philippe Gerum
2025-08-22 7:35 ` Philippe Gerum
2025-08-22 7:45 ` Philippe Gerum
2025-08-22 13:29 ` Emmanuel Pacaud
2 siblings, 1 reply; 8+ messages in thread
From: Philippe Gerum @ 2025-08-22 7:34 UTC (permalink / raw)
To: Emmanuel Pacaud; +Cc: xenomai
Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> writes:
> [1. text/markdown]
> Hi,
>
> I have started to work on a repository which is intended as a collection of very simple (dumb) examples of Xenomai 4 API use. Each example is an application, sometimes coupled with a kernel module, with the strict minimum around the actual API use. Applications and kernel modules are built using meson. The meson files are also kept the their simplest form. That was easy for the application building, not so for the kernel modules.
>
> The repository is here: <https://gitlab.com/emmanuelpacaud/xenomai-c-examples>
>
> It is similar to what I did for my own project: <https://github.com/AravisProject/aravis-c-examples>. I do think this sort a simple example collection are useful to understand how to use an API.
>
> It is a work on progress, the code should be more commented.
>
> But to be useful, all the examples should work, and I'm blocking on the oob_ioctl example :(
>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/oob-ioctl.c>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.c>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.h>
>
> The ioctl call fails with a `Bad file descriptor` error. What I'm doing wrong ?
>
Looks like a typo in the public path to the thread:
- fd = open ("/dev/oob_ioctl", O_RDWR);
+ fd = open ("/dev/evl/thread/oob_ioctl", O_RDWR);
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:34 ` Philippe Gerum
@ 2025-08-22 7:35 ` Philippe Gerum
2025-08-22 7:36 ` Philippe Gerum
0 siblings, 1 reply; 8+ messages in thread
From: Philippe Gerum @ 2025-08-22 7:35 UTC (permalink / raw)
To: Emmanuel Pacaud; +Cc: xenomai
Philippe Gerum <rpm@xenomai.org> writes:
> Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> writes:
>
>> [1. text/markdown]
>> Hi,
>>
>> I have started to work on a repository which is intended as a
>> collection of very simple (dumb) examples of Xenomai 4 API use. Each
>> example is an application, sometimes coupled with a kernel module,
>> with the strict minimum around the actual API use. Applications and
>> kernel modules are built using meson. The meson files are also kept
>> the their simplest form. That was easy for the application building,
>> not so for the kernel modules.
>>
>> The repository is here: <https://gitlab.com/emmanuelpacaud/xenomai-c-examples>
>>
>> It is similar to what I did for my own project: <https://github.com/AravisProject/aravis-c-examples>. I do think this sort a simple example collection are useful to understand how to use an API.
>>
>> It is a work on progress, the code should be more commented.
>>
>> But to be useful, all the examples should work, and I'm blocking on the oob_ioctl example :(
>>
>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/oob-ioctl.c>
>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.c>
>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.h>
>>
>> The ioctl call fails with a `Bad file descriptor` error. What I'm doing wrong ?
>>
>
> Looks like a typo in the public path to the thread:
>
> - fd = open ("/dev/oob_ioctl", O_RDWR);
> + fd = open ("/dev/evl/thread/oob_ioctl", O_RDWR);
Sorry, stike that. I missed the point. You want to open the driver, not
the thread element.
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:35 ` Philippe Gerum
@ 2025-08-22 7:36 ` Philippe Gerum
0 siblings, 0 replies; 8+ messages in thread
From: Philippe Gerum @ 2025-08-22 7:36 UTC (permalink / raw)
To: Emmanuel Pacaud; +Cc: xenomai
Philippe Gerum <rpm@xenomai.org> writes:
> Philippe Gerum <rpm@xenomai.org> writes:
>
>> Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> writes:
>>
>>> [1. text/markdown]
>>> Hi,
>>>
>>> I have started to work on a repository which is intended as a
>>> collection of very simple (dumb) examples of Xenomai 4 API use. Each
>>> example is an application, sometimes coupled with a kernel module,
>>> with the strict minimum around the actual API use. Applications and
>>> kernel modules are built using meson. The meson files are also kept
>>> the their simplest form. That was easy for the application building,
>>> not so for the kernel modules.
>>>
>>> The repository is here: <https://gitlab.com/emmanuelpacaud/xenomai-c-examples>
>>>
>>> It is similar to what I did for my own project: <https://github.com/AravisProject/aravis-c-examples>. I do think this sort a simple example collection are useful to understand how to use an API.
>>>
>>> It is a work on progress, the code should be more commented.
>>>
>>> But to be useful, all the examples should work, and I'm blocking on the oob_ioctl example :(
>>>
>>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/oob-ioctl.c>
>>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.c>
>>> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.h>
>>>
>>> The ioctl call fails with a `Bad file descriptor` error. What I'm doing wrong ?
>>>
>>
>> Looks like a typo in the public path to the thread:
>>
>> - fd = open ("/dev/oob_ioctl", O_RDWR);
>> + fd = open ("/dev/evl/thread/oob_ioctl", O_RDWR);
>
> Sorry, stike that. I missed the point. You want to open the driver,
> not
strike that, too. Coffee underflow.
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:13 Simple Xenomai 4 API use examples and a question Emmanuel Pacaud
2025-08-22 7:34 ` Philippe Gerum
@ 2025-08-22 7:45 ` Philippe Gerum
2025-08-22 12:20 ` Emmanuel Pacaud
2025-08-22 13:29 ` Emmanuel Pacaud
2 siblings, 1 reply; 8+ messages in thread
From: Philippe Gerum @ 2025-08-22 7:45 UTC (permalink / raw)
To: Emmanuel Pacaud; +Cc: xenomai
Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> writes:
> [1. text/markdown]
> Hi,
>
> I have started to work on a repository which is intended as a collection of very simple (dumb) examples of Xenomai 4 API use. Each example is an application, sometimes coupled with a kernel module, with the strict minimum around the actual API use. Applications and kernel modules are built using meson. The meson files are also kept the their simplest form. That was easy for the application building, not so for the kernel modules.
>
> The repository is here: <https://gitlab.com/emmanuelpacaud/xenomai-c-examples>
>
> It is similar to what I did for my own project: <https://github.com/AravisProject/aravis-c-examples>. I do think this sort a simple example collection are useful to understand how to use an API.
>
> It is a work on progress, the code should be more commented.
>
> But to be useful, all the examples should work, and I'm blocking on the oob_ioctl example :(
>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/oob-ioctl.c>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.c>
> * <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/cd9f849d4325b57565edcd691021255adc486b90/modules/oob-ioctl.h>
>
> The ioctl call fails with a `Bad file descriptor` error. What I'm doing wrong ?
>
> Emmanuel.
EBADF is likely returned because your driver does not register the file
as an oob-capable one, therefore it won't accept oob_ioctl() requests. A
typical way to implement the missing bits would be as follows:
struct foo_state {
struct evl_file efile;
...
};
static int foo_open(struct inode *inode, struct file *filp)
{
struct foo_state *st;
int ret;
st = kzalloc(sizeof(*st), GFP_KERNEL);
if (st == NULL)
return -ENOMEM;
ret = evl_open_file(&st->efile, filp);
if (ret)
kfree(st);
filp->private_data = st;
return ret;
}
static int foo_release(struct inode *inode, struct file *filp)
{
struct foo_state *st = filp->private_data;
evl_release_file(&st->efile);
kfree(st);
return 0;
}
The way this works is explained in this document:
https://v4.xenomai.org/core/kernel-api/file/
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:45 ` Philippe Gerum
@ 2025-08-22 12:20 ` Emmanuel Pacaud
0 siblings, 0 replies; 8+ messages in thread
From: Emmanuel Pacaud @ 2025-08-22 12:20 UTC (permalink / raw)
To: Philippe Gerum; +Cc: xenomai
Le vendredi 22 août 2025 à 09:45 +0200, Philippe Gerum a écrit :
> EBADF is likely returned because your driver does not register the file
> as an oob-capable one, therefore it won't accept oob_ioctl() requests.
That was the issue. It works fine now.
> The way this works is explained in this document:
> https://v4.xenomai.org/core/kernel-api/file/
I'm pretty sure my eyes went over this page, but the information did not propagate to the brain.
Thanks,
Emmanuel.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 7:13 Simple Xenomai 4 API use examples and a question Emmanuel Pacaud
2025-08-22 7:34 ` Philippe Gerum
2025-08-22 7:45 ` Philippe Gerum
@ 2025-08-22 13:29 ` Emmanuel Pacaud
2025-08-24 9:02 ` Philippe Gerum
2 siblings, 1 reply; 8+ messages in thread
From: Emmanuel Pacaud @ 2025-08-22 13:29 UTC (permalink / raw)
To: xenomai
Le vendredi 22 août 2025 à 09:13 +0200, Emmanuel Pacaud a écrit :
> I have started to work on a repository which is intended as a collection of very simple (dumb) examples of Xenomai 4 API use. Each example is an application, sometimes coupled with a kernel module, with the strict minimum around the actual API use. Applications and kernel modules are built using meson. The meson files are also kept the their simplest form. That was easy for the application building, not so for the kernel modules.
In my quest of the simplest example, there is this line in <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/8253729aa3eb669576e387bba80085c91199f3cf/meson.build>:
```
exe = executable (e, e + '.c',
dependencies: evl_dep,
c_args: ['-I' + evl_dep.get_pkgconfig_variable('includedir') 'uapi'],
install: true)
```
In my setup, I, don't install kernel user space API headers, as it is a diskless one, where I want to be able to switch between different kernels. So I let install-uapi enabled, which means *-abi.h files are installed in $prefix/include/uapi. Which means I have to add this path to the include path manually, as it is not present in the pkg config file, using c_args parameter.
Is it intended ? I would have expected them to be installed along the other libevl headers. If so, I think the C flags in pkg config file should include $includedir/uapi, when install-uapi option is enabled.
Emmanuel.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Simple Xenomai 4 API use examples and a question
2025-08-22 13:29 ` Emmanuel Pacaud
@ 2025-08-24 9:02 ` Philippe Gerum
0 siblings, 0 replies; 8+ messages in thread
From: Philippe Gerum @ 2025-08-24 9:02 UTC (permalink / raw)
To: Emmanuel Pacaud; +Cc: xenomai
Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> writes:
> [1. text/markdown]
> Le vendredi 22 août 2025 à 09:13 +0200, Emmanuel Pacaud a écrit :
>> I have started to work on a repository which is intended as a collection of very simple (dumb) examples of Xenomai 4 API use. Each example is an application, sometimes coupled with a kernel module, with the strict minimum around the actual API use. Applications and kernel modules are built using meson. The meson files are also kept the their simplest form. That was easy for the application building, not so for the kernel modules.
>
> In my quest of the simplest example, there is this line in <https://gitlab.com/emmanuelpacaud/xenomai-c-examples/-/blob/8253729aa3eb669576e387bba80085c91199f3cf/meson.build>:
>
> ```
> exe = executable (e, e + '.c',
> dependencies: evl_dep,
> c_args: ['-I' + evl_dep.get_pkgconfig_variable('includedir') 'uapi'],
> install: true)
> ```
>
> In my setup, I, don't install kernel user space API headers, as it is a diskless one, where I want to be able to switch between different kernels. So I let install-uapi enabled, which means *-abi.h files are installed in $prefix/include/uapi. Which means I have to add this path to the include path manually, as it is not present in the pkg config file, using c_args parameter.
>
> Is it intended ? I would have expected them to be installed along the other libevl headers. If so, I think the C flags in pkg config file should include $includedir/uapi, when install-uapi option is enabled.
>
> Emmanuel.
Since ABI 42 guarantees that we have no naming conflict anymore thanks
to the -abi.h suffix for those headers, we can merge them with the
common library headers, leaving the evl.pc generation as is. I'm pushing
the following change to the -next branch to address this:
diff --git a/meson/install-uapi.sh b/meson/install-uapi.sh
index 333122b..2ccee5e 100644
--- a/meson/install-uapi.sh
+++ b/meson/install-uapi.sh
@@ -3,4 +3,4 @@
# $2 = $includedir
cd $1
-find -L evl \! \( -name '*~' \) -type f | cpio -pdum --quiet $MESON_INSTALL_DESTDIR_PREFIX/$2/uapi
+find -L evl \! \( -name '*~' \) -type f | cpio -pdum --quiet $MESON_INSTALL_DESTDIR_PREFIX/$2
Please let me know if that fixes the issue on your end.
--
Philippe.
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-08-24 9:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 7:13 Simple Xenomai 4 API use examples and a question Emmanuel Pacaud
2025-08-22 7:34 ` Philippe Gerum
2025-08-22 7:35 ` Philippe Gerum
2025-08-22 7:36 ` Philippe Gerum
2025-08-22 7:45 ` Philippe Gerum
2025-08-22 12:20 ` Emmanuel Pacaud
2025-08-22 13:29 ` Emmanuel Pacaud
2025-08-24 9:02 ` Philippe Gerum
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.