From: Philippe Gerum <rpm@xenomai.org>
To: Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
Cc: xenomai <xenomai@lists.linux.dev>
Subject: Re: Simple Xenomai 4 API use examples and a question
Date: Fri, 22 Aug 2025 09:45:46 +0200 [thread overview]
Message-ID: <87349jhk9h.fsf@xenomai.org> (raw)
In-Reply-To: <9330e95ad45a1742cedfdf2335141c3f79b7223d.camel@lapp.in2p3.fr> (Emmanuel Pacaud's message of "Fri, 22 Aug 2025 09:13:34 +0200")
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.
next prev parent reply other threads:[~2025-08-22 7:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-08-22 12:20 ` Emmanuel Pacaud
2025-08-22 13:29 ` Emmanuel Pacaud
2025-08-24 9:02 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87349jhk9h.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=emmanuel.pacaud@lapp.in2p3.fr \
--cc=xenomai@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.