lkml.org 
[lkml]   [2007]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: How to access correctly serial port inside module?
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Jan Engelhardt schrieb:
    > 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
    is it the way to access from kernelspace the userspace fs?
    the not-correct-way?

    If it is so, I will wait for another solution ;)

    Dont want to learn writing nasty kernel code. *g*

    Anyway thx.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.3 (MingW32) - GPGrelay v0.959

    iD8DBQFGVeRlAAomYJ1taN8RAj4LAJ4oD+3yGy6k69nBEXi5BSda+tdeNACeOCTY
    +nJSUcsGpwh25uDjyC2GKRU=
    =twVz
    -----END PGP SIGNATURE-----
    begin:vcard
    fn:Lars K.W. Gohlke
    n:Gohlke;Lars K.W.
    email;internet:lkwg82@gmx.de
    x-mozilla-html:FALSE
    version:2.1
    end:vcard

    \
     
     \ /
      Last update: 2007-05-24 21:19    [W:0.025 / U:32.428 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site