[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.61.0705241927410.31549@yvahk01.tjqt.qr>
Date: Thu, 24 May 2007 19:29:29 +0200 (MEST)
From: Jan Engelhardt <jengelh@...ux01.gwdg.de>
To: "Lars K.W. Gohlke" <lkwg82@....de>
cc: Tilman Schmidt <tilman@...p.cc>, linux-kernel@...r.kernel.org
Subject: Re: How to access correctly serial port inside module?
On May 24 2007 19:19, Lars K.W. Gohlke wrote:
> I want to read from serial port (I mean the port, which is called
> /dev/ttyS0 in user-space). Then I want copy_to_user() it through
> /proc/serialPort
>
> This is just to get familiar with driver programming (in kernelspace),
> it could be better done in userspace - I know. But this is for learning.
>
> It is a kind of synthetic problem, but after this, I hope too know how
> to handle further ones.
>
> Understood? It is a little bit strange, but hope it is explained well. ;)
>
> If tell me that for /dev/ttyS0 I can adept it to /dev/ttyS1 etc..
struct file *filp = filp_open("/dev/ttyS0");
char buf[4096];
mm_segment_t oldfs = get_fs();
loff_t pos = 0;
set_ds(KERNEL_DS);
while (vfs_read(filp, buf, sizeof(buf), &pos) > 0)
printk("%s\n", buf);
filp_close(filp);
[I've warned about it... ;-) ]
Jan
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists