Specifying Non-Standard Baud Rate for Ftdi Virtual Serial Port Under Linux

Specifying non-standard baud rate for FTDI virtual serial port under Linux

You can't change baud base, I suppose it is hardware related. So messing with the module won't do you any good. In your third point you only talk about the first method proposed for setting a custom baudrate, where you need to access the tty->alt_speed. It seems there is no interface to directly set tty struct from userspace, at least not with the ftdi_sio driver.

However, there is another method explained in the comments :

     * 3. You can also set baud rate by setting custom divisor as follows
* - set tty->termios->c_cflag speed to B38400
* - call TIOCSSERIAL ioctl with (struct serial_struct) set as
* follows:
* o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
* o custom_divisor set to baud_base / your_new_baudrate

Did you try it ?

Tcl refuses to set 76800 baud rate for serial channel on Linux

Tcl refuses to set the speed to those values because the underlying C functions don't support those baud rates on Linux. In fact, it's not Tcl or even your libc that's the problem here, but Linux: it supports a fixed set of baud rates, and 76800 is not one of them.

On my system (Debian sid), the baud rates beyond the ones specified by POSIX are visible in /usr/include/x86_64-linux-gnu/bits/termios-baud.h. This location may differ based on the OS and version.

If you want to use this serial device, you'll need to configure it for a different rate. The closest ones are 57600 and 115200. The maximum supported POSIX-specified version is 38400.

Is there any way we can change the default baud rate of FT230X devices in ubuntu 20.04 system?

If I understand your questions correctly, it implies some missconcept about how the FTDI UART bridges work:

  1. There are two different "ways" to address a FTDI USB-UART-bridge: Virtual Com Port (VCP) or D2XX driver. The former is very confinient and allows to every program to address the bridge IC as a com port. The D2XX allows a much deeper control and access to GPIOs, non UART protocols (if supported), latency settings etc. Under windows both drivers can be switched "on-the-fly", while under unix systems a "manual" driver switch is maybe required.

  2. If one uses the VCP driver and opens a handle to a com port the baud rate can be set during this. E.g. in python serial.Serial("/dev/ttyUSB0", 9600). Similar one can set the baud rate of an FT devices using the D2XX driver (FT_SetBaudRate). However the baud rate setting is "per opening". Why it is not a permanent setting? Because the baud rate is meaningless if no handle is open as no operation can take place and it is common practice to set the baud rate if one opens a COM port anyway.

Dealing with serial port at 100 baud rate

You're actually in luck. 100 baud is low enough that you can compute a divisor that will do it (1,152) with typical 16450-compatible serial ports (which is pretty much what everything is) and linux supports custom divisors with the spd_cust parameter to setserial.

Virtual Serial Port for Linux

You can use a pty ("pseudo-teletype", where a serial port is a "real teletype") for this. From one end, open /dev/ptyp5, and then attach your program to /dev/ttyp5; ttyp5 will act just like a serial port, but will send/receive everything it does via /dev/ptyp5.

If you really need it to talk to a file called /dev/ttys2, then simply move your old /dev/ttys2 out of the way and make a symlink from ptyp5 to ttys2.

Of course you can use some number other than ptyp5. Perhaps pick one with a high number to avoid duplicates, since all your login terminals will also be using ptys.

Wikipedia has more about ptys: http://en.wikipedia.org/wiki/Pseudo_terminal



Related Topics



Leave a reply



Submit