* [Xenomai-help] unable to open serial port from a kernel module
@ 2009-11-11 8:52 Anisha Kaul
2009-11-11 9:19 ` Jan Kiszka
0 siblings, 1 reply; 5+ messages in thread
From: Anisha Kaul @ 2009-11-11 8:52 UTC (permalink / raw)
To: xenomai
hi,
when i use rt_dev_open ("/dev/ttyS0", 0); from the function init_module () of
a self written kernel module, it returns -19 ! What must be the reason, can't
a file be opened from a kernel module ?
kindly help !
-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] unable to open serial port from a kernel module
2009-11-11 8:52 [Xenomai-help] unable to open serial port from a kernel module Anisha Kaul
@ 2009-11-11 9:19 ` Jan Kiszka
2009-11-11 13:19 ` Anisha Kaul
2009-11-11 14:02 ` Anisha Kaul
0 siblings, 2 replies; 5+ messages in thread
From: Jan Kiszka @ 2009-11-11 9:19 UTC (permalink / raw)
To: Anisha Kaul; +Cc: xenomai
Anisha Kaul wrote:
> hi,
>
> when i use rt_dev_open ("/dev/ttyS0", 0); from the function init_module () of
> a self written kernel module, it returns -19 ! What must be the reason, can't
> a file be opened from a kernel module ?
Please read documentation and examples more carefully: "rtdev0" is the
answer.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] unable to open serial port from a kernel module
2009-11-11 9:19 ` Jan Kiszka
@ 2009-11-11 13:19 ` Anisha Kaul
2009-11-11 14:02 ` Anisha Kaul
1 sibling, 0 replies; 5+ messages in thread
From: Anisha Kaul @ 2009-11-11 13:19 UTC (permalink / raw)
To: xenomai
> Anisha Kaul wrote:
> > hi,
> >
> > when i use rt_dev_open ("/dev/ttyS0", 0); from the function init_module
> > () of a self written kernel module, it returns -19 ! What must be the
> > reason, can't a file be opened from a kernel module ?
>
> Please read documentation and examples more carefully: "rtdev0" is the
> answer.
>
> Jan
Thanks for being patient,
Did you mean this --> ''rtdm_open ("rtdev0", 0);"
I tried this from the init_module () of the concerned kernel module, it still
returns '-19'.
Anyways, as per your example '', I tried --> "rt_dev_open ("rtdev0", 0);"
from the main () function of the user space program. As per one of your mails
I added "-lrtdm" to the LDFLAGS of the concerned Makefile for the compilation
of rt_dev_open. The program compiled without errors but still it
returns '-19'.
regards,
anisha
-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] unable to open serial port from a kernel module
2009-11-11 9:19 ` Jan Kiszka
2009-11-11 13:19 ` Anisha Kaul
@ 2009-11-11 14:02 ` Anisha Kaul
2009-11-11 14:30 ` Stefan Kisdaroczi
1 sibling, 1 reply; 5+ messages in thread
From: Anisha Kaul @ 2009-11-11 14:02 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
On Wednesday November 11 2009 14 : 49 : 19 you wrote:
> Anisha Kaul wrote:
> > hi,
> >
> > when i use rt_dev_open ("/dev/ttyS0", 0); from the function init_module
> > () of a self written kernel module, it returns -19 ! What must be the
> > reason, can't a file be opened from a kernel module ?
>
> Please read documentation and examples more carefully: "rtdev0" is the
> answer.
>
> Jan
Hi,
I forgot to attach the kernel module file as well as the user space file in
the previous mail. Hereby I have included both of them !
kernel module file: serialPortISR.c
user space file : userSpace.c
thanks,
anisha
[-- Attachment #2: serialPortISR.c --]
[-- Type: text/x-csrc, Size: 1499 bytes --]
#include <native/task.h>
#include <native/heap.h>
#include <native/intr.h>
#include <linux/kernel.h>
#include <rtdm/rtdm_driver.h>
#define PORT 0x3F8
RT_INTR serialRT;
RT_HEAP heap_desc;
rtdm_task_t task;
char* shmem;
static rtdm_task_t tasklet;
static int times;
rtdm_task_proc_t resetRegisters (void * f)
{
outb (0x83, PORT + 3);
outb (0x01, PORT + 0);
outb (0x00, PORT + 1);
outb (0x03, PORT + 3);
outb (0x01, PORT + 1);
outb (0x27, PORT + 2);
outb (0x08, PORT + 4);
return NULL;
}
rt_isr_t isrSerialPort (int irq, void *dev_id, struct pt_regs *regs)
{
times++;
printk (KERN_ALERT "\nisrSerialPort called %d ", times);
*shmem = inb (PORT);
printk ("\nsharedMem: %s", shmem);
rtdm_task_init (&tasklet, "tasklet", resetRegisters, NULL, 1, 0);
return (rt_isr_t) IRQ_HANDLED;
}
int init_module ()
{
rt_intr_create (&serialRT, "softbrainISR", 4, isrSerialPort, NULL, I_SHARED);
rt_intr_enable (&serialRT);
outb (0x83, PORT + 3);
outb (0x01, PORT + 0);
outb (0x00, PORT + 1);
outb (0x03, PORT + 3);
outb (0x01, PORT + 1);
outb (0x27, PORT + 2);
outb (0x08, PORT + 4);
rt_heap_create (&heap_desc, "MyHeap", 16384, H_SHARED);
rt_heap_alloc (&heap_desc, 0, TM_NONBLOCK, (void*)&shmem);
return result;
}
void cleanup_module ()
{
rt_heap_free (&heap_desc, &shmem);
rt_intr_delete (&serialRT);
printk (KERN_ALERT "\ncleanup_module called\n");
}
MODULE_LICENSE ("GPL");
[-- Attachment #3: userSpace.c --]
[-- Type: text/x-csrc, Size: 570 bytes --]
#include <sys/mman.h>
#include <native/task.h>
#include <native/timer.h>
#include <native/heap.h>
#include <string.h>
#include <rtdm/rtdm.h>
RT_TASK task_desc;
RT_HEAP heap_desc;
void* shmem;
int main ()
{
mlockall (MCL_CURRENT|MCL_FUTURE);
rt_heap_bind (&heap_desc, "MyHeap", TM_NONBLOCK);
rt_heap_alloc (&heap_desc, 1, TM_NONBLOCK, &shmem);
/***************************************/
int result = rt_dev_open ("rtdev0", 0);
printf ("\n%d passed ", result);
rt_dev_write (result, "abcd", 4);
/***************************************/
}
[-- Attachment #4: Type: text/plain, Size: 79 bytes --]
-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-help] unable to open serial port from a kernel module
2009-11-11 14:02 ` Anisha Kaul
@ 2009-11-11 14:30 ` Stefan Kisdaroczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Kisdaroczi @ 2009-11-11 14:30 UTC (permalink / raw)
To: Anisha Kaul, xenomai
[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]
Hi,
> int main ()
> {
> mlockall (MCL_CURRENT|MCL_FUTURE);
you need to call rt_task_shadow(...) here (see docs),
which turns the current Linux task into a native Xenomai task.
> rt_heap_bind (&heap_desc, "MyHeap", TM_NONBLOCK);
> rt_heap_alloc (&heap_desc, 1, TM_NONBLOCK, &shmem);
check all return values. I guess its -19 too without rt_task_shadow.
> /***************************************/
> int result = rt_dev_open ("rtdev0", 0);
>
> printf ("\n%d passed ", result);
>
> rt_dev_write (result, "abcd", 4);
> /***************************************/
> }
good luck,
kisda
Anisha Kaul schrieb:
> On Wednesday November 11 2009 14 : 49 : 19 you wrote:
>> Anisha Kaul wrote:
>>> hi,
>>>
>>> when i use rt_dev_open ("/dev/ttyS0", 0); from the function init_module
>>> () of a self written kernel module, it returns -19 ! What must be the
>>> reason, can't a file be opened from a kernel module ?
>> Please read documentation and examples more carefully: "rtdev0" is the
>> answer.
>>
>> Jan
>
> Hi,
>
> I forgot to attach the kernel module file as well as the user space file in
> the previous mail. Hereby I have included both of them !
>
> kernel module file: serialPortISR.c
> user space file : userSpace.c
>
> thanks,
> anisha
>
>
> ------------------------------------------------------------------------
>
>
>
> -------------------------------------
> Hi-Tech Gears Limited, Gurgaon, India
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-11-11 14:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11 8:52 [Xenomai-help] unable to open serial port from a kernel module Anisha Kaul
2009-11-11 9:19 ` Jan Kiszka
2009-11-11 13:19 ` Anisha Kaul
2009-11-11 14:02 ` Anisha Kaul
2009-11-11 14:30 ` Stefan Kisdaroczi
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.