Testing the serial port

To get to know how to access serial devices I decided to write some simple test code. I connected an Arduino board to the UART1 port of BeagleBone Black as seen here.

Wiring Arduino and BBB

ENABLE UART PORTS ON Jessie

To enable the UART1 port I openedĀ /etc/default/capemgr in vim and added the following line to the bottom:

vim /etc/default/capemgr
----------------------------------------------------
# Options to pass to capemgr
CAPE=BB-UART1,BB-UART2,BB-UART3,BB-UART4

enable uart ports on wheezy

To enable the UART1 port I opened /boot/uEnv.txt in vim and added the following line to the bottom:

vim /boot/uEnv.txt
----------------------------------------------------
##Enable UART ports
cape_enable=capemgr.enable_partno=BB-UART1

So tail gives the following:

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

##Enable UART ports
cape_enable=capemgr.enable_partno=BB-UART1

uuid=0478ef9b-40b8-4b33-b24a-43dbccf19b0b

Communicating through uart

I then wrote some Arduino code which sends 5000 messages to the UART port. On the BB I read the messages using the termios API (see man termios ) and write each message with a tag (time, date) to a file. Currently, everything works fine, but I think if there should arise any issues in terms of performance making the file writing and port reading asynchronously (possibly also using IO interrupts via SIGIO?) should give the whole process more performance.

The code can be found in my GSoC preparation repo

 

How to wire the Arduino to the BBB for testing purposes
Testing the serial port