779 views|1 replies

501

Posts

4

Resources
The OP
 

[2023 DigiKey Contest Participation Award] BeagleBone_Green development board for serial port development based on Ibserialport [Copy link]

 

This article is reproduced from my official account

The board is based on Ibserialport for serial port development

https://mp.weixin.qq.com/s/14_pt_OkyrNTEPGlB9gWBw Play board series 3: BeagleBone_Green development board based on Ibserialport for serial port development

1. Introduction

Serial port is the most commonly used communication interface in embedded development and needs to be used frequently. A good serial port development library can be more convenient, simple and efficient than directly operating the device file reading and writing. Here we share a better cross-platform serial port library libserialport and its application examples on this development board.

2. Enable the serial port

View the device tree

debian@BeagleBone:~$ ls /lib/firmware/BB-UART*

/lib/firmware/BB-UART1-00A0.dtbo

/lib/firmware/BB-UART1-RTSCTS-00A0.dtbo

/lib/firmware/BB-UART2-00A0.dtbo

/lib/firmware/BB-UART2-00A1.dtbo

/lib/firmware/BB-UART2-RTSCTS-00A0.dtbo

/lib/firmware/BB-UART3-00A0.dtbo

/lib/firmware/BB-UART4-00A0.dtbo

/lib/firmware/BB-UART4-E-INK.dtbo

/lib/firmware/BB-UART4-RS485-00A0.dtbo

/lib/firmware/BB-UART4-RTSCTS-00A0.dtbo

/lib/firmware/BB-UART5-00A0.dtbo

/lib/firmware/BB-UART5-RTSCTS-00A0.dtbo

debian@BeagleBone:~$

View device tree contents

cat /lib/firmware/BB-UART1-00A0.dtbo

sudo nano /boot/uEnv.txt Add the following content to enable device tree and reboot

# UART 1

uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo

# UART 2

uboot_overlay_addr1=/lib/firmware/BB-UART2-00A0.dtbo

# UART 4

uboot_overlay_addr2=/lib/firmware/BB-UART4-00A0.dtbo

# UART 5

uboot_overlay_addr3=/lib/firmware/BB-UART5-00A0.dtbo

# UART 3 (only TX). Note that in "uboot_overlay_addrX", the X need not be = UART id

uboot_overlay_addr4=/lib/firmware/BB-UART3-00A0.dtbo

3. Use Ibserialport source code to build applications

Download the code

git clone git://sigrok.org/libserialport

At the same level as libserialport

Copy the test code

cp libserialport/examples/send_receive.c .

The newly created config.h file can be an empty file

Required documents

libserialport.h

libserialport_internal.h

serialport.c

timing.c

linux.c

linux_termios.c

linux_termios.h

Compile

gcclibserialport/serialport.clibserialport/timing.clibserialport/linux.clibserialport/linux_termios.csend_receive.c-osend_receive-Ilibserialport/ -I.-DSP_PRIV=

Running Tests

sudo cat /proc/tty/drivers

debian@BeagleBone:~$ sudo cat /proc/tty/drivers

/dev/tty /dev/tty 5 0 system:/dev/tty

/dev/console /dev/console 5 1 system:console

/dev/ptmx /dev/ptmx 5 2 system

/dev/vc/0 /dev/vc/0 4 0 system:vtmaster

g_serial /dev/ttyGS 242 0-7 serial

serial /dev/ttyS 4 64-69 serial

pty_slave /dev/pts 136 0-1048575 pty:slave

pty_master /dev/ptm 128 0-1048575 pty:master

unknown /dev/tty 4 1-63 console

debian@BeagleBone:~$

correspond

debian@BeagleBone:~$ ls /dev/ttyS

ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5

We use UART4 to test and short the RXD and TXD of UART4.

debian@BeagleBone:~$ ./send_receive /dev/ttyS4

Looking for port /dev/ttyS4.

Opening port.

Setting port to 9600 8N1, no flow control.

Sending 'Hello!' (6 bytes) on port /dev/ttyS4.

Sent 6 bytes successfully.

Receiving 6 bytes on port /dev/ttyS4.

Received 6 bytes successfully.

Received 'Hello!'.

debian@BeagleBone:~$

IV. Conclusion

Based on the blocking and non-blocking interfaces provided by libserial, serial port applications can be developed quickly.

This post is from DigiKey Technology Zone

Latest reply

The blocking and non-blocking interfaces provided by libserial can quickly develop serial port applications, perfect   Details Published on 2024-5-16 07:45
 
 

6570

Posts

0

Resources
2
 

The blocking and non-blocking interfaces provided by libserial can quickly develop serial port applications, perfect

This post is from DigiKey Technology Zone
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list