On 05/08/2015 01:28 PM, Helder Daniel wrote:
> Hi,
> 
> I am writing a driver that implements read_rt and read_nrt handlers for
> Xenomai 3-rc4 Cobalt.
> But I am having problems when trying to read from user space in comand line:
> 
> $> cat /dev/rtdm/device0
> cat: /dev/rtdm/device0: Invalid argument
> 
> and also from a user space real time thread:
> 
> f = open("/dev/rtdm/device0");
> for(;;){
>    rt_task_wait_period(NULL);
>    read (f, &count, 1);
> //...
> 
> This read gives me garbage.
> 
>

[snip]

> Looking at kernel log, after accessing the driver from user spcae both:
> 
> in cmd line with:
> 
> $> cat /dev/rtdm/device0
> 
> and from a real time task
> 
> it seems that the open, close and read are never called, since there is no
> entry in kernel log.
> 
> I am doing something wrong?

The Cobalt read() service must be called for invoking the related
read_[n]rt handler in your RTDM driver. Since the cat command will use
the regular glibc read() call instead, this won't work. Your test
program is likely missing the wrapping step, which is performed by a
linker trick, substituting calls to read() and other POSIX services to
the corresponding Cobalt implementation. In your test, the glibc
counterpart is still used, which won't work either.

You need to make sure to pass --posix to xeno-config --ldflags for
retrieving the proper LDFLAGS that do the magic for wrapping POSIX
calls. You can combine APIs with xeno-config, such as --alchemy --posix.

> 
> Should I use rtdm_read in user space to access the driver?
>

No, this is a kernel-space only service, for inter-driver communication.
This is the reason why you can't pull the related declarations in a
user-space program.

-- 
Philippe.

_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

Reply via email to