RTDM & serial port
Hi Jan et al.!
I've noticed your thread on the RTAI list "Driver Model for RTAI" in June. Now as I try to port some RTAI serial port stuff to Xenomai in order to put up some howto page on my website, I'm clueless.
None of the RTAI functions rt_spopen, rt_spread_timed, rt_spwrite are available - I see that there is some rt_dev_open, rt_dev_write available, but only rt_dev_read - what about some timed-read ?
I see that rt_spopen opens /dev/rtser[X] but /dev/rtser[X] is not on my system, nor can I find any creation-script in the xenomai source.
Sorry if I'm overlooking some stuff... 5:40am here.
I'd be very glad for any hints/examples/code-snippets!
Thanks a lot & best regards,
Hannes.
Quoted 5 lines · Hannes Mayer
Hi Jan et al.!
I've noticed your thread on the RTAI list "Driver Model for RTAI" in June. Now as I try to port some RTAI serial port stuff to Xenomai in order to put up some howto page on my website, I'm clueless.
Actually, there is already some howto, but I guess also enough room for
improvements: http://www.rts.uni-hannover.de/mitarbeiter/kiszka/rtaddon/
Quoted 4 lines
None of the RTAI functions
rt_spopen,rt_spread_timed,rt_spwriteare available - I see that there is somert_dev_open,rt_dev_writeavailable, but onlyrt_dev_read- what about some timed-read ?
Yep, that's correct, it's yet another new API. Anyway, if you feel the need for a legacy wrapper, you are welcome to add some library on top of the RTDM profile.
BTW, timed read can be realised by setting a reception timeout for the opened device instance, see example or profile documentation.
Quoted 3 lines
I see that
rt_spopenopens /dev/rtser[X] but /dev/rtser[X] is not on my system, nor can I find any creation-script in the xenomai source.
Nope, RTDM devices are not being mapped into the Linux file system. They use a separate namespace where you can find serial devices as plain "rtser[X]".
Quoted 3 lines
Sorry if I'm overlooking some stuff... 5:40am here.
Any frequent problems falling asleep? ;)
Jan
Hi Jan!
Jan Kiszka wrote:
[...]
Quoted 2 lines
Actually, there is already some howto, but I guess also enough room for
improvements: http://www.rts.uni-hannover.de/mitarbeiter/kiszka/rtaddon/
Cool! Thanks!
Quoted 3 lines
Nope, RTDM devices are not being mapped into the Linux file system. They use a separate namespace where you can find serial devices as plain "rtser[X]".
I compiled the rt_serial_uprog, but it can't open rtser0:
# ./rt_serial_uprog rt_serial_uprog: timer started rt_serial_uprog: can't open rtser0 (write) rt_serial_uprog: stop timer
# lsmod Module Size Used by xeno_16550A 12392 0 xeno_rtdm 23460 1 xeno_16550A xeno_native 114384 0 xeno_nucleus 82696 3 xeno_16550A,xeno_rtdm,xeno_native xeno_hal 23616 4 xeno_16550A,xeno_rtdm,xeno_native,xeno_nucleus [...]
rtser[X] should be available as soon as xeno_16550A is loaded, right ?
Quoted 1 line
Any frequent problems falling asleep? ;)
Usually not - we have national holiday today, so I was doing my stuff as long as I wanted :-)
Thanks and best regards,
Hannes.
Hello Hannes,
Quoted 18 lines
...
I compiled thert_serial_uprog, but it can't open rtser0:# ./rt_serial_uprog rt_serial_uprog: timer started rt_serial_uprog: can't open rtser0 (write) rt_serial_uprog: stop timer# lsmod Module Size Used by xeno_16550A 12392 0 xeno_rtdm 23460 1 xeno_16550A xeno_native 114384 0 xeno_nucleus 82696 3 xeno_16550A,xeno_rtdm,xeno_native xeno_hal 23616 4 xeno_16550A,xeno_rtdm,xeno_native,xeno_nucleus [...]
Quoted 1 line
rtser[X] should be available as soon as
xeno_16550Ais loaded, right ?
Only when you provided the correct module parameters... Isn't that documented somewhere? Don't remember right now, but if not, this requires fixing. Check what's available on your box via /proc/xenomai/rtdm.
Quoted 7 lines
Quoted 2 lines
Any frequent problems falling asleep? ;)
Usually not - we have national holiday today, so I was doing my stuff as long
as I wanted :-)
Yea, I can understand. The only problem is the code one produces between about 3 and 5 am - mine is generally just "interesting". Later it gets better again. :)
Jan
Hi Jan!
Jan Kiszka wrote:
[...]
Quoted 6 lines
Quoted 1 line
rtser[X] should be available as soon as
xeno_16550Ais loaded, right ?Only when you provided the correct module parameters... Isn't that documented somewhere? Don't remember right now, but if not, this requires fixing. Check what's available on your box via
/proc/xenomai/rtdm.
E.g.:
# cat named_devices Hash Name /proc
I didn't find any page so far documenting the parameters, but they should be something like this ?
# insmod /usr/realtime/modules/xeno_16550A.ko ioaddr=3f8 irq=4 tx_fifo=10 start_index=0 But I get: insmod: error inserting '/usr/realtime/modules/xeno_16550A.ko': -1 Device or resource busy
During boot, this appears in the kernel log:
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
Maybe this is causing the device to be busy ?
Thanks a lot and best regards,
Hannes.
Quoted 16 lines · Hannes Mayer
Hi Jan!
Jan Kiszka wrote:
[...]Quoted 8 lines
Quoted 1 line
rtser[X] should be available as soon as
xeno_16550Ais loaded, right ?Only when you provided the correct module parameters... Isn't that documented somewhere? Don't remember right now, but if not, this requires fixing. Check what's available on your box via
/proc/xenomai/rtdm.E.g.:
Quoted 8 lines
# cat named_devices Hash Name /procI didn't find any page so far documenting the parameters, but they should be
something like this ?# insmod /usr/realtime/modules/xeno_16550A.ko ioaddr=3f8 irq=4 tx_fifo=10 start_index=0
Almost: ioaddr=0x3f8
Ok, we need some README about xeno_16550A somewhere. Where would you look for information first?
Quoted 10 lines
But I get:
insmod: error inserting '/usr/realtime/modules/xeno_16550A.ko': -1 Device or resource busyDuring boot, this appears in the kernel log:
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled ttyS0 at I/O0x3f8(irq = 4) is a 16550A
ttyS1 at I/O0x2f8(irq = 3) is a 16550A
Maybe this is causing the device to be busy ?
"setserial /dev/ttyS0 uart none" releases the first port.
Also something for a README. :-/
Jan
Hi Jan!
Jan Kiszka wrote:
[...]
Quoted 1 line
Almost: ioaddr=0x3f8
Yep, tried that too before, but disabling ttyS0 with setserial did the trick :-)
Quoted 2 lines
Ok, we need some README about
xeno_16550Asomewhere. Where would you look for information first?
API-docs -> Modules -> Real-Time Driver Model -> Device Profiles -> Serial Devices ?
Quoted 3 lines
"setserial
/dev/ttyS0uart none" releases the first port.Also something for a README. :-/
I'd add that to the API-docs too.
Just one further thing:
I've modified rt_serial_uprog.c and I just open rtser0 for reading and writing. That works, I can write to it and read data back from it, but:
In read_task_proc:
ret = rt_dev_ioctl(my_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );
rt_dev_ioctl always returns -1 - it doesn't block.
rtser_config for rtser0:
static const struct rtser_config ser_config = {
0xFFFF, /* config_mask */
RTSER_9600_BAUD, /* baud_rate */
RTSER_ODD_PARITY , /* parity */
RTSER_8_BITS , /* data_bits */
RTSER_1_STOPB , /* stop_bits */
RTSER_NO_HAND , /* handshake */
RTSER_DEF_FIFO_DEPTH, /* fifo_depth*/
RTSER_DEF_TIMEOUT, /* rx_timeout */
RTSER_DEF_TIMEOUT, /* tx_timeout */
RTSER_DEF_TIMEOUT, /* event_timeout */
RTSER_RX_TIMESTAMP_HISTORY, /* timestamp_history */
RTSER_EVENT_RXPEND /* event mask */
};
How can I get rt_dev_ioctl to block ?
Thank you very much for your time Jan! :-)
Best regards,
Hannes.
Hannes Mayer wrote:
[...]
Quoted 7 lines
Just one further thing:
I've modifiedrt_serial_uprog.cand I just open rtser0 for reading and writing. That works, I can write to it and read data back from it, but:In
read_task_proc:ret = rt_dev_ioctl(my_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );
rt_dev_ioctlalways returns -1 - it doesn't block.
[...]
Quoted 1 line
How can I get
rt_dev_ioctlto block ?
AHA! Found it! :-)
There is
if (!rtdm_in_rt_context())
return -EPERM;in rt_16550_ioctl(...)
Silly me put a printf into it:
ret = rt_task_set_mode(0, T_PRIMARY, NULL); [...] printf(RTASK_PREFIX "waiting for event\n"); ret = rt_dev_ioctl(write_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );
so the whole thing was not in RT anymore.
Thanks again and best regards,
Hannes.
Quoted 11 lines · Hannes Mayer
Hi Jan!
Jan Kiszka wrote:
[...]Quoted 1 line
Almost: ioaddr=0x3f8
Yep, tried that too before, but disabling ttyS0 with setserial did the trick :-)
Quoted 6 lines
Quoted 2 lines
Ok, we need some README about
xeno_16550Asomewhere. Where would you look for information first?API-docs -> Modules -> Real-Time Driver Model -> Device Profiles -> Serial Devices ?
Hmm, that part is intended to remain implementation indepent. Will have to think about it.
Quoted 7 lines
Quoted 1 line
How can I get
rt_dev_ioctlto block ?AHA! Found it! :-)
There is
if (!rtdm_in_rt_context()) return -EPERM;
Quoted 8 lines
in
rt_16550_ioctl(...)Silly me put a printf into it:
ret = rt_task_set_mode(0, T_PRIMARY, NULL); [...] printf(RTASK_PREFIX "waiting for event\n"); ret = rt_dev_ioctl(write_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );so the whole thing was not in RT anymore.
But this one IS documented! ;)
Well, the patch containing this check is rather new. Maybe it should better read like this:
if (!rtdm_in_rt_context())
return -ENOSYS;
The result would be that the nucleus will try to switch the caller to RT on return and restart the call afterwards. Then you shouldn't notice any error. Patch in preparation...
Jan
Jan Kiszka wrote:
[...]
Quoted 5 lines
Quoted 2 lines
API-docs -> Modules -> Real-Time Driver Model -> Device Profiles -> Serial Devices ?
Hmm, that part is intended to remain implementation indepent. Will have to think about it.
Ok, what about a README.DRIVERS in the root-dir of the xeno tarball ? This file could contain any information regarding RTDM drivers.
[...]
Quoted 9 lines
Well, the patch containing this check is rather new. Maybe it should better read like this:
if (!rtdm_in_rt_context())
return -ENOSYS;The result would be that the nucleus will try to switch the caller to RT on return and restart the call afterwards. Then you shouldn't notice any error. Patch in preparation...
I dunno if either solution is good. IMO, if the program is not in RT, it should work anyway. And I'm not sure if it's good, if it ist switched sliently to RT... *shrugs*
Thanks and best regards,
Hannes.
Quoted 3 lines
Ok, what about a README.DRIVERS in the root-dir of the xeno tarball ? This file could contain any information regarding RTDM drivers.
According to the current file layout, this file should rather be called rtdm.txt and be placed into skins/rtdm/doc (cf. doc files for the other skins).
Or it would be preferable to rename all skins/*/doc/*.txt files into README.* files in the root directory.
Signature · 1 line
Romain Lenglet