virtual serial port driver..... - Linux

This is a discussion on virtual serial port driver..... - Linux ; hi all..... i want to prorgam a device driver that act as a serial port driver.....actually a virtuall serial port driver, on the lower layer.. it will connect to network. i want to implement a driver that can control the ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: virtual serial port driver.....

  1. virtual serial port driver.....

    hi all.....

    i want to prorgam a device driver that act as a serial port
    driver.....actually a virtuall serial port driver, on the lower layer..
    it will connect to network.

    i want to implement a driver that can control the baudrate that define
    by the user....


    my question is....

    is it the same way to develop it with a regular serial char drive???

    how i control the baud rate on the module???

    or is there an example of virtual serial port driver in linux??

    P.S i use kernel 2.6

    thnx..


  2. Re: virtual serial port driver.....

    marojahan wrote:

    > hi all.....
    >
    > i want to prorgam a device driver that act as a serial port
    > driver.....actually a virtuall serial port driver, on the lower layer..
    > it will connect to network.
    >
    > i want to implement a driver that can control the baudrate that define
    > by the user....
    >
    >
    > my question is....
    >
    > is it the same way to develop it with a regular serial char drive???


    No. You can write a char driver which behaves like a serial
    port, but that means that you have to implement a long list
    of IOCTLs.

    They tty subsystem in the kernel takes care of most of this.
    You need to write a tty driver.

    http://lwn.net/images/pdf/LDD3/ch18.pdf

    >
    > how i control the baud rate on the module???

    Your driver's set_termios method gets called with
    the port parameters which include the baudrate.

    >
    > or is there an example of virtual serial port driver in linux??


    Depends what you mean by virtual. There are USB serial port
    drivers which don't talk directly to hardware, but use
    the USB subsystem. Your UART-over-network driver would look
    very similar.

    Regards,

    Iwo


  3. Re: virtual serial port driver.....

    On 2006-10-18, marojahan wrote:
    > hi all.....
    >
    > i want to prorgam a device driver that act as a serial port
    > driver.....actually a virtuall serial port driver, on the lower layer..
    > it will connect to network.
    >
    > i want to implement a driver that can control the baudrate that define
    > by the user....
    >
    >
    > my question is....
    >
    > is it the same way to develop it with a regular serial char drive???


    Yes -- you must implement the same API (the interface between
    the low-level driver and the line-discipline layer) that all of
    the other low-level serial drivers implement.

    Alternatively, there is a "common" low-level serial driver
    (another layer below the line discipline layer) that assumes
    it's talking to a UART that has fifos and causes interrupts.
    You can make your driver talk to the common low-level driver if
    you want, but in my experience that API doesn't work well with
    network-attached hardware.

    > how i control the baud rate on the module???


    termios

    > or is there an example of virtual serial port driver in linux??


    There are a number of network-attached serial hardware vendors
    that provide drivers, but I don't think there are any drivers
    for such hardware included in the kernel.

    --
    Grant Edwards grante Yow! .. here I am in 53
    at B.C. and all I want is a
    visi.com dill pickle!!

  4. Re: virtual serial port driver.....

    On 2006-10-18, Iwo Mergler wrote:

    >> is it the same way to develop it with a regular serial char drive???

    >
    > No. You can write a char driver which behaves like a serial
    > port, but that means that you have to implement a long list
    > of IOCTLs.


    Including the line discipline layer, which will be a bitch to
    get right.

    > They tty subsystem in the kernel takes care of most of this.
    > You need to write a tty driver.
    >
    > http://lwn.net/images/pdf/LDD3/ch18.pdf


    I'm glad somebody is finally documenting tty drivers! I would
    have killed for that chapter a few years ago.

    --
    Grant Edwards grante Yow! Kids, don't gross me
    at off... "Adventures with
    visi.com MENTAL HYGIENE" can be
    carried too FAR!

  5. Re: virtual serial port driver.....

    marojahan wrote:
    > hi all.....
    >
    > i want to prorgam a device driver that act as a serial port
    > driver.....actually a virtuall serial port driver, on the lower layer..
    > it will connect to network.


    This is done by using a pseudo-tty device. Pseudo is another term for
    virtual, and a tty is the Unix and Linux name for anything that looks
    like a serial line.

    Pseudo-terminal devices are also used in the implementation of terminal
    emulator programs such as xterm. Programs running under xterm think
    they are talking to a serial device. You can set the baud rate in
    xterm. But of course, it's ignored since it doesn't make sense.

    Back in 1996, a little program called "modemu" was written by someone,
    demonstrating the reverse use of a pseudo tty. With the help of a
    serial communication program like minicom, you talk to modemu through
    a pseudo-tty device that it creates, and command it to make TCP
    connections using Hayes AT commands.

    > i want to implement a driver that can control the baudrate that define
    > by the user....


    Why do you want to control the baud rate, if you are connecting to a
    network, rather than over hardware which has baud rate?

    If you want to actually emulate the slow speed, I think you should be
    able to retrieve the tty parameters on the master side of the device,
    and use that as a parameter to your simulated slow I/O.


  6. Re: virtual serial port driver.....

    On 2006-10-19, Kaz Kylheku wrote:
    > marojahan wrote:
    >> hi all.....
    >>
    >> i want to prorgam a device driver that act as a serial port
    >> driver.....actually a virtuall serial port driver, on the lower layer..
    >> it will connect to network.

    >
    > This is done by using a pseudo-tty device.


    Not when the "virtual" serial port needs to act like a real
    one.

    Pty's don't allow for control of things like parity, number of
    data bits, and don't allow implementation of any of the modem
    control/status functionality require for a "real" serial port.

    > Pseudo is another term for virtual, and a tty is the Unix and
    > Linux name for anything that looks like a serial line.
    >
    > Pseudo-terminal devices are also used in the implementation of terminal
    > emulator programs such as xterm. Programs running under xterm think
    > they are talking to a serial device.


    Some do, some don't. Any program that requires more than the
    _very_ rudimentary features of a serial port will bomb out when
    handed a pty device. For example TIOCMSET and TIOCMGET ioctl()
    calls will fail. Parity and character width settings will get
    overridden by the pty driver. There are a few other minor
    problems also, but those the the big ones.

    > You can set the baud rate in xterm. But of course, it's
    > ignored since it doesn't make sense.


    You can set the baud rate, but you can't set parity or number
    of data bits. You can't read the modem status lines. You
    can't control the modem control lines.

    >> i want to implement a driver that can control the baudrate
    >> that define by the user....

    >
    > Why do you want to control the baud rate, if you are connecting to a
    > network, rather than over hardware which has baud rate?


    He may be connecting _through_ the network to real serial
    hardware that requires control of baud rate, parity, modem
    lines, etc.

    > If you want to actually emulate the slow speed, I think you
    > should be able to retrieve the tty parameters on the master
    > side of the device, and use that as a parameter to your
    > simulated slow I/O.


    --
    Grant Edwards grante Yow! Now I'm concentrating
    at on a specific tank battle
    visi.com toward the end of World
    War II!

+ Reply to Thread