adrianomarto / soft_uart

Software-based serial port module for Raspberry Pi.
GNU General Public License v3.0
156 stars 83 forks source link

soft_uart

Software-based serial port module for Raspberry Pi.

This module creates a software-based serial port using a configurable pair of GPIO pins. The serial port will appear as /dev/ttySOFT0.

Features

Compiling

Fetch the source:

git clone https://github.com/adrianomarto/soft_uart

Install the package raspberrypi-kernel-headers:

sudo apt-get install raspberrypi-kernel-headers

Run make and make install, as usual.

cd soft_uart
make
sudo make install

I haven't tried cross-compiling this module, but it should work as well.

Loading

Module parameters:

Loading the module with default parameters:

sudo insmod soft_uart.ko

Loading module with custom parameters:

sudo insmod soft_uart.ko gpio_tx=10 gpio_rx=11

Usage

The device will appear as /dev/ttySOFT0. Use it as any usual TTY device.

You must be included in the group dialout. You can verify in what groups you are included by typing groups. To add an user to the group dialout, type:

sudo usermod -aG dialout <username>

Usage examples:

minicom -b 4800 -D /dev/ttySOFT0
cat /dev/ttySOFT0
echo "hello" > /dev/ttySOFT0

Baud rate

When choosing the baud rate, take into account that:

As a result, you can expect communication errors when using fast baud rates. So I would not try to go any faster than 4800 bps.