Re: Low-level serial communication with USB2SERIAL converter

From: Byron A Jeff (byron_at_cc.gatech.edu)
Date: 10/16/04


Date: 16 Oct 2004 17:45:14 -0400

In article <66256eff.0410131101.379a558f@posting.google.com>,
Szymon Lukasik <szymonl@poczta.onet.pl> wrote:

Sorry I'm slow getting back. It's been a busy week.

>> BAJ wrote...
>> Use the higher level interface that the driver provides you. That's why
>> it exists, so that you can access the serial port though it's connected
>> to a USB cable. There are no corresponding low level registers for you to
>> work with.
>>
>> A question: why do you need access to the low level registers? What
>> functionality are you looking for that requires direct register access.
>
>The first simple reason I wanted to use those low-level functions is
>... I've already implemented them. And for standard serial ports it's
>working fine...

But again you seem to miss the point. The whole point of a device driver
is to provide a consistent interface to an activity. You want to do serial.
The linux serial driver provides you all the functionality you need to
do serial with a standard serial port. The USB serial driver provides the
exact same functionality, except that it works on a USB serial cable.

By your application gets to see and use the same interface. Which of course
as you are now seeing is of great benefit.

>
>The use of higher level interface is not a problem for me... but
>there's one thing which is completely blocking my work. The
>Microcontroller's loader with 16Mhz quartz is communicating with my PC
>using baud-rate (14400) which is not implemented in termios.h (if I'm
>not wrong).

You can use setserial or its equivalent to get the correct bit rate.
Since 14400 is exactly 1/8 of 115200, which is a standard bit rate
for a PC serial port, you shold be able to get it no problem.

As to how it's done, setserial is a program that let's you set a custom
divisor that is applied when you set the bit rate to 38.4Kbps. So
set the divisor to 8, then set your bit rate to 38.4K and you're done.

>
>> Finally direct register access hurts you because then your application
>> must be run as root to gain access to the registers anyway.
>>
>> All the way around this is a poorly thought out path. So if you can come
>> back with an explanation of why you think you need register access and then
>> maybe we can figure out another path.
>
>Ok, so the problem is - how to set baudrate 14400 using C, under
>Linux, with the possibility of working with usb-serial converters?

See above. It's all done for you already.

BAJ



Relevant Pages

  • Re: COM correct choice for my application?
    ... A device driver communicates ... functionality. ... > I am developing a custom piece of hardware that connects to the computer ... > to my code at compile-time (just the interface I have defined). ...
    (microsoft.public.win32.programmer.ole)
  • Re: Linux Firewall/LoadBalancer
    ... The bonding driver originally came from Donald Becker's beowulf patches for ... Build kernel with the bonding driver ... "Bonding driver support" in the "Network device support" section. ... so the bonding driver will automatically load when the bond0 interface is ...
    (Security-Basics)
  • [PATCH] IPMI driver updates, part 2
    ... It has been far too long since the last IPMI driver updates, ... This second part adds the "System Interface" driver. ...
    (Linux-Kernel)
  • [2.6 patch] remove comx driver docs
    ... info on the driver for Baycom style amateur radio modems ... -LMI) protocols are available as link-level protocol. ... -The COMX driver set has a new type of user interface based on the /proc ... -To create the interface 'comx0' which is the first channel of a COMX card: ...
    (Linux-Kernel)
  • [2.6 patch] remove the documentation for the legacy CDROM drivers
    ... This patch removes the documentation for the removed legacy CDROM drivers. ... SC1200 WDT DRIVER ... LaTeX document on standardizing the CD-ROM programming interface. ... THIS DRIVER WILL WORK WITH THE CD-ROM DRIVES LISTED, ...
    (Linux-Kernel)